From e85610f51615f9cdc9e35ebeb550de867f3f3f77 Mon Sep 17 00:00:00 2001 From: Gauge Date: Mon, 1 Jul 2024 11:17:57 -0700 Subject: [PATCH] simplified anntena ranges --- .../Data/Scripts/AlwaysOn/Core.cs | 55 ++++++------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/SkyPiratesAntennaAlwaysOn/Data/Scripts/AlwaysOn/Core.cs b/SkyPiratesAntennaAlwaysOn/Data/Scripts/AlwaysOn/Core.cs index fa49c31..761fa80 100644 --- a/SkyPiratesAntennaAlwaysOn/Data/Scripts/AlwaysOn/Core.cs +++ b/SkyPiratesAntennaAlwaysOn/Data/Scripts/AlwaysOn/Core.cs @@ -16,46 +16,11 @@ public class Core : MyGameLogicComponent public const float rangeLargeGrid = 100f; private IMyRadioAntenna beacon; - private bool waitframe = false; public override void Init(MyObjectBuilder_EntityBase objectBuilder) { - beacon = Entity as IMyRadioAntenna; - if (beacon.Radius < rangeSmallGrid) - beacon.Radius = rangeSmallGrid; - - NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME; - } - - - public override void UpdateOnceBeforeFrame() - { - if (waitframe) - { - waitframe = false; - NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME; - return; - } - - List controls; - MyAPIGateway.TerminalControls.GetControls(out controls); - - foreach (IMyTerminalControl control in controls) - { - if (control.Id == "Radius") - { - if (beacon.CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Small) - { - ((IMyTerminalControlSlider)control).SetLimits(rangeSmallGrid, 50000f); - } - else if (beacon.CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Large) - { - ((IMyTerminalControlSlider)control).SetLimits(rangeLargeGrid, 50000f); - } - - break; - } - } + beacon = Entity as IMyRadioAntenna; + NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME; } /// @@ -74,6 +39,22 @@ public override void UpdateBeforeSimulation100() { beacon.EnableBroadcasting = true; } + + if (beacon.CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Large) + { + if (beacon.Radius < rangeSmallGrid) + { + beacon.Radius = rangeSmallGrid; + } + } + else if (beacon.CubeGrid.GridSizeEnum == VRage.Game.MyCubeSize.Large) + { + if (beacon.Radius < rangeLargeGrid) + { + beacon.Radius = rangeLargeGrid; + } + } + } } }