コード例 #1
0
        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!");
        }
コード例 #2
0
ファイル: BotBase.cs プロジェクト: kulseran/SpaceEngineers
    public BotBase(SpawnManager manager, SpawnedShip ship, IMyRemoteControl remote) {
      m_spawnManager = manager;
      m_spawnedShip = ship;
      m_ownedGrid = remote.CubeGrid;
      m_remote = remote;

      SetupRemote();
      SetupComms();
    }
コード例 #3
0
    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;
    }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: CargoBot.cs プロジェクト: kulseran/SpaceEngineers
 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();
 }