From dc2232872dddbbe7fd068b3e74552b082b9ce09b Mon Sep 17 00:00:00 2001 From: Jim Burlison Date: Mon, 8 Jul 2019 19:45:32 -0400 Subject: [PATCH] Fixed schematic builders to not stop when it does not have a required item in the stockpile Fixed mana pipe not connecting to mana pump --- .../Items/Energy/ManaPump.cs | 19 +++++++++-------- .../Items/Energy/ManaTank.cs | 3 +-- .../Transportation/PropulsionPlatform.cs | 2 +- .../Items/Transportation/TrainStation.cs | 4 ++-- .../Jobs/Construction/SchematicBuilder.cs | 21 ++++++++++++------- .../Jobs/Roaming/RoamingJobState.cs | 9 ++++++-- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaPump.cs b/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaPump.cs index 9f662e9..71e77cd 100644 --- a/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaPump.cs +++ b/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaPump.cs @@ -192,16 +192,17 @@ public class ManaPumpGenerate : CSGenerateType ConnectedBlock = new ConnectedBlock() { BlockType = "ManaPipe", - Connections = new List() + AutoChange = false, + CalculationType = "Pipe", + Connections = new List() { - Models.BlockSide.Xn, - Models.BlockSide.Xp, - Models.BlockSide.Yn, - Models.BlockSide.Yp, - Models.BlockSide.Zn, - Models.BlockSide.Zp - }, - AutoChange = false + BlockSide.Xn, + BlockSide.Xp, + BlockSide.Zn, + BlockSide.Zp, + BlockSide.Yn, + BlockSide.Yp + } } }; } diff --git a/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaTank.cs b/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaTank.cs index 55e129b..07bf5fc 100644 --- a/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaTank.cs +++ b/Pandaros.Settlers/Pandaros.Settlers/Items/Energy/ManaTank.cs @@ -76,8 +76,7 @@ public class ManaTankObjective : IRoamingJobObjective public void DoWork(Colony colony, RoamingJobState state) { - if (!state.ActionEnergy.ContainsKey(GameLoader.NAMESPACE + ".ManaTankRefill")) - state.ActionEnergy.Add(GameLoader.NAMESPACE + ".ManaTankRefill", 0); + state.InitializeActionEnergy(GameLoader.NAMESPACE + ".ManaTankRefill", 0); if (state.NextTimeForWork < Time.SecondsSinceStartDouble) { diff --git a/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/PropulsionPlatform.cs b/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/PropulsionPlatform.cs index 01b7cec..42e2ebf 100644 --- a/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/PropulsionPlatform.cs +++ b/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/PropulsionPlatform.cs @@ -79,7 +79,7 @@ public class PropulsionPlatform : CSType TrainBounds = new SerializableVector3(3, 2, 3), IdealHeightFromTrack = 3, MoveTimePerBlockMs = 500, - ManaCostPerBlock = 0.005f + ManaCostPerBlock = 0.0001f }; } } diff --git a/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/TrainStation.cs b/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/TrainStation.cs index fdba6a2..ddb6820 100644 --- a/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/TrainStation.cs +++ b/Pandaros.Settlers/Pandaros.Settlers/Items/Transportation/TrainStation.cs @@ -54,8 +54,8 @@ public class TrainStationObjective : IRoamingJobObjective public void DoWork(Colony colony, RoamingJobState state) { - if (!state.ActionEnergy.ContainsKey(GameLoader.NAMESPACE + ".ManaTankRefill")) - state.ActionEnergy.Add(GameLoader.NAMESPACE + ".ManaTankRefill", 0); + state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaTankRefill"); + state.GetActionEnergy(GameLoader.NAMESPACE + ".ManaMachineRepair"); } } diff --git a/Pandaros.Settlers/Pandaros.Settlers/Jobs/Construction/SchematicBuilder.cs b/Pandaros.Settlers/Pandaros.Settlers/Jobs/Construction/SchematicBuilder.cs index c86df67..cbdf999 100644 --- a/Pandaros.Settlers/Pandaros.Settlers/Jobs/Construction/SchematicBuilder.cs +++ b/Pandaros.Settlers/Pandaros.Settlers/Jobs/Construction/SchematicBuilder.cs @@ -84,14 +84,14 @@ public void DoJob(IIterationType iterationType, IAreaJob areaJob, ConstructionJo if (!ok && ownerStockPile.Contains(buildType.ItemIndex)) ok = true; - if (!ok && !string.IsNullOrWhiteSpace(buildType.ParentType)) + if (!ok && !string.IsNullOrWhiteSpace(buildType.ParentType) && !buildType.ParentType.Contains("grass") && !buildType.ParentType.Contains("leaves")) { - var parentType = ItemTypes.GetType(buildType.ParentType); + var parentType = ItemTypes.GetType(buildType.ParentType); + buildType = parentType; if (ownerStockPile.Contains(parentType.ItemIndex)) { ok = true; - buildType = parentType; } } @@ -128,6 +128,16 @@ public void DoJob(IIterationType iterationType, IAreaJob areaJob, ConstructionJo return; } } + else + { + if (!areaJob.Owner.Stockpile.Contains(buildType.ItemIndex) && buildType.ItemIndex != ColonyBuiltIn.ItemTypes.AIR.Id) + state.SetIndicator(new Shared.IndicatorState(5f, buildType.Name, true, false)); + + if (buildType.ItemIndex == ColonyBuiltIn.ItemTypes.AIR.Id) + continue; + else + return; + } } else { @@ -135,10 +145,7 @@ public void DoJob(IIterationType iterationType, IAreaJob areaJob, ConstructionJo _needsChunkLoaded.Add(bpi); ChunkQueue.QueuePlayerSurrounding(iterationType.CurrentPosition); - - if (areaJob.Owner.Stockpile.Contains(buildType.ItemIndex) && buildType.ItemIndex != ColonyBuiltIn.ItemTypes.AIR.Id) - state.SetIndicator(new Shared.IndicatorState(5f, buildType.Name)); - + state.SetIndicator(new Shared.IndicatorState(5f, ColonyBuiltIn.ItemTypes.ERRORIDLE.Name)); return; } diff --git a/Pandaros.Settlers/Pandaros.Settlers/Jobs/Roaming/RoamingJobState.cs b/Pandaros.Settlers/Pandaros.Settlers/Jobs/Roaming/RoamingJobState.cs index bee7b32..c13609b 100644 --- a/Pandaros.Settlers/Pandaros.Settlers/Jobs/Roaming/RoamingJobState.cs +++ b/Pandaros.Settlers/Pandaros.Settlers/Jobs/Roaming/RoamingJobState.cs @@ -75,14 +75,19 @@ public void ResetActionToMaxLoad(string action) SetActionEnergy(action, GetActionsMaxEnergy(action, Colony, RoamingJobSettings.ObjectiveCategory)); } - public float GetActionEnergy(string action) + public float InitializeActionEnergy(string action, float valueIfNotInitialized) { if (!ActionEnergy.ContainsKey(action)) - ActionEnergy.Add(action, GetActionsMaxEnergy(action, Colony, RoamingJobSettings.ObjectiveCategory)); + ActionEnergy.Add(action, valueIfNotInitialized); return ActionEnergy[action]; } + public float GetActionEnergy(string action) + { + return InitializeActionEnergy(action, GetActionsMaxEnergy(action, Colony, RoamingJobSettings.ObjectiveCategory)); + } + public void SetActionEnergy(string action, float value) { ActionEnergy[action] = value;