GlowGrid woes

Started by skullywag, March 16, 2015, 05:14:10 PM

Previous topic - Next topic

skullywag

Hey all,

does anyone know how I can change a things def to another things def and have the glower update. i did it once but for some reason the same exact code wont work again (really its weird). So im simple doing:

this.def = ThingDef.named("Myotherthing");
Find.GlowGrid.MarkGlowGridDirty(Position);

but the glowgrid does not update and the glow is the same colour, im simply changing between 2 defs both with compglowers of differing colours. I can destroy and spawn to switch no problem, but ever since i got it to work once i dont want to do that. I just need the glow grid to update itself.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Leeman

What you can try is updating the Map after you changed the glowgrid. Graves update their Graphics using this line of code

Find.MapDrawer.MapChanged(this.Position, MapChangeType.Things);

Maybe this helps you somehow

skullywag

#2
Ive been trying that, perhaps both.....brb...

edit - nope.....grrrr
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Leeman

After looking in the Class MapChangeType

there is a special Enum for GroundGlow. Did you try doing the line above with MapChangeType.GroundGlow instead of MapChangeType.Things

skullywag

yep, will try again with both though.

edit - aaand nope.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

Leeman

Then I don't know. Sorry  :-\ You#re sure the compglower also updates if you just switch the it's def?

skullywag

Like i said i accidentally got it working, was clicking my ui button on the building and the glower was flipping lovely. I backed out to change the ui icon and it then stopped working....so confused.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mipen

You could try turning the glow off before changing the def (glower.Lit=false;) and then setting the new glower on once you have switched the def

skullywag

nope no dice. No matter what I do the glower will not change or will just go off and not come back on, even tried registering the glower after changing the def. Im so annoyed I cant replicate how i did it before, unless what I had was a bug and not supposed to happen and this is just not the way to do it....
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mipen

Are you just trying to change the colour of the glower? Or change the building as well?

skullywag

Well changing the colour of the glower was my initial goal, but as this is set in the glowers properties I cant change it for one building without effecting all the others. Unless Im misunderstanding something. So i moved on to setting up multiple buildings all the same with just different colour compglowers and am trying to now switch between them
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mipen

You could try using base.GetComp to get the instance of the glower on the building, then assign it a new CompProperties with the colour that you want, I'm not sure if it's private or not, but even then you could use reflection to change it. That might work. You could also look for a way to destroy the glower and add a new CompGlower