Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Essentials/Conditions/ConditionsImplementations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,22 @@ public static bool PlayerDistanceLessThan(MyCubeGrid grid, double dist)
return false;
}

[Condition("poweredgriddistancegreaterthan", "Finds grids that are farther than the given distance from other grids that are powered.")]
public static bool PoweredGridDistanceGreaterThan(MyCubeGrid grid, double dist)
{
// Returns 'true' if the count of matched grids from a list of all grids is zero for these conditions:
// the distance from grid to entity is less than dist
// the grid is powered
// Otherwise, returns 'false'
dist *= dist;
return MyEntities.GetEntities().Where(
x =>
(VRageMath.Vector3.DistanceSquared(x.PositionComp.GetPosition(), grid.PositionComp.GetPosition()) < dist
&& (x.GetType() == typeof(MyCubeGrid))
)).Cast<MyCubeGrid>().Where(y => !y.EntityId.Equals(grid.EntityId) && y.IsPowered)
.Count() == 0;
}

[Condition("centerdistancelessthan", "centerdistancegreaterthan", "Finds grids that are further than the given distance from center.")]
public static bool CenterDistanceLessThan(MyCubeGrid grid, double dist)
{
Expand Down