// 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);
            }
        }
Example #2
0
 public static void Prefix(string signal, CompGlower __instance)
 {
     // should react to gas on/off signals
     if (signal == CompGasTrader.Signal_GasOn || signal == CompGasTrader.Signal_GasOff)
     {
         __instance.UpdateLit(__instance.parent.Map);
     }
 }
Example #3
0
        //moved it to util for easier implementation with MAD
        public static void DestroyNCreateGlower(ThingWithComps parent, ColorInt glowColour, float glowRadius, Map map)
        {
            CompGlower      oldGlower = null;
            CompPowerTrader pwrTrader = null;

            List <ThingComp> list = parent.GetComps();

            foreach (ThingComp comp in list)
            {
                if (typeof(CompGlower) == comp.GetType())
                {
                    oldGlower = (CompGlower)comp;
                }
                if (typeof(CompPowerTrader) == comp.GetType())
                {
                    pwrTrader = (CompPowerTrader)comp;
                }
            }

            if (oldGlower != null)
            {
                //Boolean isLit = oldGlower.;
                //oldGlower.Lit = false;
                //parent.BroadcastCompSignal("FlickedOff");

                //oldGlower.PostDeSpawn();
                map.glowGrid.DeRegisterGlower(oldGlower);

                CompGlower newGlower = Util.newCompGlower(parent, glowColour, glowRadius);
                list.Remove(oldGlower);
                list.Add(newGlower);
                //Find.GlowGrid.RegisterGlower(newGlower);

                //(CompGlower)oldGlower.


                //replaced with an extention to thingWithComps... doesnt feel safe but hey
                //typeof(BuildingGlowTnC).GetField("comps", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(parent, List_AllThingComps);
                parent.SetComps(list);
                //parent.BroadcastCompSignal("FlickedOn");

                newGlower.UpdateLit(map);
                //newGlower.Lit = false;
                updateMap(parent.Position, map);


                //if (pwrTrader != null)
                //{
                //    if (isLit && pwrTrader.PowerOn)
                //    {
                //        newGlower.Lit = true;
                //    }
                //}
            }
        }
Example #4
0
        public override void CompTickRare()
        {
#if DEBUG
            Log.Message("CompTickRare() ShouldBeSwitchedOn=" + ShouldBeSwitchedOn + " CompFlickable.SwitchIsOn=" + this.CompFlickable.SwitchIsOn);
#endif
            if (ShouldBeSwitchedOn != CompFlickable.SwitchIsOn)
            {
                CompFlickable.SwitchIsOn = ShouldBeSwitchedOn;
                CompGlower.UpdateLit(this.parent.Map);
            }
        }
Example #5
0
        void ToggleGlower(bool turnItOn)
        {
            if (
                (IdleProps.operationalMode == LowIdleDrawMode.Cycle) &&
                (!turnItOn)
                )
            {
                // Cyclers don't toggle glowers, but let them turn it back on (old saves)
                return;
            }

            // Toggle and update glow grid
            var toggleableGlower = CompGlower as CompGlowerToggleable;

            if (toggleableGlower != null)
            {
                toggleableGlower.Lit = turnItOn;
            }
            CompGlower.UpdateLit();
        }