From 100dc130cf7c18f1ad55fcd34db5715d4e4e714f Mon Sep 17 00:00:00 2001 From: PowerfulBacon <> Date: Sun, 20 Mar 2022 19:54:17 +0000 Subject: [PATCH 1/3] Delete AreaPowerController.cs --- .../Structures/Power/AreaPowerController.cs | 128 ------------------ 1 file changed, 128 deletions(-) delete mode 100644 GJ2022/Entities/Structures/Power/AreaPowerController.cs diff --git a/GJ2022/Entities/Structures/Power/AreaPowerController.cs b/GJ2022/Entities/Structures/Power/AreaPowerController.cs deleted file mode 100644 index 5438510..0000000 --- a/GJ2022/Entities/Structures/Power/AreaPowerController.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using GJ2022.Components; -using GJ2022.Entities.ComponentInterfaces; -using GJ2022.EntityLoading; -using GJ2022.Game; -using GJ2022.Game.GameWorld; -using GJ2022.Game.Power; -using GJ2022.Rendering.RenderSystems.Renderables; -using GJ2022.Rendering.Text; -using GJ2022.Subsystems.Processing; -using GJ2022.Utility.MathConstructs; - -namespace GJ2022.Entities.Structures.Power -{ - public class AreaPowerController : Structure, IPowerGridConnected, IProcessable - { - - //The cell inside this APC - private Entity insertedCell; - - public AreaPowerController(Vector position, Directions direction) : base(position, Layers.LAYER_STRUCTURE) - { - float offsetAmount = 0.7f; - switch (direction) - { - case Directions.EAST: - offset = new Vector(offsetAmount, 0); - break; - case Directions.WEST: - offset = new Vector(-offsetAmount, 0); - break; - case Directions.NORTH: - offset = new Vector(0, offsetAmount); - break; - case Directions.SOUTH: - offset = new Vector(0, -offsetAmount); - break; - } - World.AddAreaPowerController((int)position.X, (int)position.Y, this); - World.AddPowernetInteractor((int)position.X, (int)position.Y, PowernetInteractor); - Position += offset; - //TODO: Move this to a definition file - insertedCell = EntityCreator.CreateEntity("Cell_Standard", position); - insertedCell.Location = this; - textObjectOffset = new Vector(0, -0.3f); - attachedTextObject = new TextObject($"{insertedCell?.SendSignalSynchronously(Signal.SIGNAL_GET_STORED_POWER)}", Colour.White, Position + textObjectOffset, TextObject.PositionModes.WORLD_POSITION, 0.4f); - UpdateOverlays(0); - PowerProcessingSystem.Singleton.StartProcessing(this); - } - - //Display offset, will screw up the positional checks of this - private Vector offset; - - //Set up the renderable - public override Renderable Renderable { get; set; } = new StandardRenderable("power.apc0"); - - //Create the powernet interactor - public PowernetInteractor PowernetInteractor { get; } = new PowernetInteractor(); - - public override bool Destroy() - { - Position -= offset; - World.RemoveAreaPowerController((int)Position.X, (int)Position.Y, this); - World.RemovePowernetInteractor((int)Position.X, (int)Position.Y, PowernetInteractor); - PowerProcessingSystem.Singleton.StopProcessing(this); - return base.Destroy(); - } - - int overlayState = 0; - - public void UpdateOverlays(float chargeRate) - { - attachedTextObject.Text = $"{insertedCell?.SendSignalSynchronously(Signal.SIGNAL_GET_STORED_POWER)}"; - int newOverlayState; - bool maxCharge = Convert.ToSingle(insertedCell.SendSignalSynchronously(Signal.SIGNAL_GET_POWER_DEMAND, 1)) == 0; - if (PowernetInteractor.AttachedPowernet == null || insertedCell == null || (chargeRate <= 0 && !maxCharge)) - newOverlayState = 1; - else if (maxCharge) - newOverlayState = 2; - else - newOverlayState = 3; - if (newOverlayState == overlayState) - return; - overlayState = newOverlayState; - Renderable.ClearOverlays(); - switch (overlayState) - { - case 1: - Renderable.AddOverlay("power", new StandardRenderable("power.apco3-0"), Layers.LAYER_STRUCTURE + 0.01f); - break; - case 2: - Renderable.AddOverlay("power", new StandardRenderable("power.apco3-2"), Layers.LAYER_STRUCTURE + 0.01f); - break; - case 3: - Renderable.AddOverlay("power", new StandardRenderable("power.apco3-1"), Layers.LAYER_STRUCTURE + 0.01f); - break; - } - } - - public void Process(float deltaTime) - { - //Check if we are attached to a powernet - if (PowernetInteractor.AttachedPowernet == null) - { - UpdateOverlays(0); - return; - } - //Check we actually contain a cell - if (insertedCell == null) - { - UpdateOverlays(0); - PowernetInteractor.Demand = 0; - return; - } - //Charge our cell if we can - float powerDemand = Convert.ToSingle(insertedCell.SendSignalSynchronously(Signal.SIGNAL_GET_POWER_DEMAND, deltaTime)); - PowernetInteractor.Demand = powerDemand; - float powerDelta = PowernetInteractor.AttachedPowernet.ReceievePower(powerDemand); - insertedCell.SendSignal(Signal.SIGNAL_ITEM_GIVE_POWER, powerDelta); - UpdateOverlays(powerDelta); - } - - } -} From 420904d8a15ccf8feaa22e6a246ad05e1b84c7e6 Mon Sep 17 00:00:00 2001 From: PowerfulBacon <> Date: Sun, 20 Mar 2022 19:56:26 +0000 Subject: [PATCH 2/3] Removes APC references in the world --- GJ2022/Game/GameWorld/World.cs | 38 ---------------------------------- 1 file changed, 38 deletions(-) diff --git a/GJ2022/Game/GameWorld/World.cs b/GJ2022/Game/GameWorld/World.cs index c686b2e..98fe117 100644 --- a/GJ2022/Game/GameWorld/World.cs +++ b/GJ2022/Game/GameWorld/World.cs @@ -70,9 +70,6 @@ public IntegerReference(int value) //Dictionary containing all mobs in the world public static PositionBasedBinaryList> WorldPawns = new PositionBasedBinaryList>(); - //Dictionary containing all mobs in the world - public static PositionBasedBinaryList> AreaPowerControllers = new PositionBasedBinaryList>(); - //An integer storing the amount of atmospheric blocking things at this location private static PositionBasedBinaryList AtmosphericBlockers = new PositionBasedBinaryList(); @@ -316,41 +313,6 @@ public static bool RemoveThing(string thingGroup, int x, int y, IComponentHandle return true; } - //====================== - // APCs - //====================== - - public static List GetAreaPowerControllers(int x, int y) - { - return AreaPowerControllers.Get(x, y) ?? new List() { }; - } - - /// - /// Add an pawn to the world list - /// - public static void AddAreaPowerController(int x, int y, AreaPowerController apc) - { - List located = AreaPowerControllers.Get(x, y); - if (located != null) - located.Add(apc); - else - AreaPowerControllers.Add(x, y, new List() { apc }); - } - - /// - /// Remove the pawn from the world list - /// - public static bool RemoveAreaPowerController(int x, int y, AreaPowerController apc) - { - List located = AreaPowerControllers.Get(x, y); - if (located == null) - return false; - located.Remove(apc); - if (located.Count == 0) - AreaPowerControllers.Remove(x, y); - return true; - } - //====================== // Pawns //====================== From 27ce23b57bfc43bf255c266f019308b0733ea01c Mon Sep 17 00:00:00 2001 From: PowerfulBacon <> Date: Sun, 20 Mar 2022 19:58:53 +0000 Subject: [PATCH 3/3] Update BlueprintData.json --- .../Data/ConstructionData/BlueprintData.json | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/GJ2022/Data/ConstructionData/BlueprintData.json b/GJ2022/Data/ConstructionData/BlueprintData.json index 6c3a2a2..6f09923 100644 --- a/GJ2022/Data/ConstructionData/BlueprintData.json +++ b/GJ2022/Data/ConstructionData/BlueprintData.json @@ -43,8 +43,7 @@ "canister_debug", "canister_debug_h2", "fire", - "heavy_conduit_instant", - "apc_instant" + "heavy_conduit_instant" ] } ], @@ -195,13 +194,6 @@ "isRoom": true, "edge": "heavy_conduit_instant", "fill": "heavy_conduit_instant" - }, - { - "id": "apc_instant", - "name": "Spawn APC", - "isRoom": false, - "edge": "apc_instant", - "fill": "apc_instant" } ], "blueprints": [ @@ -409,15 +401,6 @@ "texture": "power_cond_heavy.1-2-4-8", "layer": 5, "instant": true - }, - { - "id": "apc_instant", - "created_type": "AreaPowerController", - "priority": 1, - "blueprintType": "BlueprintDirectional", - "texture": "power.apc0", - "layer": 5, - "instant": true } ] }