private bool HasAccessToInfo(IntelCoverage coverage, ItemInfoID infoID, Player player) {
     switch (coverage) {
         case IntelCoverage.Comprehensive:
             if (HasAccessToInfo_Comprehensive(infoID, player)) {
                 return true;
             }
             goto case IntelCoverage.Broad;
         case IntelCoverage.Broad:
             if (HasAccessToInfo_Broad(infoID, player)) {
                 return true;
             }
             goto case IntelCoverage.Essential;
         case IntelCoverage.Essential:
             if (HasAccessToInfo_Essential(infoID, player)) {
                 return true;
             }
             goto case IntelCoverage.Basic;
         case IntelCoverage.Basic:
             if (HasAccessToInfo_Basic(infoID, player)) {
                 return true;
             }
             goto case IntelCoverage.None;
         case IntelCoverage.None:
             return false;
         default:
             throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(coverage));
     }
 }
        protected override bool HasAccessToInfo_Basic(ItemInfoID infoID, Player player) {
            switch (infoID) {
                case ItemInfoID.Name:
                case ItemInfoID.Position:
                case ItemInfoID.SectorID:
                    return true;
                case ItemInfoID.Owner:
                    // If gets here, System IntelCoverage is Basic, but a member could be allowing access
                    SystemData sysData = _data as SystemData;
                    bool starHasAccess = sysData.StarData.InfoAccessCntlr.HasAccessToInfo(player, infoID);
                    if (starHasAccess) {
                        return true;
                    }
                    else {
                        bool anyPlanetoidHasAccess = sysData.AllPlanetoidData.Select(pData => pData.InfoAccessCntlr).Any(iac => iac.HasAccessToInfo(player, infoID));
                        if (anyPlanetoidHasAccess) {
                            return true;
                        }
                        // WARNING: Do not inquire about Settlement Owner as Settlement inquires about System Owner creating a circular loop
                    }
                    return false;

                default:
                    return false;
            }
        }
 public string GetText(DisplayTargetID displayTgtID, Player player, StarReport starReport, PlanetoidReport[] planetoidReports, bool includeUnknown) {
     if (!IsTextCurrent(displayTgtID, player, starReport, planetoidReports, includeUnknown)) {
         D.Log("{0} generating new text for Label {1}, Player {2}.", GetType().Name, displayTgtID.GetValueName(), player.LeaderName);
         GenerateText(displayTgtID, player, starReport, planetoidReports, includeUnknown);
     }
     return _stringBuilder.ToString();
 }
 public string GetText(DisplayTargetID displayTgtID, Player player, AIntel intel, ShipReport[] elementReports, bool includeUnknown) {
     if (!IsTextCurrent(displayTgtID, player, intel.CurrentCoverage, elementReports, includeUnknown)) {
         D.Log("{0} generating new text for Label {1}, Player {2}.", GetType().Name, displayTgtID.GetValueName(), player.LeaderName);
         GenerateText(displayTgtID, player, intel, elementReports, includeUnknown);
     }
     return _stringBuilder.ToString();
 }
 protected override bool HasAccessToInfo_Comprehensive(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Resources:
         default:
             return false;
     }
 }
Esempio n. 6
0
 private AIntel InitializeIntelState(Player player) {
     bool isCoverageComprehensive = References.DebugControls.IsAllIntelCoverageComprehensive || Owner == player;
     // 8.1.16 OPTIMIZE alliance test may not be needed. Currently, new items created in runtime test for this in their creators
     isCoverageComprehensive = isCoverageComprehensive || Owner.IsRelationshipWith(player, DiplomaticRelationship.Alliance);
     var coverage = isCoverageComprehensive ? IntelCoverage.Comprehensive : DefaultStartingIntelCoverage;
     return MakeIntel(coverage);
 }
 protected override bool HasAccessToInfo_Essential(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Owner:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Broad(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Capacity:
             return true;
         default:
             return false;
     }
 }
