From 492da33c6a48e79f99e0c41f7fc493fcc072739c Mon Sep 17 00:00:00 2001 From: KylianB Date: Sat, 29 Oct 2022 17:44:25 +0200 Subject: [PATCH] sprinkler fix --- 1.4/Assemblies/VFEF.dll | Bin 15360 -> 15360 bytes Source/VFEF/CompSprinkler.cs | 27 ++++++++++------ Source/VFEF/VFEF_SprinklersManager.cs | 43 ++++++++++++-------------- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/1.4/Assemblies/VFEF.dll b/1.4/Assemblies/VFEF.dll index b05c16ca4f0a170f17ab6797a6842f0de5494a8c..527ed2888a5c6d64649e929b8ede18b82ca3565f 100644 GIT binary patch delta 5692 zcmZ8l3v^WFwch`K&YV}yOfoa%1px-bV@yJTgjNu}5{QqW5km+<3u=l$fs_FQTwoZ^ zj0z>Fh4d6F2uq`|TxhXkYF%k-7gVHJ+bYU(-BjTQ#rEpbMJd!`3*mnIpP^OH%6w

pRDok7aK~~ z&meW(0+bY>(^W)O!-<5yV*EA!9de^pL1c`OsiEB`q^EoToi&HC7Ox?4NXld_?ukKw zR3VWrlp0#sk3vY{to*ay{f~GN#3Ld0XFF}43a0Fh#4;$dlao-PjN;jj zkqwqu4oSbBXO4aYJz=Lfx?h=H1k7e@)u>hw<*V)_zYCZ6eSpFJ!Z9Y6L6e=5ydrnP z=W0Mnk1MrQ=AfNWOAK-Ks2^H84bNd?baT|kF!Hc7I*sjVW88+i1IX1?K{zQ#1I>hl4>tNrnN1d=U`Vp!u%+?ys z3+G`)+KC}qAF_&PW0k0eb5A{Xal`Jl=lU;SCSKZ-u!RWY3~Q^f_RzVi5}D*FHj<-} zBAEmv)&nr&iX}3h0*TF)DuaoPZvdA%Pd6^g{PJL>$2Mxw4+X&!Y$UKEofM+za_A+MqVhT{02U;$jhz%$tIpem? z52_LOZ4$IRj)YDeqjgegC4By?!VC*H+|PO}3pkyGzBv9M3pTPqs*L>xrqgKO^j|Fh z{+H!Az>N0IEbd@X<15LH@8keks7NYuPFgZv>2C>Ds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9TW%q*s?6!)KQKa$DTlBxNMcfcoM@= zP-Z)5j^lWuQaEbDnJq8|N#{_RUC0c6Fx%i>Gc=msi8(;U?=7Ls&fE|Ox>h%F+2gE- z$tu7~ah;WFi7Kg3=~#sGhEmfntx&ndpM??+I?!pH_on6Pn#RJ2OsK-e*8__f^nW@!XGriMy6_6m-XLZ&Q!8VOTC8CM%H zt`pMCe=~6d2Z&iO-81XvVCm(@)=9(mVi+?*N$xGfMn$k7ykfi$(dU#yIHbEB>O%N%cL!QKv=sQ1kx*?GYJX diff --git a/Source/VFEF/CompSprinkler.cs b/Source/VFEF/CompSprinkler.cs index 26eeb96..39cd6cb 100644 --- a/Source/VFEF/CompSprinkler.cs +++ b/Source/VFEF/CompSprinkler.cs @@ -1,7 +1,7 @@ -using RimWorld; -using System.Collections.Generic; -using Verse; +using System.Collections.Generic; using System.Linq; +using RimWorld; +using Verse; namespace VFEF { @@ -25,28 +25,35 @@ public CompProperties_Sprinkler Props public List affectCells = new List(); + public Map map; + public CompPowerTrader compPowerTrader; + public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); - parent.Map.GetComponent().Register(this); - LastSprinkledMotesTick = (long)(GenTicks.TicksAbs - 60000); - affectCells.AddRange(parent.Map.AllCells.Where(cell => parent.Position.DistanceTo(cell) < Props.effectRadius)); + map = parent.Map; + + LastSprinkledMotesTick = GenTicks.TicksAbs - 60000; + affectCells = GenRadial.RadialCellsAround(parent.Position, Props.effectRadius, true).ToList(); + + map.GetComponent().Register(this); + compPowerTrader = parent.GetComp(); } public override void PostDeSpawn(Map map) { base.PostDeSpawn(map); - map.GetComponent().Deregister(this); affectCells.Clear(); + map.GetComponent().Deregister(this); } public void StartSprinklingMotes() { curRot = 0f; CurrentlySprinklingMotes = true; - MoteSprinkleEndTick = (long)(GenTicks.TicksAbs + Props.sprinkleDurationTicks); + MoteSprinkleEndTick = GenTicks.TicksAbs + Props.sprinkleDurationTicks; SprinkleMotes(); - LastSprinkledMotesTick = (long)GenTicks.TicksAbs; + LastSprinkledMotesTick = GenTicks.TicksAbs; } public void SprinkleMotes() @@ -57,7 +64,7 @@ public void SprinkleMotes() } if (GenTicks.TicksAbs % Props.moteMod == 0) { - MoteSprinkler.ThrowWaterSpray(parent.TrueCenter(), parent.Map, curRot, Props.moteThingDef); + MoteSprinkler.ThrowWaterSpray(parent.TrueCenter(), map, curRot, Props.moteThingDef); } curRot += Props.degreesPerTick; } diff --git a/Source/VFEF/VFEF_SprinklersManager.cs b/Source/VFEF/VFEF_SprinklersManager.cs index 65e9c4a..a22c433 100644 --- a/Source/VFEF/VFEF_SprinklersManager.cs +++ b/Source/VFEF/VFEF_SprinklersManager.cs @@ -34,8 +34,7 @@ public void Deregister(CompSprinkler c) private void BoostPlantAt(IntVec3 cell) { - Plant _plant = cell.GetPlant(map); - if (_plant != null && !_plant.def.plant.IsTree) // No tree growth boost + if (cell.GetPlant(map) is Plant _plant && !_plant.def.plant.IsTree) // No tree growth boost { _plant.Growth += 0.04f; } @@ -54,33 +53,29 @@ public override void MapComponentTick() { if (GenLocalDate.HourOfDay(map) == 7) { - for (int i = 0; i < comps.Count; i++) + var ticksAbs = GenTicks.TicksAbs; + for (int c = 0; c < comps.Count; c++) { - CompSprinkler _sprinkler = comps[i]; - if (_sprinkler.parent.GetComp().PowerOn && !_sprinkler.CurrentlySprinklingMotes && GenTicks.TicksAbs - _sprinkler.LastSprinkledMotesTick >= 57500L) + CompSprinkler _sprinkler = comps[c]; + if (_sprinkler.Props.shouldSprinkleMotes) { - if (_sprinkler.Props.shouldSprinkleMotes) + if (_sprinkler.compPowerTrader.PowerOn && !_sprinkler.CurrentlySprinklingMotes && ticksAbs - _sprinkler.LastSprinkledMotesTick >= 57500L) { _sprinkler.StartSprinklingMotes(); + for (int i = 0; i < affectedCells.Count; i++) + { + var cell = affectedCells[i]; + var list = map.thingGrid.ThingsListAt(cell); + if (list.Count == 0 || !list.Any(b => b is Building building && exception.Contains(building.def.defName))) + { + BoostPlantAt(cell); + } + } + } + else if (_sprinkler.CurrentlySprinklingMotes) + { + _sprinkler.SprinkleMotes(); } - } - else if (_sprinkler.Props.shouldSprinkleMotes && _sprinkler.CurrentlySprinklingMotes) - { - _sprinkler.SprinkleMotes(); - } - } - - for (int i = 0; i < affectedCells.Count; i++) - { - IntVec3 cell = affectedCells[i]; - List list = map.thingGrid.ThingsListAt(cell); - if (list.Count == 0) - { - BoostPlantAt(cell); - } - else if (!list.FindAll(b => b is Building building && building != null && building.def.altitudeLayer != AltitudeLayer.Conduits && !exception.Contains(building.def.defName)).Any()) - { - BoostPlantAt(cell); } } }