Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/StarCoreSE/TLB
Browse files Browse the repository at this point in the history
  • Loading branch information
xianson committed Jul 1, 2024
2 parents a8e0d8b + e85610f commit e3881f0
Show file tree
Hide file tree
Showing 2 changed files with 25 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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ public override void UpdateBeforeSimulation()
continue;
}

// Ignores grids that are probalby just trash or wheels
if (((MyCubeGrid)grid).BlocksCount <= 7)
{
RemoveGPS(grid.EntityId);
continue;
}

Vector3D gridLoc = grid.WorldAABB.Center;

if (grid.EntityId == CurrentData.EntityId
Expand Down

0 comments on commit e3881f0

Please sign in to comment.