public override void CompTick() { //base.CompTick(); bool every5Sec = (Find.TickManager.TicksGame % CheckEvery5Second == 0); if (stoneComp != null && !stoneComp.SwitchIsOn) { return; } // regular consumption if (!this.Props.consumeFuelOnlyWhenUsed) { this.ConsumeFuel(this.ConsumptionRatePerTick); } // additionnal rain consumption if (this.Props.fuelConsumptionPerTickInRain > 0f && this.parent.Spawned && this.parent.Map.weatherManager.RainRate > 0.4f && !this.parent.Map.roofGrid.Roofed(this.parent.Position)) { this.ConsumeFuel(this.Props.fuelConsumptionPerTickInRain); } // if on if (stoneComp.SwitchIsOn) { // no more fuel, extinguishing if (Fuel <= 0) { stoneComp.DoFlick(false); stoneComp.ResetToOff(); } if (every5Sec) { // raining, chances to extinguish if (RollForRainFire()) { return; } if (LaniusMod) { Room room = this.parent.GetRoom(); float breathablility = this.parent.Map.GetComponent <RoomBreathabilityManager>().RoomBreathability(room); if (breathablility < 50f) { stoneComp.DoFlick(false); stoneComp.ResetToOff(); } } } } }
protected override IEnumerable <Toil> MakeNewToils() { //Tools.Warn("make new toil", true); this.FailOnDespawnedOrNull(TargetIndex.A); this.FailOn(delegate { CompExtinguishable compExtinguishable = null; compExtinguishable = job.targetA.Thing.TryGetComp <CompExtinguishable>(); return(!(compExtinguishable != null && compExtinguishable.WantsFlick())); }); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch)); yield return(Toils_General.Wait(15).FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch)); Toil finalize = new Toil(); finalize.initAction = delegate { Pawn actor = finalize.actor; ThingWithComps thingWithComps = (ThingWithComps)actor.CurJob.targetA.Thing; for (int i = 0; i < thingWithComps.AllComps.Count; i++) { //Tools.Warn("Found "+i+" comp",true); if (thingWithComps.AllComps[i] is CompExtinguishable compExtinguishable && compExtinguishable.WantsFlick()) { //Tools.Warn("found extinguish", true); compExtinguishable.DoFlick(); } } }; finalize.defaultCompleteMode = ToilCompleteMode.Instant; yield return(finalize); }
public override void CompTick() { //base.CompTick(); //Log.Warning("0", true); if (extinguishableComp == null) { Log.Warning("Cant find extinguishableComp: " + parent.Label); return; } //Log.Warning("1", true); if (!extinguishableComp.SwitchIsOn) { return; } //Log.Warning("2", true); // regular consumption if (!Props.consumeFuelOnlyWhenUsed) { ConsumeFuel(ConsumptionRatePerTick); } // additionnal rain consumption if (Props.fuelConsumptionPerTickInRain > 0f && parent.Spawned && RainThreshold && UnroofedBuilding) { ConsumeFuel(Props.fuelConsumptionPerTickInRain); } // Trying to extinguish bc rain / lanius // no more fuel, extinguishing if (Fuel <= 0) { parent.BroadcastCompSignal(RanOutOfFuelSignal); extinguishableComp.DoFlick(false); extinguishableComp.ResetToOff(); } UpdateGlowStatus(); //Log.Warning("6", true); //Log.Warning("every1sec", true); if (!extinguishableComp.RainVulnerable && !extinguishableComp.OxygenVulnerable) { return; } if (!parent.IsHashIntervalTick(300)) { return; } //Log.Warning("7", true); //if(MyDebug) Log.Warning("every5sec"); // raining, chances to extinguish if (extinguishableComp.RainVulnerable) { RollForRainFire(); } //Log.Warning("8", true); // lanius mod active, checking oxygen ratio if (extinguishableComp.OxygenVulnerable) { if (LaniusMod) { Room room = parent.GetRoom(); if (room.PsychologicallyOutdoors) { return; } float breathablility = parent.Map.GetComponent <RoomBreathabilityManager>().RoomBreathability(room); if (breathablility < 50f) { extinguishableComp.DoFlick(false); extinguishableComp.ResetToOff(); } } } }