Skip to content

Commit 49e25cd

Browse files
authored
added hasgridtype condition (#180)
When using !cleanup delete hasownertype npc everything will be deleted that is npc owned, so stations and ships. This is not a good behavior as NPC stations that are protected by safezoned may not want to be deleted. You of course can remove them and use the shitty commands to remove the now empty safezones as well but players may want to expect a consistent location of these NPCs, as common points of interest. So with this new condition you can !cleanup delete hasownertype npc hasgridtype ship which will only remove npc ships and leave the stations. Similar to all other conditions a grid will only be deleted if all subgrids match this condition. So it works best for ships, as all subgrids of a ship usually are ships as well. However a station with a rotor head wont be removed by "static" condition as long as the rotor head is there. This could be changed in the future but personally I dont think its needed to build something inconsistent there.
1 parent abdb5c5 commit 49e25cd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎Essentials/Commands/CleanupModule.cs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,28 @@ public bool PCULessThan(MyCubeGrid grid, int pcu)
223223
return grid.BlocksPCU < pcu;
224224
}
225225

226+
[Condition("hasgridtype", helpText: "Finds grids with the specified grid type (large | small | ship | static).")]
227+
public bool HasGridType(MyCubeGrid grid, string gridType)
228+
{
229+
if (string.IsNullOrEmpty(gridType))
230+
return false;
231+
232+
if (string.Compare(gridType, "static", StringComparison.InvariantCultureIgnoreCase) == 0)
233+
return grid.IsStatic;
234+
235+
if (string.Compare(gridType, "ship", StringComparison.InvariantCultureIgnoreCase) == 0)
236+
return !grid.IsStatic;
237+
238+
if (string.Compare(gridType, "large", StringComparison.InvariantCultureIgnoreCase) == 0)
239+
return grid.GridSizeEnum == VRage.Game.MyCubeSize.Large;
240+
241+
if (string.Compare(gridType, "small", StringComparison.InvariantCultureIgnoreCase) == 0)
242+
return grid.GridSizeEnum == VRage.Game.MyCubeSize.Small;
243+
244+
// In all other cases, just return false.
245+
return false;
246+
}
247+
226248
[Condition("hasownertype", helpText: "Finds grids with the specified owner type (npc | player | nobody).")]
227249
public bool HasOwnerType(MyCubeGrid grid, string ownerType)
228250
{

0 commit comments

Comments
 (0)