Esempio n. 9
0
 public ShipDesign(Player player, string designName, ShipHullStat hullStat, EnginesStat enginesStat, ShipCombatStance combatStance,
     IEnumerable<WeaponDesign> weaponDesigns, IEnumerable<PassiveCountermeasureStat> passiveCmStats,
     IEnumerable<ActiveCountermeasureStat> activeCmStats, IEnumerable<SensorStat> sensorStats, IEnumerable<ShieldGeneratorStat> shieldGenStats, Priority hqPriority)
     : base(player, designName, weaponDesigns, passiveCmStats, activeCmStats, sensorStats, shieldGenStats, hqPriority) {
     HullStat = hullStat;
     EnginesStat = enginesStat;
     CombatStance = combatStance;
 }
 public UnitCreatorConfiguration(string unitName, Player owner, GameDate deployDate, string cmdDesignName, IEnumerable<string> elementDesignNames) {
     UnitName = unitName;
     Owner = owner;
     DeployDate = deployDate;
     CmdDesignName = cmdDesignName;
     ElementDesignNames = elementDesignNames;
     ValidateDeployDate();
 }
Esempio n. 11
0
        public void HandleDetectionBy(Player detectingPlayer, IUnitCmd_Ltd cmdItem, RangeCategory sensorRange) {
            if (!_item.IsOperational) {
                D.Error("{0} should not be detected by {1} when dead!", _item.DebugName, cmdItem.DebugName);
            }
            //D.Log(ShowDebugLog, "{0}.HandleDetectionBy called. Detecting Cmd: {1}, SensorRange: {2}.", DebugName, cmdItem.DebugName, sensorRange.GetValueName());

            IDictionary<RangeCategory, IList<IUnitCmd_Ltd>> rangeLookup;
            if (!_detectionLookup.TryGetValue(detectingPlayer, out rangeLookup)) {

                Profiler.BeginSample("Proper Dictionary allocation", (_item as Component).gameObject);
                rangeLookup = new Dictionary<RangeCategory, IList<IUnitCmd_Ltd>>(3, RangeCategoryEqualityComparer.Default); // OPTIMIZE check size
                Profiler.EndSample();

                _detectionLookup.Add(detectingPlayer, rangeLookup);
            }

            IList<IUnitCmd_Ltd> cmds;
            if (!rangeLookup.TryGetValue(sensorRange, out cmds)) {

                Profiler.BeginSample("Proper List allocation", (_item as Component).gameObject);
                cmds = new List<IUnitCmd_Ltd>();
                Profiler.EndSample();

                rangeLookup.Add(sensorRange, cmds);
            }
            D.Assert(!cmds.Contains(cmdItem), cmdItem.DebugName);
            cmds.Add(cmdItem);

            // The following returns can not move earlier in method as detection state must be kept current to support Reset
            if (_debugControls.IsAllIntelCoverageComprehensive) {
                // Should already be set to comprehensive during game startup
                __ValidatePlayerIntelCoverageOfItemIsComprehensive(detectingPlayer);
                // Note: this debug setting DOES NOT pre-populate all player's knowledge
                if (_item.Owner.IsRelationshipWith(detectingPlayer, DiplomaticRelationship.Alliance, DiplomaticRelationship.Self)) {
                    // even with DebugSettings all coverage comprehensive, still no reason to update if Alliance or Self
                    __ValidatePlayerIntelCoverageOfItemIsComprehensive(detectingPlayer);    // UNCLEAR why called again?
                    __ValidatePlayerKnowledgeOfItem(detectingPlayer);
                    return;
                }
                UpdatePlayerKnowledge(detectingPlayer);
                return; // continuing could regress coverage on items that allow it
            }

            if (_item.Owner.IsRelationshipWith(detectingPlayer, DiplomaticRelationship.Alliance, DiplomaticRelationship.Self)) {
                // Should already be set to comprehensive when became self or alliance took place
                __ValidatePlayerIntelCoverageOfItemIsComprehensive(detectingPlayer);
                __ValidatePlayerKnowledgeOfItem(detectingPlayer);
                return; // continuing could regress coverage on items that allow it
            }

            Profiler.BeginSample("AssignDetectingPlayerIntelCoverage", (_item as Component).gameObject);
            AssignDetectingPlayerIntelCoverage(detectingPlayer);
            Profiler.EndSample();
            Profiler.BeginSample("UpdatePlayerKnowledge", (_item as Component).gameObject);
            UpdatePlayerKnowledge(detectingPlayer);
            Profiler.EndSample();
        }
 protected override bool HasAccessToInfo_Basic(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Name:
         case ItemInfoID.Position:
             return true;
         default:
             return false;
     }
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FacilityData" /> class.
 /// </summary>
 /// <param name="facility">The facility.</param>
 /// <param name="owner">The owner.</param>
 /// <param name="passiveCMs">The passive countermeasures.</param>
 /// <param name="hullEquipment">The hull equipment.</param>
 /// <param name="activeCMs">The active countermeasures.</param>
 /// <param name="sensors">The sensors.</param>
 /// <param name="shieldGenerators">The shield generators.</param>
 /// <param name="hqPriority">The HQ priority.</param>
 /// <param name="topography">The topography.</param>
 public FacilityData(IFacility facility, Player owner, IEnumerable<PassiveCountermeasure> passiveCMs, FacilityHullEquipment hullEquipment,
     IEnumerable<ActiveCountermeasure> activeCMs, IEnumerable<Sensor> sensors, IEnumerable<ShieldGenerator> shieldGenerators,
     Priority hqPriority, Topography topography)
     : base(facility, owner, passiveCMs, hullEquipment, activeCMs, sensors, shieldGenerators, hqPriority) {
     Topography = topography;
     Science = hullEquipment.Science;
     Culture = hullEquipment.Culture;
     Income = hullEquipment.Income;
 }
