コード例 #1
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            this.compPowerTrader = this.GetComp <CompPowerTrader>();
            this.compSchedule    = this.GetComp <CompSchedule>();

            this.ResetPowerOutput();
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: dougbenham/all-day-growing
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }