|
- using System;
- using Svelto.ECS;
- using Techblox.Building.Rules;
- using Techblox.Building.Rules.Entities;
- using TechbloxModdingAPI.Engines;
- using TechbloxModdingAPI.Utility;
- using Unity.Mathematics;
-
- namespace BuildingTools
- {
- public class SetLimitsCommandEngine : IApiEngine
- {
- public void Ready()
- {
- }
-
- public EntitiesDB entitiesDB { get; set; }
- public void Dispose()
- {
- }
-
- public void SetLimits(int cpu, int power, int clusters)
- {
- if (entitiesDB is null)
- {
- Logging.CommandLog("This command only works in build mode. If you're in build mode, well, report pls.");
- return;
- }
-
- ref var rules = ref entitiesDB.QueryUniqueEntity<MachineRulesComponent>(GroupCompound<MACHINE, LOCAL>.BuildGroup);
- Logging.CommandLog($"Old CPU limit: {rules.cpu.max}, power limit: {rules.power.max}, cluster limit: {rules.clusters.max}");
- rules.cpu.max = cpu;
- rules.power.max = power;
- rules.clusters.max = clusters;
- if (BuildRulesUtils.GetLocalMachine(entitiesDB, out var egid))
- {
- entitiesDB.QueryEntity<MachineVolumeLimitAabbComponent>(egid).aabb =
- new AABB { Center = 0, Extents = float.MaxValue };
- Logging.CommandLog("Removed volume limits");
- }
-
- Logging.CommandLog($"New CPU limit: {rules.cpu.max}, power limit: {rules.power.max}, cluster limit: {rules.clusters.max}");
- }
-
- public string Name => "SetLimitsEngine";
- public bool isRemovable => true;
- }
- }
|