Example #1
0
        private void SpawnCargoShip()
        {
            if (m_empireData.civilianFleet.Count >= 2)
            {
                return;
            }

            IMyPlayer randomPlayer = GetRandomPlayer();

            if (randomPlayer == null)
            {
                return;
            }
            SectorId originSector = m_empireData.ownedSectors[Util.rand.Next(m_empireData.ownedSectors.Count)];
            Vector3D sectorCenter = SectorManager.CenterFromSector(originSector);
            Vector3D dirToSector  = Vector3D.Normalize(sectorCenter - randomPlayer.GetPosition());
            Vector3D crossPoint   = MathExtender.RandomPerpendicularVector(dirToSector) * CARGOSHIP_CROSS_DIST;

            GroupInfo group = GetRandomSpawnGroup(SpawnerClass.CIVILIAN, m_empireData.credits);

            if (group == null)
            {
                return;
            }
            Vector3D routeDir = Vector3D.Normalize(sectorCenter - crossPoint);

            if (Util.rand.NextDouble() < 0.5)
            {
                routeDir *= -1;
            }
            Vector3D spawnStart = crossPoint - (routeDir * CARGOSHIP_SPAWN_DIST);
            Vector3D spawnEnd   = crossPoint + (routeDir * CARGOSHIP_SPAWN_DIST * 10);

            SpawnForGroup(group, EncounterType.TransientCargoship, spawnStart, spawnEnd);
        }
Example #2
0
        private void InitSectorOwnership()
        {
            List <SectorId> capturedSectors = new List <SectorId>();

            foreach (SectorId sector in m_data.ownedSectors)
            {
                if (!SectorManager.OwnFreeSector(sector, m_data))
                {
                    capturedSectors.Add(sector);
                }
            }
            m_data.ownedSectors.RemoveAll(s => capturedSectors.Find(t => t == s) != null);
            if (m_data.ownedSectors.Count == 0)
            {
                Util.Error("Empire owns no sectors: " + m_data.empireTag);
            }
        }
Example #3
0
        private void SpawnHQ()
        {
            if (m_data.ownedSectors.Count == 0)
            {
                Util.Error("Empire owns no sectors: " + m_data.empireTag);
                return;
            }
            SpawnManager.GroupInfo info = m_shipManager.GetRandomSpawnGroup(
                SpawnManager.SpawnerType.STATIC_STRUCTURE_HQ,
                999999999);
            Vector3D teritoryCenter = SectorManager.CenterFromSector(
                m_data.ownedSectors[Util.rand.Next(m_data.ownedSectors.Count)]);
            BoundingBoxD hqLocation = new BoundingBoxD(
                teritoryCenter - MAX_STRUCTURE_DISPLACEMENT,
                teritoryCenter + MAX_STRUCTURE_DISPLACEMENT);

            m_shipManager.SpawnForRegion(info, SpawnManager.EncounterType.Static, hqLocation);
        }