public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); this.compPowerTrader = this.GetComp <CompPowerTrader>(); this.compSchedule = this.GetComp <CompSchedule>(); this.ResetPowerOutput(); }
public static bool RecalculateAllowed(ref CompSchedule __instance) { var comp = __instance.parent.GetComp <CompGlower>(); if (comp != null && comp.Props.overlightRadius > 0) { __instance.Allowed = true; return(false); } return(true); }
public static bool WantsToBeOn(Thing t) { CompExtinguishable compExtinguishable = t.TryGetComp <CompExtinguishable>(); if (compExtinguishable != null && !compExtinguishable.SwitchIsOn) { return(false); } CompSchedule compSchedule = t.TryGetComp <CompSchedule>(); return(compSchedule == null || compSchedule.Allowed); }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); flickable = parent.GetComp <CompFlickable>(); breakdownable = parent.GetComp <CompBreakdownable>(); schedule = parent.GetComp <CompSchedule>(); // set flickable to false, to avoid immediately flooding the area with // deadly toxins. if (!respawningAfterLoad && flickable != null) { flickable.SwitchIsOn = false; } // get ventPos ventPos = GenGas.VentingPosition(parent); }
private float GetScheduledPowerDelta(CompSchedule scheduleComp) { CompFlickable compFlickable = scheduleComp.parent.TryGetComp <CompFlickable>(); if (compFlickable == null || compFlickable.SwitchIsOn) { if (!scheduleComp.parent.IsBrokenDown()) { CompPowerTrader cpt = scheduleComp.parent.GetComp <CompPowerTrader>(); float powerOutput = cpt.PowerOn ? cpt.PowerOutput : 0.0f; if (scheduleComp.Props.startTime <= scheduleComp.Props.endTime) { return((scheduleComp.Props.endTime - scheduleComp.Props.startTime) * cpt.Props.basePowerConsumption + powerOutput); } else { return((1.0f - scheduleComp.Props.startTime + scheduleComp.Props.endTime) * cpt.Props.basePowerConsumption + powerOutput); } } } return(0.0f); }