Esempio n. 14
0
 public FleetReport GetReport(Player player, AIntel intel, ShipReport[] elementReports) {
     if (!IsReportCurrent(player, intel.CurrentCoverage, elementReports)) {
         D.Log("{0} generating new {1} for Player {2}.", GetType().Name, typeof(FleetReport).Name, player.LeaderName);
         _elementReports = elementReports;
         _report = GenerateReport(player, intel, elementReports);
         _data.AcceptChanges();
     }
     return _report;
 }
 public SystemReport GetReport(Player player, StarReport starReport, PlanetoidReport[] planetoidReports) {
     if (!IsReportCurrent(player, starReport, planetoidReports)) {
         D.Log("{0} generating new {1} for Player {2}.", GetType().Name, typeof(SystemReport).Name, player.LeaderName);
         _starReport = starReport;
         _planetoidReports = planetoidReports;
         _report = GenerateReport(player, starReport, planetoidReports);
         _data.AcceptChanges();
     }
     return _report;
 }
 protected override bool HasAccessToInfo_Comprehensive(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.CurrentHitPoints:
         case ItemInfoID.Health:
         case ItemInfoID.Resources:
             return true;
         default:
             return false;
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StarData" /> class.
 /// </summary>
 /// <param name="star">The star.</param>
 /// <param name="starStat">The stat.</param>
 /// <param name="owner">The owner.</param>
 public StarData(IStar star, StarStat starStat, Player owner)
     : base(star, owner) {
     Category = starStat.Category;
     Radius = starStat.Radius;
     CloseOrbitInnerRadius = starStat.CloseOrbitInnerRadius;
     Capacity = starStat.Capacity;
     Resources = starStat.Resources;
     Topography = Topography.System;
     SectorID = References.SectorGrid.GetSectorIdThatContains(Position);
 }
        public sealed override bool HasAccessToInfo(Player player, ItemInfoID infoID) {
            if (player == TempGameValues.NoPlayer) {
                D.Error("{0}: NoPlayer used to attempt access to {1}.{2}.", _data.DebugName, typeof(ItemInfoID).Name, infoID.GetValueName());
            }
            D.AssertNotDefault((int)infoID);

            var coverage = (_data as AIntelItemData).GetIntelCoverage(player);
            //D.Log(ShowDebugLog, "{0}: {1}.IntelCoverage for {2} is {3}.", GetType().Name, _data.DebugName, player, coverage.GetValueName());
            return HasAccessToInfo(coverage, infoID, player);
        }
Esempio n. 19
0
 public PlayersKnowledge(IEnumerable<Player> allPlayers) {
     int playerCount = allPlayers.Count();
     _playersKnowledgeLookup = new Dictionary<Player, PlayerKnowledge>(playerCount);
     allPlayers.ForAll(p => {
         _playersKnowledgeLookup.Add(p, new PlayerKnowledge(p));
         if (p.IsUser) {
             _userPlayer = p;
         }
     });
 }
 protected override bool HasAccessToInfo_Comprehensive(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Culture:
         case ItemInfoID.Science:
         case ItemInfoID.NetIncome:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Broad(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.CurrentHitPoints:
         case ItemInfoID.Health:
         case ItemInfoID.Defense:
         case ItemInfoID.Offense:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Essential(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Owner:
         case ItemInfoID.Category:
         case ItemInfoID.CurrentSpeedSetting:
         case ItemInfoID.AlertStatus:
             return true;
         default:
             return false;
     }
 }
Esempio n. 23
0
 private void GenerateText(DisplayTargetID displayTgtID, Player player, AIntel intel, ShipReport[] elementReports, bool includeUnknown) {
     _stringBuilder.Clear();
     _currentTextLabelID = displayTgtID;
     LabelFormatter.IncludeUnknown = includeUnknown;
     LabelFormatter.Report = GetReport(player, intel, elementReports);
     var labelLines = LabelFormatter.GetLabelLines(displayTgtID);
     foreach (var line in labelLines) {
         _stringBuilder.AppendLine(line);
         // IMPROVE don't include a line break on the last line
     }
 }
 protected override bool HasAccessToInfo_Basic(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Name:
         case ItemInfoID.ParentName:
         case ItemInfoID.Position:
         case ItemInfoID.SectorID:
         case ItemInfoID.OrbitalSpeed:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Comprehensive(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.CurrentCmdEffectiveness:
         case ItemInfoID.UnitScience:
         case ItemInfoID.UnitNetIncome:
         case ItemInfoID.Resources:
         case ItemInfoID.UnitCulture:
         case ItemInfoID.Capacity:
         case ItemInfoID.UnitCurrentHitPts:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Essential(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Category:
         case ItemInfoID.MaxHitPoints:
         case ItemInfoID.Mass:
         case ItemInfoID.WeaponsRange:
         case ItemInfoID.SensorRange:
         case ItemInfoID.Owner:
         case ItemInfoID.AlertStatus:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Broad(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.UnitWeaponsRange:
         case ItemInfoID.UnitSensorRange:
         case ItemInfoID.UnitHealth:
         case ItemInfoID.UnitMaxHitPts:
         case ItemInfoID.UnitCurrentHitPts:
         case ItemInfoID.Composition:
         case ItemInfoID.Formation:
         case ItemInfoID.UnitDefense:
         case ItemInfoID.UnitOffense:
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Broad(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.UnitWeaponsRange:
         case ItemInfoID.UnitSensorRange:
         case ItemInfoID.UnitHealth:
         case ItemInfoID.UnitMaxHitPts:
         case ItemInfoID.Formation:
         case ItemInfoID.Composition:
         case ItemInfoID.UnitOffense:
         case ItemInfoID.UnitDefense:
             //D.Log(ShowDebugLog, "{0}.HasAccesstoInfo_Broad({1}, {2}) called.", GetType().Name, infoID.GetValueName(), player);
             return true;
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Basic(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Name:
         case ItemInfoID.ParentName:
         case ItemInfoID.Position:
         case ItemInfoID.SectorID:
             return true;
         case ItemInfoID.Owner:
             // If gets here, Settlement IntelCoverage is Basic, but ParentSystem could be allowing access.
             // System uses ImprovingIntel where Coverage can't regress. Settlement uses Intel which allows regress
             SystemInfoAccessController parentSysAccessCntlr = (_data as SettlementCmdData).ParentSystemData.InfoAccessCntlr;
             return parentSysAccessCntlr.HasAccessToInfo(player, ItemInfoID.Owner);
         default:
             return false;
     }
 }
 protected override bool HasAccessToInfo_Basic(ItemInfoID infoID, Player player) {
     switch (infoID) {
         case ItemInfoID.Name:
         case ItemInfoID.Position:
         case ItemInfoID.SectorID:
             return true;
         case ItemInfoID.Owner:
             // If gets here, Sector IntelCoverage is Basic, but a member could be allowing access.
             SectorData sectorData = _data as SectorData;
             bool systemHasAccess = sectorData.SystemData != null ? sectorData.SystemData.InfoAccessCntlr.HasAccessToInfo(player, infoID) : false;
             if (systemHasAccess) {
                 return true;
             }
             return false;
         default:
             return false;
     }
 }