public override void Initialize() { this.m_LoadingFighters = new List <Ship>(); this.m_LaunchingFighters = new List <Ship>(); this.m_SpawnedFighters = new List <LocustFighterControl>(); this.m_Planets = new List <StellarBody>(); this.m_State = LocustNestStates.SEEK; this.m_Target = (IGameObject)null; this.m_MaxNumFighters = this is LocustMoonControl ? this.m_Game.AssetDatabase.GlobalLocustData.MaxMoonCombatDrones : this.m_Game.AssetDatabase.GlobalLocustData.MaxCombatDrones; this.m_NumDestroyedDrones = 0; this.m_UpdateListDelay = 0; this.m_UpdateTargetList = false; this.m_LocustNest.PostSetProp("SetAsOnlyLaunchCarrier", true); this.m_NumLocustsReachedPlanet = this.m_Game.AssetDatabase.GlobalLocustData.NumToLand; if (this is LocustMoonControl) { this.m_LocustNest.Maneuvering.TargetFacingAngle = TargetFacingAngle.BroadSide; } LocustSwarmInfo locustSwarmInfo = this.m_Game.GameDatabase.GetLocustSwarmInfos().ToList <LocustSwarmInfo>().FirstOrDefault <LocustSwarmInfo>((Func <LocustSwarmInfo, bool>)(x => { int?fleetId1 = x.FleetId; int fleetId2 = this.m_FleetID; if (fleetId1.GetValueOrDefault() == fleetId2) { return(fleetId1.HasValue); } return(false); })); this.m_LocustSwarmID = 0; this.m_MaxNumFightersTotal = this.m_Game.AssetDatabase.GlobalLocustData.MaxDrones; if (locustSwarmInfo != null) { this.m_LocustSwarmID = locustSwarmInfo.Id; this.m_MaxNumFightersTotal = locustSwarmInfo.NumDrones; } this.SpawnMaxFighters(); }
private int SetNextScoutTarget( GameSession game, LocustSwarmInfo info, StarSystemInfo currentSystem, LocustSwarmScoutInfo scout, List <int> scoutedSystems) { List <int> previousTargets = game.GameDatabase.GetLocustSwarmTargets().ToList <int>(); List <StarSystemInfo> closestStars = EncounterTools.GetClosestStars(game.GameDatabase, currentSystem); closestStars.RemoveAll((Predicate <StarSystemInfo>)(x => previousTargets.Contains(x.ID))); closestStars.RemoveAll((Predicate <StarSystemInfo>)(x => scoutedSystems.Contains(x.ID))); if (closestStars.Count > 0) { scout.TargetSystemId = closestStars.First <StarSystemInfo>().ID; int num = game.GameDatabase.InsertFleet(this.PlayerId, 0, currentSystem.ID, currentSystem.ID, "Locust Swarm Scout", FleetType.FL_NORMAL); game.GameDatabase.TransferShip(scout.ShipId, num); int missionID = game.GameDatabase.InsertMission(num, MissionType.SURVEY, scout.TargetSystemId, 0, 0, 0, false, new int?()); Kerberos.Sots.StarFleet.StarFleet.SetWaypointsForMission(game, MissionType.SURVEY, missionID, num, scout.TargetSystemId, 0, new int?(currentSystem.ID)); game.GameDatabase.UpdateLocustSwarmScoutInfo(scout); } return(scout.TargetSystemId); }
private bool SetNextWorldTarget( GameSession game, LocustSwarmInfo info, FleetInfo fleet, StarSystemInfo currentSystem) { List <int> previousTargets = game.GameDatabase.GetLocustSwarmTargets().ToList <int>(); List <StarSystemInfo> source = new List <StarSystemInfo>(); if (game.GameDatabase.HasEndOfFleshExpansion()) { List <LocustSwarmScoutInfo> list = game.GameDatabase.GetLocustSwarmScoutsForLocustNest(info.Id).ToList <LocustSwarmScoutInfo>(); if (list.Count > 0) { bool flag1 = true; foreach (LocustSwarmScoutInfo locustSwarmScoutInfo in list) { ShipInfo shipInfo = game.GameDatabase.GetShipInfo(locustSwarmScoutInfo.ShipId, false); if (shipInfo != null) { int fleetId1 = shipInfo.FleetID; int?fleetId2 = info.FleetId; if ((fleetId1 != fleetId2.GetValueOrDefault() ? 1 : (!fleetId2.HasValue ? 1 : 0)) != 0) { flag1 = false; break; } } } if (!flag1) { return(true); } bool flag2 = false; List <StarSystemInfo> starSystemInfoList = new List <StarSystemInfo>(); foreach (LocustSwarmScoutTargetInfo swarmScoutTargetInfo in game.GameDatabase.GetLocustSwarmScoutTargetInfos().ToList <LocustSwarmScoutTargetInfo>()) { if (swarmScoutTargetInfo.SystemId != currentSystem.ID) { flag2 = true; int num = 0; foreach (PlanetInfo planetInfo in ((IEnumerable <PlanetInfo>)game.GameDatabase.GetStarSystemPlanetInfos(swarmScoutTargetInfo.SystemId)).ToList <PlanetInfo>()) { num += planetInfo.Resources; } if (num > 0) { StarSystemInfo starSystemInfo = game.GameDatabase.GetStarSystemInfo(swarmScoutTargetInfo.SystemId); if (swarmScoutTargetInfo.IsHostile) { starSystemInfoList.Add(starSystemInfo); } else { source.Add(starSystemInfo); } } } } if (!flag2) { source = EncounterTools.GetClosestStars(game.GameDatabase, currentSystem); } if (source.Count == 0) { source.AddRange((IEnumerable <StarSystemInfo>)starSystemInfoList); } source.OrderBy <StarSystemInfo, float>((Func <StarSystemInfo, float>)(x => (x.Origin - currentSystem.Origin).LengthSquared)); } else { source = EncounterTools.GetClosestStars(game.GameDatabase, currentSystem); } } else { source = EncounterTools.GetClosestStars(game.GameDatabase, currentSystem); } source.RemoveAll((Predicate <StarSystemInfo>)(x => previousTargets.Contains(x.ID))); if (source.Count <= 0) { return(false); } game.GameDatabase.InsertLocustSwarmTarget(info.Id, fleet.SystemID); int id = source.First <StarSystemInfo>().ID; int missionID = game.GameDatabase.InsertMission(fleet.ID, MissionType.STRIKE, source.First <StarSystemInfo>().ID, 0, 0, 0, false, new int?()); game.GameDatabase.InsertWaypoint(missionID, WaypointType.TravelTo, new int?(id)); this.UpdateScoutedSystems(game, id); return(true); }
public void UpdateTurn(GameSession game, int id) { LocustSwarmInfo locustSwarmInfo1 = game.GameDatabase.GetLocustSwarmInfo(id); if (locustSwarmInfo1 == null || !locustSwarmInfo1.FleetId.HasValue) { game.GameDatabase.RemoveEncounter(id); } else { FleetInfo fleetInfo1 = game.GameDatabase.GetFleetInfo(locustSwarmInfo1.FleetId.Value); StarSystemInfo starSystemInfo = game.GameDatabase.GetStarSystemInfo(fleetInfo1.SystemID); if (starSystemInfo != (StarSystemInfo)null && !starSystemInfo.IsDeepSpace) { locustSwarmInfo1 = this.SpendResources(game, locustSwarmInfo1, fleetInfo1); } game.GameDatabase.GetMissionByFleetID(fleetInfo1.ID); if (game.GameDatabase.GetMoveOrderInfoByFleetID(fleetInfo1.ID) != null || game.isHostilesAtSystem(this.PlayerId, fleetInfo1.SystemID)) { game.GameDatabase.UpdateLocustSwarmInfo(locustSwarmInfo1); } else { if (locustSwarmInfo1.Resources >= game.AssetDatabase.GlobalLocustData.MinResourceSpawnAmount) { this.AddInstance(game.GameDatabase, game.AssetDatabase, new int?(starSystemInfo.ID)); locustSwarmInfo1.Resources -= game.AssetDatabase.GlobalLocustData.MinResourceSpawnAmount; } int num1 = 0; List <PlanetInfo> list = ((IEnumerable <PlanetInfo>)game.GameDatabase.GetStarSystemPlanetInfos(starSystemInfo.ID)).ToList <PlanetInfo>(); foreach (PlanetInfo planet in list) { int num2 = Math.Min(planet.Resources, game.AssetDatabase.GlobalLocustData.MaxSalvageRate - num1); planet.Resources -= num2; num1 += num2; game.GameDatabase.UpdatePlanet(planet); if (num1 == game.AssetDatabase.GlobalLocustData.MaxSalvageRate) { break; } } locustSwarmInfo1.Resources += num1; int num3 = list.Sum <PlanetInfo>((Func <PlanetInfo, int>)(x => x.Resources)); bool flag = false; foreach (LocustSwarmInfo locustSwarmInfo2 in game.GameDatabase.GetLocustSwarmInfos().ToList <LocustSwarmInfo>()) { if (locustSwarmInfo2.Id != id && id >= locustSwarmInfo2.Id && locustSwarmInfo2.FleetId.HasValue) { FleetInfo fleetInfo2 = game.GameDatabase.GetFleetInfo(locustSwarmInfo2.FleetId.Value); if (fleetInfo2 != null && fleetInfo2.SystemID == fleetInfo1.SystemID) { flag = true; break; } } } if (game.GameDatabase.HasEndOfFleshExpansion()) { bool nestWaitingToGroupUp = num3 == 0 && game.GameDatabase.GetLocustSwarmScoutTargetInfos().Count <LocustSwarmScoutTargetInfo>() > 0 || flag; this.UpdateScoutMission(game, locustSwarmInfo1, fleetInfo1, starSystemInfo, nestWaitingToGroupUp); } if ((num3 == 0 || flag) && !this.SetNextWorldTarget(game, locustSwarmInfo1, fleetInfo1, starSystemInfo)) { game.GameDatabase.RemoveFleet(fleetInfo1.ID); game.GameDatabase.RemoveEncounter(locustSwarmInfo1.Id); } else { game.GameDatabase.UpdateLocustSwarmInfo(locustSwarmInfo1); } } } }