public void UpdateConsumerDraw(PowerConsumerComponent consumer, int oldDrawRate, int newDrawRate) { Debug.Assert(_consumersByPriority[consumer.Priority].Contains(consumer)); _drawByPriority[consumer.Priority] -= oldDrawRate; _drawByPriority[consumer.Priority] += newDrawRate; UpdateConsumerReceivedPower(); }
public void UpdateConsumerDraw(PowerConsumerComponent consumer, int oldDrawRate, int newDrawRate) { Debug.Assert(_consumersByPriority[consumer.Priority].Contains(consumer)); _drawByPriority[consumer.Priority] -= oldDrawRate; _drawByPriority[consumer.Priority] += newDrawRate; _powerNetManager.AddDirtyPowerNet(this); }
public void RemoveConsumer(PowerConsumerComponent consumer) { Debug.Assert(_consumersByPriority[consumer.Priority].Contains(consumer)); consumer.ReceivedPower = 0; _consumersByPriority[consumer.Priority].Remove(consumer); _drawByPriority[consumer.Priority] -= consumer.DrawRate; _powerNetManager.AddDirtyPowerNet(this); }
public void RemoveConsumer(PowerConsumerComponent consumer) { Debug.Assert(_consumersByPriority[consumer.Priority].Contains(consumer)); consumer.ReceivedPower = 0; _consumersByPriority[consumer.Priority].Remove(consumer); _drawByPriority[consumer.Priority] -= consumer.DrawRate; UpdateConsumerReceivedPower(); }
public void UpdateConsumerPriority(PowerConsumerComponent consumer, Priority oldPriority, Priority newPriority) { Debug.Assert(_consumersByPriority[oldPriority].Contains(consumer)); _consumersByPriority[oldPriority].Remove(consumer); _drawByPriority[oldPriority] -= consumer.DrawRate; _consumersByPriority[newPriority].Add(consumer); _drawByPriority[newPriority] += consumer.DrawRate; _powerNetManager.AddDirtyPowerNet(this); }
public void UpdateConsumerPriority(PowerConsumerComponent consumer, Priority oldPriority, Priority newPriority) { Debug.Assert(_consumersByPriority[oldPriority].Contains(consumer)); _consumersByPriority[oldPriority].Remove(consumer); _drawByPriority[oldPriority] -= consumer.DrawRate; _consumersByPriority[newPriority].Add(consumer); _drawByPriority[newPriority] += consumer.DrawRate; UpdateConsumerReceivedPower(); }
public static void PowerTickPrefix(ref PowerSystem __instance, ref PowerConsumerComponent[] __state) { __state = new PowerConsumerComponent[__instance.consumerPool.Length]; __instance.consumerPool.CopyTo(__state, 0); for (int i = 0; i < __instance.consumerPool.Length; i++) { __instance.consumerPool[i].idleEnergyPerTick = 0; __instance.consumerPool[i].workEnergyPerTick = 0; __instance.consumerPool[i].requiredEnergy = 0; } }
public async Task PowerNetTest() { var options = new ServerIntegrationOptions { ExtraPrototypes = Prototypes }; var server = StartServerDummyTicker(options); PowerSupplierComponent supplier = null; PowerConsumerComponent consumer1 = null; PowerConsumerComponent consumer2 = null; server.Assert(() => { var mapMan = IoCManager.Resolve <IMapManager>(); var entityMan = IoCManager.Resolve <IEntityManager>(); mapMan.CreateMap(new MapId(1)); var grid = mapMan.CreateGrid(new MapId(1)); var generatorEnt = entityMan.SpawnEntity("GeneratorDummy", grid.ToCoordinates()); var consumerEnt1 = entityMan.SpawnEntity("ConsumerDummy", grid.ToCoordinates(0, 1)); var consumerEnt2 = entityMan.SpawnEntity("ConsumerDummy", grid.ToCoordinates(0, 2)); if (generatorEnt.TryGetComponent(out AnchorableComponent anchorable)) { anchorable.TryAnchor(null, force: true); } Assert.That(generatorEnt.TryGetComponent(out supplier)); Assert.That(consumerEnt1.TryGetComponent(out consumer1)); Assert.That(consumerEnt2.TryGetComponent(out consumer2)); var supplyRate = 1000; //arbitrary amount of power supply supplier.SupplyRate = supplyRate; consumer1.DrawRate = supplyRate / 2; //arbitrary draw less than supply consumer2.DrawRate = supplyRate * 2; //arbitrary draw greater than supply consumer1.Priority = Priority.First; //power goes to this consumer first consumer2.Priority = Priority.Last; //any excess power should go to low priority consumer }); server.RunTicks(1); //let run a tick for PowerNet to process power server.Assert(() => { Assert.That(consumer1.DrawRate, Is.EqualTo(consumer1.ReceivedPower)); //first should be fully powered Assert.That(consumer2.ReceivedPower, Is.EqualTo(supplier.SupplyRate - consumer1.ReceivedPower)); //second should get remaining power }); await server.WaitIdleAsync(); }
public async Task PowerNetTest() { var server = StartServerDummyTicker(); PowerSupplierComponent supplier = null; PowerConsumerComponent consumer1 = null; PowerConsumerComponent consumer2 = null; server.Assert(() => { var mapMan = IoCManager.Resolve <IMapManager>(); var entityMan = IoCManager.Resolve <IEntityManager>(); mapMan.CreateMap(new MapId(1)); var grid = mapMan.CreateGrid(new MapId(1)); var generatorEnt = entityMan.SpawnEntity("DebugGenerator", new GridCoordinates(new Vector2(0, 0), grid.Index)); var consumerEnt1 = entityMan.SpawnEntity("DebugConsumer", new GridCoordinates(new Vector2(0, 1), grid.Index)); var consumerEnt2 = entityMan.SpawnEntity("DebugConsumer", new GridCoordinates(new Vector2(0, 2), grid.Index)); Assert.That(generatorEnt.TryGetComponent(out supplier)); Assert.That(consumerEnt1.TryGetComponent(out consumer1)); Assert.That(consumerEnt2.TryGetComponent(out consumer2)); var supplyRate = 1000; //arbitrary amount of power supply supplier.SupplyRate = supplyRate; consumer1.DrawRate = supplyRate / 2; //arbitrary draw less than supply consumer2.DrawRate = supplyRate * 2; //arbitrary draw greater than supply consumer1.Priority = Priority.First; //power goes to this consumer first consumer2.Priority = Priority.Last; //any excess power should go to low priority consumer }); server.RunTicks(1); //let run a tick for PowerNet to process power server.Assert(() => { Assert.That(consumer1.DrawRate, Is.EqualTo(consumer1.ReceivedPower)); //first should be fully powered Assert.That(consumer2.ReceivedPower, Is.EqualTo(supplier.SupplyRate - consumer1.ReceivedPower)); //second should get remaining power }); await server.WaitIdleAsync(); }
public static void FastDeleteEntities(PlanetFactory factory, List <int> targetIds, List <int> edgeIds) { Player player = GameMain.mainPlayer; using IDisposable toggle = UndoManager.IgnoreAllEvents.On(); FactorySystem factorySystem = factory.factorySystem; CargoTraffic cargoTraffic = factory.cargoTraffic; PowerSystem powerSystem = factory.powerSystem; // Close all the build tools, so we don't have to worry about BuildTool.buildPreview foreach (BuildTool buildTool in player.controller.actionBuild.tools) { if (!(buildTool is DragRemoveBuildTool)) { buildTool._Close(); } } powerConRemoval.Clear(); if (powerConRemoval.Capacity < powerSystem.netCursor) { powerConRemoval.Capacity = powerSystem.netCursor; } // Close inspect player.controller.actionInspect.InspectNothing(); for (int i = 0; i < powerSystem.netCursor; i++) { int maxConsumers = 10; if (powerSystem.netPool[i] != null) { maxConsumers = powerSystem.netPool[i].consumers.Count; } powerConRemoval.Add(new HashSet <int>(maxConsumers)); } foreach (int itemId in LDB.items.dataIndices.Keys) { takeBackCount[itemId] = 0; takeBackInc[itemId] = 0; } PowerConsumerComponent[] consumerPool = powerSystem.consumerPool; InserterComponent[] inserterPool = factorySystem.inserterPool; EntityData[] entityPool = factory.entityPool; void RemoveConsumerComponent(int id) { ref PowerConsumerComponent powerCon = ref consumerPool[id]; if (powerCon.id != 0) { if (powerCon.networkId >= powerConRemoval.Count) { //Debug.Log($"Power Net: {powerCon.networkId} is not in the list"); return; } if (powerConRemoval[powerCon.networkId].Contains(id)) { return; } powerConRemoval[powerCon.networkId].Add(id); powerCon.SetEmpty(); powerSystem.consumerRecycle[powerSystem.consumerRecycleCursor] = id; powerSystem.consumerRecycleCursor++; } }
public void AddConsumer(PowerConsumerComponent consumer) { _consumersByPriority[consumer.Priority].Add(consumer); _drawByPriority[consumer.Priority] += consumer.DrawRate; _powerNetManager.AddDirtyPowerNet(this); }
public void UpdateConsumerPriority(PowerConsumerComponent consumer, Priority oldPriority, Priority newPriority) { }
public void UpdateConsumerDraw(PowerConsumerComponent consumer, int oldDrawRate, int newDrawRate) { }
public void RemoveConsumer(PowerConsumerComponent consumer) { }
public void AddConsumer(PowerConsumerComponent consumer) { }
public void AddConsumer(PowerConsumerComponent consumer) { _consumersByPriority[consumer.Priority].Add(consumer); _drawByPriority[consumer.Priority] += consumer.DrawRate; UpdateConsumerReceivedPower(); }