/// <summary> /// Updates the report with data from a star. /// </summary> /// <param name="star">Star to report.</param> /// <param name="scan">Amount of Knowledge to set.</param> /// <param name="year">Year of the updated data.</param> public void Update(Star star, ScanLevel scan, int year) { Clear(); if (star == null) { return; } if (year < this.Year) { return; } // Information that is always available and doesn't // depend on scanning level. Name = star.Name; Position = star.Position; // Can this change? Random Events? if (scan >= ScanLevel.None) { // We can't see this star. } // If we are at least scanning with non-penetrating if (scan >= ScanLevel.InScan) { // Non-pen scanners are useless for stars. } // If we are at least currently in orbit of the star // with no scanners. if (scan >= ScanLevel.InPlace) { // We can at least see it, so set age to current. Year = year; Owner = star.Owner; MineralConcentration = star.MineralConcentration; Gravity = star.Gravity; Radiation = star.Radiation; Temperature = star.Temperature; Starbase = star.Starbase; HasFleetsInOrbit = star.HasFleetsInOrbit; } // If we are have Pen-Scanners, or we are // in orbit with scanners. if (scan >= ScanLevel.InDeepScan) { Colonists = star.Colonists; } // If the star is ours. if (scan >= ScanLevel.Owned) { // We do nothing, as owned Stars are handled // elsewhere. } }
/// <summary> /// Updates the report with data from a fleet. /// </summary> /// <param name="fleet">Fleet to report.</param> /// <param name="scan">Amount of Knowledge to set.</param> /// <param name="year">Year of the updated data.</param> public void Update(Fleet fleet, ScanLevel scan, int year) { if (fleet == null) { return; } // Information that is always available and doesn't // depend on scanning level. Key = fleet.Key; Name = fleet.Name; Icon = fleet.Icon; Type = ItemType.FleetIntel; if (year < this.Year) { return; } if (scan >= ScanLevel.None) { // We keep the information we have. } // If we are at least scanning with non-penetrating if (scan >= ScanLevel.InScan) { // We can at least see it, so set age to current. Year = year; Position = fleet.Position; Bearing = fleet.Bearing; Speed = fleet.Speed; InOrbit = (fleet.InOrbit == null) ? false : true; IsStarbase = fleet.IsStarbase; Composition = fleet.Composition; } // If in the same position. if (scan >= ScanLevel.InPlace) { } // Pen scans do nothing for fleets. if (scan >= ScanLevel.InDeepScan) { } // If the fleet is ours. if (scan >= ScanLevel.Owned) { // Owned fleets are handled elsewhere. } }
/// <summary> /// Creates a fleet report from a fleet. /// </summary> /// <param name="fleet">Fleet to report.</param> /// <param name="scan">Amount of Knowledge to set.</param> /// <param name="year">Year of the data.</param> public FleetIntel(Fleet fleet, ScanLevel scan, int year) : base(fleet) { Clear(); Update(fleet, scan, year); }
public FleetIntel GenerateReport(ScanLevel scan, int year) { FleetIntel report = new FleetIntel(this, scan, year); return(report); }
/// <summary> /// Creates a star report from a star. /// </summary> /// <param name="star">Star to report.</param> /// <param name="scan">Amount of Knowledge to set.</param> /// <param name="year">Year of the data.</param> public StarIntel(Star star, ScanLevel scan, int year) : base() { Clear(); Update(star, scan, year); }
private void Scan(EmpireData empire) { foreach (Mappable scanner in empire.IterateAllMappables()) { int scanRange = 0; int penScanRange = 0; //Do some self scanning (Update reports) and set ranges.. if (scanner is Star) { scanRange = (scanner as Star).ScanRange; penScanRange = (scanner as Star).ScanRange; // TODO:(priority 6) Planetary Pen-Scan not implemented yet. empire.StarReports[scanner.Name].Update(scanner as Star, ScanLevel.Owned, serverState.TurnYear); } else { scanRange = (scanner as Fleet).ScanRange; penScanRange = (scanner as Fleet).PenScanRange; empire.FleetReports[scanner.Key].Update(scanner as Fleet, ScanLevel.Owned, empire.TurnYear); } // Scan everything foreach (Mappable scanned in serverState.IterateAllMappables()) { // ...That isn't ours! if (scanned.Owner == empire.Id) { continue; } ScanLevel scanLevel = ScanLevel.None; double range = 0; range = PointUtilities.Distance(scanner.Position, scanned.Position); if (scanned is Star) { Star star = scanned as Star; // There are two ways to get information from a Star: // 1. In orbit with a fleet, // 2. Not in orbit with a Pen Scan (fleet or star). // Non penetrating distance scans won't tell anything about it. if ((scanner is Fleet) && range == 0) { scanLevel = (scanner as Fleet).CanScan ? ScanLevel.InDeepScan : ScanLevel.InPlace; } else // scanner is Star or non orbiting Fleet { scanLevel = (range <= penScanRange) ? ScanLevel.InDeepScan : ScanLevel.None; } // Dont update if we didn't scan to allow report to age. if (scanLevel == ScanLevel.None) { continue; } if (empire.StarReports.ContainsKey(scanned.Name)) { empire.StarReports[scanned.Name].Update((scanned as Star), scanLevel, serverState.TurnYear); } else { empire.StarReports.Add(scanned.Name, (scanned as Star).GenerateReport(scanLevel, serverState.TurnYear)); } } else // scanned is Fleet { // Fleets are simple as scan levels (PenScan for example) won't affect them. We only // care for non penetrating distance scans. if (range > scanRange) { continue; } // Check if we have a record of this design(s). foreach (ShipToken token in (scanned as Fleet).Composition.Values) { if (empire.EmpireReports[scanned.Owner].Designs.ContainsKey(token.Design.Key)) { continue; } // If not, add just the empty Hull. ShipDesign newDesign = new ShipDesign(token.Design); newDesign.Key = token.Design.Key; newDesign.ClearAllocated(); empire.EmpireReports[scanned.Owner].Designs.Add(newDesign.Key, newDesign); } if (!empire.FleetReports.ContainsKey(scanned.Key)) { empire.FleetReports.Add(scanned.Key, (scanned as Fleet).GenerateReport(ScanLevel.InScan, serverState.TurnYear)); } else { empire.FleetReports[scanned.Key].Update((scanned as Fleet), ScanLevel.InScan, serverState.TurnYear); } } } } }
public StarIntel GenerateReport(ScanLevel scan, int year) { StarIntel report = new StarIntel(this, scan, year); return(report); }