void LaunchDrone(EncounterType encounterType, IMyRemoteControl remote, IMyEntity entity, Vector3D despawnCoords) { if (remote != null && encounterType == EncounterType.TransientCargoship) { remote.ClearWaypoints(); remote.FlightMode = Sandbox.ModAPI.Ingame.FlightMode.OneWay; remote.AddWaypoint(despawnCoords, "DespawnTarget"); remote.SetAutoPilotEnabled(true); remote.SpeedLimit = CARGOSHIP_SPEED; Util.Notify("Autopilot set"); } SpawnedShip ship = new SpawnedShip(); ship.entityId = entity.EntityId; if (encounterType == EncounterType.Static || encounterType == EncounterType.TransientEncounter) { m_empireData.encounters.Add(ship); } else if (encounterType == EncounterType.TransientCargoship) { m_empireData.civilianFleet.Add(ship); } else if (encounterType == EncounterType.TransientAttackship) { m_empireData.militaryFleet.Add(ship); } ship.despawnTick = GlobalData.world.currentTick + Tick.Minutes(10); if (encounterType == EncounterType.TransientAttackship || encounterType == EncounterType.TransientCargoship) { BotManager.CreateBot(BotManager.BotType.CargoShip, this, ship, remote); } Util.Log("Drone Prepped!"); }
public BotBase(SpawnManager manager, SpawnedShip ship, IMyRemoteControl remote) { m_spawnManager = manager; m_spawnedShip = ship; m_ownedGrid = remote.CubeGrid; m_remote = remote; SetupRemote(); SetupComms(); }
public static BotBase CreateBot(BotType botType, SpawnManager manager, SpawnedShip ship, IMyRemoteControl remote) { BotBase bot = null; switch (botType) { case BotType.CargoShip: bot = new CargoBot(manager, ship, remote); break; case BotType.Fighter: break; } if (bot != null && bot.Active) { m_activeBots.Add(bot); } return bot; }
public void DespawnDrone(SpawnedShip ship) { bool managed = false; managed |= m_empireData.civilianFleet.Remove(ship); managed |= m_empireData.militaryFleet.Remove(ship); IMyEntity entity = MyAPIGateway.Entities.GetEntityById(ship.entityId); if (entity == null) { return; } if (!managed) { // Player captured me! // Only despawn me if I'm more than 20K from the player. } GroupInfo info = m_spawnGroups.Find(g => g.m_spawnGroupDef.Id.SubtypeName == ship.prefabId); if (info != null) { m_empireData.credits += info.m_cost; } IMyInventory inventory = entity.GetInventory(); if (inventory != null) { foreach (IMyInventoryItem item in inventory.GetItems()) { // TODO: actually value each type of item differently. m_empireData.credits += item.Amount.ToIntSafe() * 10; } } BlockManagement.DespawnShip((IMyCubeGrid)entity); }
public CargoBot(SpawnManager manager, SpawnedShip spawnedShip, IMyRemoteControl remote) : base(manager, spawnedShip, remote) { EventManager.AddEvent(m_spawnedShip.despawnTick, UpdateDespawn); EventManager.AddEvent(GlobalData.world.currentTick + CALL_HELP_TICKS, UpdateCallHelp); SetupCallsign(); }