public static void Force(this CompFlickable flickable, bool mode) { if (mode != flickable.SwitchIsOn) { flickable.SwitchIsOn = mode; } if (flickable.WantsFlick()) { _flickable_wantSwitchOn_FI.SetValue(flickable, mode); } }
private void CheckDesignateFlick() { if (!enabled || !parent.Spawned) { return; } if (GenDate.DaysPassed > this.currDaysPassed) { hasFlickedOnToday = false; hasFlickedOffToday = false; this.currDaysPassed = GenDate.DaysPassed; } bool?wantsFlickOn = null; if (!hasFlickedOnToday && GenLocalDate.DayPercent(this.parent.Map) > this.Props.flickOnPercent) { wantsFlickOn = true; hasFlickedOnToday = true; } if (!hasFlickedOffToday && GenLocalDate.DayPercent(this.parent.Map) > this.Props.flickOffPercent) { wantsFlickOn = false; hasFlickedOffToday = true; } if (wantsFlickOn == null) { return; } var curState = flickableComp.SwitchIsOn; if (flickableComp.WantsFlick()) { curState = !curState; } if (curState != wantsFlickOn) { var field = typeof(CompFlickable).GetField("wantSwitchOn", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField); field.SetValue(flickableComp, wantsFlickOn); FlickUtility.UpdateFlickDesignation(this.parent); } }