public void UpdatePinShip(Ship ship, Guid guid) { if (!this.Pins.ContainsKey(ship.guid)) { ThreatMatrix.Pin pin = new ThreatMatrix.Pin() { Position = ship.Center, Strength = ship.GetStrength(), EmpireName = ship.loyalty.data.Traits.Name }; this.Pins.TryAdd(ship.guid, pin); return; } this.Pins[ship.guid].Velocity = ship.Center - this.Pins[ship.guid].Position; this.Pins[ship.guid].Position = ship.Center; }
public void AssignShipToForce(Ship toAdd) { int numWars = 0; foreach (KeyValuePair<Empire, Ship_Game.Gameplay.Relationship> Relationship in this.empire.GetRelations()) { if (!Relationship.Value.AtWar || Relationship.Key.isFaction) { continue; } numWars++; } float baseDefensePct = 0.1f; baseDefensePct = baseDefensePct + 0.15f * (float)numWars; float defStr = this.DefensiveCoordinator.GetForcePoolStrength(); if (baseDefensePct > 0.35f) { baseDefensePct = 0.35f; } float EntireStrength = 0f; foreach (Ship ship in this.empire.GetShips()) { EntireStrength = EntireStrength + ship.GetStrength(); } //added by gremlin dont add zero strength ships to defensive force pool //if (this.DefensiveCoordinator.GetForcePoolStrength() / EntireStrength <= baseDefensePct if ((this.DefensiveCoordinator.defenseDeficit > 0 && this.DefensiveCoordinator.GetForcePoolStrength() < EntireStrength * baseDefensePct) && (toAdd.BombBays.Count == 0 || toAdd.WarpThrust <= 0f) &&toAdd.GetStrength()>0 && toAdd.BaseCanWarp) // { this.DefensiveCoordinator.DefensiveForcePool.Add(toAdd); toAdd.GetAI().SystemToDefend = null; toAdd.GetAI().SystemToDefendGuid = Guid.Empty; toAdd.GetAI().HasPriorityOrder = false; toAdd.GetAI().State = AIState.SystemDefender; this.DefensiveCoordinator.defenseDeficit-=toAdd.BaseStrength; return; } IOrderedEnumerable<AO> sorted = from ao in this.empire.GetGSAI().AreasOfOperations orderby Vector2.Distance(toAdd.Position, ao.Position) select ao; if (sorted.Count<AO>() <= 0) { this.empire.GetForcePool().Add(toAdd); return; } //sorted.First().AddShip(toAdd);// First<AO>().AddShip(toAdd); sorted.ElementAt(0).AddShip(toAdd); }
public void UpdatePin(Ship ship, bool ShipinBorders) { ThreatMatrix.Pin pin = null; bool exists = this.Pins.TryGetValue(ship.guid, out pin); if (pin == null) { pin = new ThreatMatrix.Pin() { Position = ship.Center, Strength = ship.GetStrength(), EmpireName = ship.loyalty.data.Traits.Name, ship = ship, InBorders = ShipinBorders }; if (exists) { this.Pins[ship.guid] = pin; return; } } else { this.Pins[ship.guid].Velocity = ship.Center - this.Pins[ship.guid].Position; this.Pins[ship.guid].Position = ship.Center; this.Pins[ship.guid].InBorders = ShipinBorders; if (this.Pins[ship.guid].ship == null) //ShipinBorders && this.Pins[ship.guid].ship = ship; return; } //lock (this.Pins) this.Pins.TryAdd(ship.guid, pin); }