Skip to content

Commit

Permalink
simplified anntena ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauge committed Jul 1, 2024
1 parent b4de9cd commit e85610f
Showing 1 changed file with 18 additions and 37 deletions.
55 changes: 18 additions & 37 deletions SkyPiratesAntennaAlwaysOn/Data/Scripts/AlwaysOn/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IMyTerminalControl> controls;
MyAPIGateway.TerminalControls.GetControls<IMyRadioAntenna>(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;
}

/// <summary>
Expand All @@ -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;
}
}

}
}
}
Expand Down

0 comments on commit e85610f

Please sign in to comment.