public void changeColourTest() { // new glower CompGlower myThingComp = new CompGlower(); myThingComp.parent = this.parent; CompProperties_Glower compProps = new CompProperties_Glower(); // color init curIndex = ((curIndex + 1) > 7) ? (0) : (curIndex + 1); newcolor = colors[curIndex]; // setting props compProps.glowColor = newcolor; compProps.glowRadius = glowRadius; // init myThingComp.Initialize(compProps); // applying to map Map myMap = parent.Map; IntVec3 myPos = parent.Position; myMap.mapDrawer.MapMeshDirty(myPos, MapMeshFlag.Things); myMap.glowGrid.RegisterGlower(myThingComp); // removing old glow parent.AllComps.Remove(glowComp); myMap.glowGrid.DeRegisterGlower(glowComp); // remembering what you did last summer glowComp = myThingComp; }
// Stone camp fire public static void SetCompGlower(Thing t, Map map, bool burning = true) { //Tools.Warn("Trying to set glow:"+burning, true); CompGlower comp = t.TryGetComp <CompGlower>(); if (comp is CompGlower) { /* * CompGlower myThingComp = new CompGlower(); * myThingComp.parent = (ThingWithComps)t; * * CompProperties compProps = new CompProperties(); * compProps.compClass = typeof(CompGlower); * * ColorInt newcolor = (burning)?(new ColorInt(252, 187, 113, 0) * 1.45f):( new ColorInt(255, 50, 0, 0) * 1.45f); * compProps.compClass.GetProperties. * compProps.glow = newcolor; * compProps.glowRadius = glowRadius; */ //myThingComp.Initialize(compProps); comp.Props.glowColor = (burning) ? (new ColorInt(252, 187, 113, 0) * 1.45f) : (new ColorInt(255, 50, 0, 0) * 1.45f); comp.Props.glowRadius = (burning) ? 10f : 2f; //Tools.Warn(" glow rad:" + comp.Props.glowRadius, true); comp.Initialize(comp.Props); comp.UpdateLit(map); map.glowGrid.RegisterGlower(comp); comp.UpdateLit(map); } else { Tools.Warn("should have found a CompGlower but no CompGlower found", true); } }
private void SetGlow(ColorInt glowColor, float glowRadius) { // new glower CompGlower myThingComp = new CompGlower(); myThingComp.parent = parent; CompProperties_Glower compProps = new CompProperties_Glower { // setting props glowColor = glowColor, glowRadius = glowRadius }; // init myThingComp.Initialize(compProps); // applying to map Map myMap = parent.Map; IntVec3 myPos = parent.Position; myMap.mapDrawer.MapMeshDirty(myPos, MapMeshFlag.Things); myMap.glowGrid.RegisterGlower(myThingComp); // removing old glow // AZAAAAARG UnsetGlow(); // remembering what you did last summer glowComp = myThingComp; }
public override void PostInitialize() { this.glower = new CompGlower(); this.hediffActionRate = 10; gProps.glowColor = glowColor; gProps.glowRadius = 1.4f; glower.parent = this.Pawn; glower.Initialize(gProps); }
//provides a new Compglower public static CompGlower newCompGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius) { CompGlower Comp_NewGlower = new CompGlower(); Comp_NewGlower.parent = parent; CompProperties CompProp_New = new CompProperties(); CompProp_New.compClass = typeof(CompGlower); CompProp_New.glowColor = glowColour; CompProp_New.glowRadius = glowRadius; Comp_NewGlower.Initialize(CompProp_New); return Comp_NewGlower; }
private void Initialize() { bool spawned = base.Pawn.Spawned; if (spawned && base.Pawn.Map != null) { MoteMaker.ThrowLightningGlow(base.Pawn.TrueCenter(), base.Pawn.Map, 3f); this.glower = new CompGlower(); gProps.glowColor = glowColor; gProps.glowRadius = 7f; glower.parent = this.Pawn; glower.Initialize(gProps); comp = base.Pawn.GetComp <CompAbilityUserMagic>(); } }
private void Initialize() { bool spawned = base.Pawn.Spawned; if (spawned && base.Pawn.Map != null) { FleckMaker.ThrowLightningGlow(base.Pawn.TrueCenter(), base.Pawn.Map, 3f); this.glower = new CompGlower(); gProps.glowColor = glowColor; gProps.glowRadius = 7f; glower.parent = this.Pawn; glower.Initialize(gProps); comp = base.Pawn.GetComp <CompAbilityUserMagic>(); this.nextLightningTick = Find.TickManager.TicksGame + Rand.Range(400, 800); } }
//provides a new Compglower public static CompGlower newCompGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius) { CompGlower Comp_NewGlower = new CompGlower(); Comp_NewGlower.parent = parent; CompProperties CompProp_New = new CompProperties(); CompProp_New.compClass = typeof(CompGlower); CompProp_New.glowColor = glowColour; CompProp_New.glowRadius = glowRadius; Comp_NewGlower.Initialize(CompProp_New); return(Comp_NewGlower); }
private void Initialize() { if (pawn != null) { MoteMaker.MakeStaticMote(pawn.TrueCenter(), pawn.Map, ThingDefOf.Mote_ExplosionFlash, 1f); SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); MoteMaker.ThrowDustPuff(pawn.Position, pawn.Map, Rand.Range(1.2f, 1.8f)); UpdateSoLPower(); this.glower = new CompGlower(); gProps.glowColor = new ColorInt(255, 255, 180, 1); gProps.glowRadius = 14f; gProps.overlightRadius = 12f; glower.parent = this; glower.Initialize(gProps); this.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things); this.Map.glowGrid.DeRegisterGlower(glower); this.glowing = false; //this.shouldGlow = false; this.initialized = true; //Log.Message("initializing sol, glowing: " + glowing + " glow center: " + glowCenter); } }
private Building SpawnGlower(IntVec3 pos) { // Create the glower and assign it to this faction Building glower = ThingMaker.MakeThing(LocalDefOf.WIN_WindowGlower) as Building; glower.SetFactionDirect(Faction.OfPlayerSilentFail); // Spawn the glower GenSpawn.Spawn(glower, pos, Map); CompGlower glowComp = new CompGlower(); glowComp.Initialize(new CompProperties_Glower() { glowColor = new ColorInt(0, 0, 0, 0), glowRadius = 0f }); glowComp.parent = glower; glower.AllComps.Add(glowComp); Map.glowGrid.RegisterGlower(glowComp); return(glower); }
public void ChangeColor( int index ) { ColorInt colour = ColorProps.color[ index ].value; ColorIndex = index; GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc; var currentGlower = CompGlower; // Current lit state from existing glower bool wasLit = currentGlower.Lit; // Turn off glower currentGlower.Lit = false; // New glower var newGlower = new CompGlower(); if( newGlower == null ) { Log.Error( "Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompGlower!" ); return; } newGlower.parent = parent; // Glower properties var newProps = new CompProperties(); if( newProps == null ) { Log.Error( "Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompProperties!" ); return; } newProps.compClass = typeof( CompGlower ); newProps.glowColor = colour; newProps.glowRadius = lightRadius; // Add properties to glower newGlower.Initialize( newProps ); // Fetch the comps list var allComps = parent.GetComps(); if( allComps == null ) { Log.Error( "Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to get list of comps!" ); return; } // Remove existing glower allComps.Remove( currentGlower ); // Add new glower allComps.Add( newGlower ); // Store comps list parent.SetComps( allComps ); // Update glow grid newGlower.Lit = false; Find.GlowGrid.MarkGlowGridDirty( parent.Position ); Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.GroundGlow ); Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.Things ); // Turn light on if appropriate newGlower.Lit |= ( wasLit ) && ( PowerTrader.PowerOn ); }
public void changeColor( int index ) { ColorInt colour = compProps.color[ index ].value; ColorIndex = index; GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc; // Current lit state from base compGlower bool wasLit = oldGlower.Lit; // Turn off old glower oldGlower.Lit = false; // Turn off replaced glower if( compGlower != null ) { // Current lit state from base replacement compGlower wasLit = compGlower.Lit; // Turn off replacement compGlower compGlower.Lit = false; } // New glower CompGlower newGlower = new CompGlower(); if( newGlower == null ) { Log.Message( parent.def.defName + " - Unable to create new compGlower!" ); return; } newGlower.parent = parent; // Glower properties CompProperties newProps = new CompProperties(); if( newProps == null ) { Log.Message( parent.def.defName + " - Unable to create new compProperties!" ); return; } newProps.compClass = typeof( CompGlower ); newProps.glowColor = colour; newProps.glowRadius = lightRadius; // Add properties to glower newGlower.Initialize( newProps ); // Fetch the comps list List<ThingComp> allComps = typeof( ThingWithComps ).GetField( "comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).GetValue( parent ) as List<ThingComp>; if( allComps == null ) { Log.Message( parent.def.defName + " - Could not get list of comps!" ); return; } // Remove default glower allComps.Remove( oldGlower ); // Remove current glower if( compGlower != null ) { allComps.Remove( compGlower ); } // Add new glower allComps.Add( newGlower ); compGlower = newGlower; // Store comps list typeof( ThingWithComps ).GetField( "comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance ).SetValue( parent, allComps ); // Update glow grid compGlower.Lit = false; Find.GlowGrid.MarkGlowGridDirty( parent.Position ); Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.GroundGlow ); Find.MapDrawer.MapMeshDirty( parent.Position, MapMeshFlag.Things ); if( ( wasLit )&&( compPower.PowerOn ) ) { // Turn it on if it the old glower was on compGlower.Lit = true; } }
public void ChangeColor(int index) { ColorInt colour = ColorProps.color[index].value; ColorIndex = index; GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc; var currentGlower = CompGlower; // Current lit state from existing glower bool wasLit = currentGlower.Lit; // Turn off glower currentGlower.Lit = false; // New glower var newGlower = new CompGlower(); if (newGlower == null) { Log.Error("Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompGlower!"); return; } newGlower.parent = parent; // Glower properties var newProps = new CompProperties(); if (newProps == null) { Log.Error("Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to create new CompProperties!"); return; } newProps.compClass = typeof(CompGlower); newProps.glowColor = colour; newProps.glowRadius = lightRadius; // Add properties to glower newGlower.Initialize(newProps); // Fetch the comps list var allComps = parent.GetComps(); if (allComps == null) { Log.Error("Community Core Library :: CompColoredLight :: " + parent.def.defName + " unable to get list of comps!"); return; } // Remove existing glower allComps.Remove(currentGlower); // Add new glower allComps.Add(newGlower); // Store comps list parent.SetComps(allComps); // Update glow grid newGlower.Lit = false; Find.GlowGrid.MarkGlowGridDirty(parent.Position); Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.GroundGlow); Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.Things); // Turn light on if appropriate newGlower.Lit |= (wasLit) && (PowerTrader.PowerOn); }
public void changeColor(int index) { ColorInt colour = compProps.color[index].value; ColorIndex = index; GizmoChangeColor.defaultDesc = GizmoChangeColor.Desc; // Current lit state from base compGlower bool wasLit = oldGlower.Lit; // Turn off old glower oldGlower.Lit = false; // Turn off replaced glower if (compGlower != null) { // Current lit state from base replacement compGlower wasLit = compGlower.Lit; // Turn off replacement compGlower compGlower.Lit = false; } // New glower CompGlower newGlower = new CompGlower(); if (newGlower == null) { Log.Message(parent.def.defName + " - Unable to create new compGlower!"); return; } newGlower.parent = parent; // Glower properties CompProperties newProps = new CompProperties(); if (newProps == null) { Log.Message(parent.def.defName + " - Unable to create new compProperties!"); return; } newProps.compClass = typeof(CompGlower); newProps.glowColor = colour; newProps.glowRadius = lightRadius; // Add properties to glower newGlower.Initialize(newProps); // Fetch the comps list List <ThingComp> allComps = typeof(ThingWithComps).GetField("comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(parent) as List <ThingComp>; if (allComps == null) { Log.Message(parent.def.defName + " - Could not get list of comps!"); return; } // Remove default glower allComps.Remove(oldGlower); // Remove current glower if (compGlower != null) { allComps.Remove(compGlower); } // Add new glower allComps.Add(newGlower); compGlower = newGlower; // Store comps list typeof(ThingWithComps).GetField("comps", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(parent, allComps); // Update glow grid compGlower.Lit = false; Find.GlowGrid.MarkGlowGridDirty(parent.Position); Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.GroundGlow); Find.MapDrawer.MapMeshDirty(parent.Position, MapMeshFlag.Things); if ((wasLit) && (compPower.PowerOn)) { // Turn it on if it the old glower was on compGlower.Lit = true; } }