protected static bool AttemptDespawn(IMyCubeGrid grid) { if (!grid.IsControlledByNpcFaction()) { return(true); // If we are not GCorp don't try to despawn, we may be wreckage or player hijacked } if (!DuckUtils.IsAnyPlayerNearPosition(grid.GetPosition(), 1750)) { grid.CloseAll(); return(true); } return(false); }
protected static bool AttemptDespawn(IMyCubeGrid grid, Int32 minplayerdistance = 1750) { if (!grid.IsControlledByFaction("GCORP")) { return(true); // If we are not GCorp don't try to despawn, we may be wreckage or player hijacked } // if player is 'near' base, then disabled drones near the base won't be despawned // if (!DuckUtils.IsAnyPlayerNearPosition(grid.GetPosition(), 1750)) // V26 if (!DuckUtils.IsAnyPlayerNearPosition(grid.GetPosition(), minplayerdistance)) { grid.CloseAll(); return(true); } return(false); }
private void OfferPotentialNpcShip(IMyCubeGrid grid) { // ModLog.Info("Potentential NPC:" + grid.CustomName); NpcGroupSaveData npcGroupSaveData; if (restoredNpcGroupData.TryGetValue(grid.EntityId, out npcGroupSaveData)) { // ModLog.Info(" Potentential NPC: Found in restored NPC Group data:" + npcGroupSaveData.NpcGroupType.ToString() + " Type="+ npcGroupSaveData.LeaderUnitType.ToString()); if (npcGroupSaveData.NpcGroupType == NpcGroupType.Backup) { npcGroups.Add(new BackupGroup(npcGroupSaveData.State, npcGroupSaveData.GroupDestination, grid, heatSystem, audioSystem, DateTime.FromBinary(npcGroupSaveData.SpawnTime))); } else // Must be convoy { if (modBuildWhenLastSaved > 30 || !bInitialInit) { restoredConvoys.Add(grid.EntityId, RegisterConvoy(grid, npcGroupSaveData.State, npcGroupSaveData.LeaderUnitType, npcGroupSaveData.GroupDestination, DateTime.FromBinary(npcGroupSaveData.SpawnTime))); } else { // else old drones with scripts that don't work on 1.193.100 if (grid.IsControlledByFaction("GCORP")) // see npcgroup.AttemptDespawn() { ModLog.Info("save build#:" + modBuildWhenLastSaved.ToString() + " Initial=" + bInitialInit.ToString()); ModLog.Info("Removing dead drone Grid:" + grid.CustomName); bOldRemovals = true; grid.CloseAll(); } } } } else { // ModLog.Info(" Potentential NPC: NOT in restored NPC Group data:" + grid.CustomName); if (modBuildWhenLastSaved > 30 || !bInitialInit) { possibleEscorts.Add(grid); } else { // Need better discernment to not delete placed G-Corp grids like G-Corp AP Turret and GCorp Experimental Mech if (grid.IsControlledByFaction("GCORP")) // see npcgroup.AttemptDespawn() { var slimBlocks = new List <IMySlimBlock>(); grid.GetBlocks(slimBlocks, b => b.FatBlock is IMyBeacon); foreach (var slim in slimBlocks) { var fb = slim.FatBlock as IMyBeacon; if (fb.CustomName.Contains(EscortName)) { ModLog.Info("Removing dead escort drone Grid:" + grid.CustomName); bOldRemovals = true; grid.CloseAll(); break; } } } } } }