コード例 #1
0
    public override void ReadXml(XmlReader reader)
    {
        IGameService service = Services.GetService <IGameService>();

        Diagnostics.Assert(service != null);
        Diagnostics.Assert(service.Game != null);
        global::Game game = service.Game as global::Game;

        Diagnostics.Assert(game != null);
        reader.ReadVersionAttribute();
        this.GUID = reader.GetAttribute <ulong>("GUID");
        base.ReadXml(reader);
        string x = reader.ReadElementString("NodeDefinitionName");
        IDatabase <CreepingNodeImprovementDefinition> database       = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true);
        CreepingNodeImprovementDefinition             nodeDefinition = null;

        if (database.TryGetValue(x, out nodeDefinition))
        {
            this.NodeDefinition = nodeDefinition;
        }
        int num  = reader.ReadElementString <int>("IndexOfPointOfInterest");
        int num2 = reader.ReadElementString <int>("IndexOfRegion");

        this.PointOfInterest     = game.World.Regions[num2].PointOfInterests[num];
        this.LastTurnChecked     = reader.ReadElementString <int>("LastTurnChecked");
        this.IsUpgradeReady      = reader.ReadElementString <bool>("IsUpgradeReady");
        this.UpgradeReachedTurn  = reader.ReadElementString <int>("UpgradeReachedTurn");
        this.TurnsCounter        = reader.ReadElementString <float>("TurnsCounter");
        this.dismantlingArmyGUID = reader.ReadElementString <ulong>("DismantlingArmyGUID");
        this.Life    = reader.ReadElementString <float>("Life");
        this.MaxLife = reader.ReadElementString <float>("MaxLife");
        this.LastTurnWhenDismantleBegun = reader.ReadElementString <int>("LastTurnWhenDismantleBegun");
        this.ReadDictionnary(reader, "StoredConstructionCost", this.StoredConstructionCost);
    }
コード例 #2
0
    protected bool CanAffordFoodCost(AILayer_CreepingNode.EvaluableCreepingNode node)
    {
        List <CreepingNodeConstructionMessage> list = new List <CreepingNodeConstructionMessage>(base.AIEntity.AIPlayer.Blackboard.GetMessages <CreepingNodeConstructionMessage>(BlackboardLayerID.Empire, (CreepingNodeConstructionMessage match) => match.State != BlackboardMessage.StateValue.Message_Canceled));
        SimulationObject     simulationObject       = new SimulationObject("PendingNodesUpkeep");
        SimulationDescriptor descriptor             = null;
        SimulationDescriptor descriptor2            = null;

        if (this.simulationDescriptorDatabase.TryGetValue("ClassCreepingNode", out descriptor2))
        {
            simulationObject.AddDescriptor(descriptor2);
            for (int i = 0; i < list.Count; i++)
            {
                CreepingNodeImprovementDefinition value = this.creepingNodeDefinitionDatabase.GetValue(list[i].NodeDefinitionName);
                if (value != null && this.simulationDescriptorDatabase.TryGetValue(node.nodeDefinition.ConstructionCostDescriptor, out descriptor))
                {
                    simulationObject.AddDescriptor(descriptor);
                }
            }
            if (this.simulationDescriptorDatabase.TryGetValue(node.nodeDefinition.ConstructionCostDescriptor, out descriptor))
            {
                simulationObject.AddDescriptor(descriptor);
            }
            this.aiEntityCity.City.SimulationObject.AddChild(simulationObject);
            this.aiEntityCity.City.SimulationObject.Refresh();
            float propertyValue = this.aiEntityCity.City.GetPropertyValue("NetCityGrowth");
            this.aiEntityCity.City.SimulationObject.RemoveChild(simulationObject);
            this.aiEntityCity.City.SimulationObject.Refresh();
            return(propertyValue > 0f);
        }
        Diagnostics.LogError("Could not find the class creeping node descriptor");
        return(false);
    }
コード例 #3
0
    protected bool CanAffordUpkeepCost(AILayer_CreepingNode.EvaluableCreepingNode node)
    {
        List <CreepingNodeConstructionMessage> list = new List <CreepingNodeConstructionMessage>(base.AIEntity.AIPlayer.Blackboard.GetMessages <CreepingNodeConstructionMessage>(BlackboardLayerID.Empire, (CreepingNodeConstructionMessage match) => match.State != BlackboardMessage.StateValue.Message_Canceled));
        SimulationObject     simulationObject       = new SimulationObject("PendingNodesUpkeep");
        SimulationDescriptor upkeepDescriptor;

        for (int i = 0; i < list.Count; i++)
        {
            CreepingNodeImprovementDefinition value = this.creepingNodeDefinitionDatabase.GetValue(list[i].NodeDefinitionName);
            if (value != null)
            {
                upkeepDescriptor = value.GetUpkeepDescriptor();
                if (upkeepDescriptor != null)
                {
                    simulationObject.AddDescriptor(upkeepDescriptor);
                }
            }
        }
        upkeepDescriptor = node.nodeDefinition.GetUpkeepDescriptor();
        if (upkeepDescriptor != null)
        {
            simulationObject.AddDescriptor(upkeepDescriptor);
        }
        this.aiEntityCity.City.SimulationObject.AddChild(simulationObject);
        this.aiEntityCity.City.SimulationObject.Refresh();
        float propertyValue = this.aiEntityCity.City.GetPropertyValue("CreepingNodesUpkeep");
        float upkeepLimit   = this.GetUpkeepLimit();

        this.aiEntityCity.City.SimulationObject.RemoveChild(simulationObject);
        this.aiEntityCity.City.SimulationObject.Refresh();
        return(propertyValue <= upkeepLimit);
    }
コード例 #4
0
    protected List <AILayer_CreepingNode.EvaluableCreepingNode> GetAvailableNodes()
    {
        List <AILayer_CreepingNode.EvaluableCreepingNode> list = new List <AILayer_CreepingNode.EvaluableCreepingNode>();
        List <StaticString> list2 = new List <StaticString>();

        CreepingNodeImprovementDefinition[] values = this.creepingNodeDefinitionDatabase.GetValues();
        for (int i = 0; i < this.worldPositionningService.World.Regions.Length; i++)
        {
            Region region = this.worldPositionningService.World.Regions[i];
            int    num    = region.IsRegionColonized() ? 1 : 0;
            bool   flag   = region.Kaiju != null;
            bool   flag2  = region.BelongToEmpire(base.AIEntity.Empire);
            bool   flag3  = false;
            if (ELCPUtilities.UseELCPPeacefulCreepingNodes && !flag2 && region.Owner != null && region.Owner is MajorEmpire)
            {
                flag3 = (this.departmentOfForeignAffairs.IsFriend(region.Owner) && this.departmentOfForeignAffairs.CanMoveOn(region.Index, false));
            }
            bool flag4 = false;
            if (flag)
            {
                flag4 = (region.Kaiju.IsWild() || region.Kaiju.OwnerEmpireIndex == base.AIEntity.Empire.Index);
            }
            if (num == 0 || flag2 || flag3 || (flag && flag4))
            {
                foreach (PointOfInterest pointOfInterest in region.PointOfInterests)
                {
                    bool flag5 = this.departmentOfCreepingNodes.POIIsOnCooldown(pointOfInterest.GUID);
                    if ((!flag3 || pointOfInterest.Type == "QuestLocation") && !flag5)
                    {
                        bool flag6 = this.IsPoiUnlocked(pointOfInterest);
                        if (pointOfInterest.CreepingNodeImprovement == null && (!(pointOfInterest.Type != "Village") || pointOfInterest.PointOfInterestImprovement == null) && ((this.worldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & base.AIEntity.Empire.Bits) > 0 && flag6))
                        {
                            foreach (CreepingNodeImprovementDefinition creepingNodeImprovementDefinition in values)
                            {
                                if (creepingNodeImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName && (!(pointOfInterest.Type == "Village") || (pointOfInterest.SimulationObject.Tags.Contains(Village.PacifiedVillage) && !pointOfInterest.SimulationObject.Tags.Contains(Village.ConvertedVillage))))
                                {
                                    list2.Clear();
                                    DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.aiEntityCity.City, creepingNodeImprovementDefinition, ref list2, new string[]
                                    {
                                        ConstructionFlags.Prerequisite
                                    });
                                    if (!list2.Contains(ConstructionFlags.Discard) && this.departmentOfTheTreasury.CheckConstructibleInstantCosts(this.aiEntityCity.City, creepingNodeImprovementDefinition))
                                    {
                                        CreepingNodeImprovementDefinition          bestCreepingNodeDefinition = this.departmentOfCreepingNodes.GetBestCreepingNodeDefinition(this.aiEntityCity.City, pointOfInterest, creepingNodeImprovementDefinition, list2);
                                        AILayer_CreepingNode.EvaluableCreepingNode item = new AILayer_CreepingNode.EvaluableCreepingNode(pointOfInterest, bestCreepingNodeDefinition);
                                        if (!list.Contains(item))
                                        {
                                            list.Add(item);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return(list);
    }
コード例 #5
0
 private void OnSelectCreepingNodeCB(GameObject obj)
 {
     if (base.PlayerController != null)
     {
         CreepingNodeImprovementLabel.CreepingNodePair creepingNodePair = obj.GetComponent <AgeControlButton>().OnActivateDataObject as CreepingNodeImprovementLabel.CreepingNodePair;
         PointOfInterest pointOfInterest = creepingNodePair.PointOfInterest;
         CreepingNodeImprovementDefinition creepingNodeImprovementDefinition = creepingNodePair.CreepingNodeImprovementDefinition;
         OrderQueueCreepingNode            order = new OrderQueueCreepingNode(base.Empire.Index, this.departmentOfTheInterior.MainCity.GUID, pointOfInterest.GUID, creepingNodeImprovementDefinition, pointOfInterest.WorldPosition, false, true);
         base.PlayerController.PostOrder(order);
     }
 }
コード例 #6
0
 public void UpgradeNode(CreepingNodeImprovementDefinition upgrade)
 {
     this.RemoveImprovementDescriptors(this.NodeDefinition);
     this.RemoveConstructionCostDescriptor();
     DepartmentOfTheInterior.ClearFIMSEOnCreepingNode(this.Empire, this);
     this.NodeDefinition = upgrade;
     this.PointOfInterest.CreepingNodeImprovement = this.NodeDefinition;
     this.MaxLife = this.ConstructionTurns * this.NodeDefinition.GrowthPerTurn;
     this.AddConstructionCostDescriptor();
     if (!this.IsUnderConstruction)
     {
         this.CompleteUpgrade();
     }
 }
コード例 #7
0
    private SynchronousJobState SyncrhronousJob_QueueNode()
    {
        if (base.AIEntity == null || (base.AIEntity.Empire as MajorEmpire).ELCPIsEliminated || this.departmentOfTheInterior.MainCity == null || this.departmentOfTheInterior.MainCity.SimulationObject.Tags.Contains(City.TagCityStatusRazed))
        {
            return(SynchronousJobState.Failure);
        }
        if (this.departmentOfTheInterior.MainCity.GetPropertyValue(SimulationProperties.NetCityGrowth) <= 0f || this.nodesPerPopulation <= 0f)
        {
            return(SynchronousJobState.Success);
        }
        int i = 0;

        while (i < this.availableNodes.Count)
        {
            if (!this.IsNodeValid(i))
            {
                this.availableNodes.RemoveAt(i);
            }
            else
            {
                CreepingNodeImprovementDefinition nodeDefinition = this.availableNodes[i].nodeDefinition;
                OrderQueueCreepingNode            order          = new OrderQueueCreepingNode(base.AIEntity.Empire.Index, this.aiEntityCity.City.GUID, this.availableNodes[i].pointOfInterest.GUID, nodeDefinition, this.availableNodes[i].pointOfInterest.WorldPosition, false, true);
                base.AIEntity.Empire.PlayerControllers.AI.PostOrder(order);
                this.availableNodes.RemoveAt(i);
                if (this.availableNodes.Count == 0)
                {
                    return(SynchronousJobState.Success);
                }
                bool flag = true;
                foreach (Player player in this.playerRepositoryService)
                {
                    if (player.Type == PlayerType.Human && player.State != PlayerState.Ready)
                    {
                        flag = false;
                        break;
                    }
                }
                if (flag)
                {
                    Diagnostics.Log("ELCP: SyncrhronousJob_QueueNode() detected all humans are ready, aborting");
                    return(SynchronousJobState.Failure);
                }
                this.nodesPerPopulation -= 1f;
                return(SynchronousJobState.Running);
            }
        }
        return(SynchronousJobState.Success);
    }
コード例 #8
0
 private void RemoveImprovementDescriptors(CreepingNodeImprovementDefinition definition)
 {
     SimulationDescriptor[] descriptors = definition.Descriptors;
     for (int i = 0; i < descriptors.Length; i++)
     {
         base.RemoveDescriptor(descriptors[i]);
     }
     if (!string.IsNullOrEmpty(definition.VillageInfectionDescriptor))
     {
         SimulationDescriptor descriptor = null;
         if (this.simulationDescriptorDatabase.TryGetValue(definition.VillageInfectionDescriptor, out descriptor))
         {
             base.RemoveDescriptor(descriptor);
         }
     }
 }
コード例 #9
0
    public WorldPositionScore[] GetWorldPositionCreepingNodeImprovementScore(global::Empire empire, City city, List <AILayer_CreepingNode.EvaluableCreepingNode> listOfCreepingNodeCandidate)
    {
        List <WorldPositionScore> list = new List <WorldPositionScore>();

        city.SimulationObject.AddChild(this.districtProxyByEmpires[empire.Index]);
        for (int i = 0; i < listOfCreepingNodeCandidate.Count; i++)
        {
            PointOfInterest pointOfInterest = listOfCreepingNodeCandidate[i].pointOfInterest;
            CreepingNodeImprovementDefinition nodeDefinition = listOfCreepingNodeCandidate[i].nodeDefinition;
            if (pointOfInterest != null && nodeDefinition != null)
            {
                list.Add(this.ComputeCreepingNodeImprovementScoreAtPosition(empire, city, pointOfInterest, nodeDefinition));
            }
        }
        city.SimulationObject.RemoveChild(this.districtProxyByEmpires[empire.Index]);
        this.cityProxyByEmpires[empire.Index].AddChild(this.districtProxyByEmpires[empire.Index]);
        return(list.ToArray());
    }
コード例 #10
0
    private bool CanAfforFoodCost(global::Empire empire, CreepingNodeImprovementDefinition nodeDefinition)
    {
        DepartmentOfTheInterior agency           = empire.GetAgency <DepartmentOfTheInterior>();
        SimulationObject        simulationObject = new SimulationObject("DummyNode");
        SimulationDescriptor    descriptor       = null;
        SimulationDescriptor    descriptor2      = null;

        if (this.simulationDescriptorDatabase.TryGetValue("ClassCreepingNode", out descriptor2))
        {
            simulationObject.AddDescriptor(descriptor2);
            if (this.simulationDescriptorDatabase.TryGetValue(nodeDefinition.ConstructionCostDescriptor, out descriptor))
            {
                simulationObject.AddDescriptor(descriptor);
            }
            agency.MainCity.SimulationObject.AddChild(simulationObject);
            agency.MainCity.SimulationObject.Refresh();
            float propertyValue = agency.MainCity.GetPropertyValue("NetCityGrowth");
            agency.MainCity.SimulationObject.RemoveChild(simulationObject);
            agency.MainCity.SimulationObject.Refresh();
            return(propertyValue >= 0f);
        }
        Diagnostics.LogError("Could not find the class creeping node descriptor");
        return(false);
    }
コード例 #11
0
    private WorldPositionScore ComputeCreepingNodeImprovementScoreAtPosition(global::Empire empire, City city, PointOfInterest creepingNodePOI, CreepingNodeImprovementDefinition creepingNodeImprovementDefinition)
    {
        if (creepingNodePOI == null)
        {
            return(null);
        }
        if (creepingNodeImprovementDefinition == null)
        {
            return(null);
        }
        WorldPosition worldPosition = creepingNodePOI.WorldPosition;

        if (!worldPosition.IsValid)
        {
            return(null);
        }
        WorldPositionScore worldPositionScore = new WorldPositionScore(worldPosition, this.fimse);
        int regionIndex          = (int)this.WorldPositionningService.GetRegionIndex(worldPosition);
        int fidsiextractionRange = creepingNodeImprovementDefinition.FIDSIExtractionRange;
        int num = fidsiextractionRange;

        if (ELCPUtilities.UseELCPSymbiosisBuffs && num > 0)
        {
            num = ((fidsiextractionRange < 7) ? 1 : 2);
        }
        WorldPosition[] worldPositions = new WorldCircle(worldPosition, num).GetWorldPositions(this.WorldPositionningService.World.WorldParameters);
        int             num2           = 0;
        bool            flag           = false;

        foreach (WorldPosition worldPosition2 in worldPositions)
        {
            if (worldPosition2.IsValid)
            {
                if ((int)this.WorldPositionningService.GetRegionIndex(worldPosition2) != regionIndex)
                {
                    worldPositionScore.SumOfLostTiles++;
                }
                else if (!this.WorldPositionningService.IsExploitable(worldPosition2, 0))
                {
                    worldPositionScore.SumOfLostTiles++;
                }
                else
                {
                    if (city != null)
                    {
                        District district = this.WorldPositionningService.GetDistrict(worldPosition2);
                        if (district != null)
                        {
                            if (district.Type == DistrictType.Exploitation)
                            {
                                goto IL_17A;
                            }
                            float propertyValue = district.GetPropertyValue(SimulationProperties.NumberOfExtensionAround);
                            if (propertyValue < (float)DepartmentOfTheInterior.MinimumNumberOfExtensionNeighbourForLevelUp)
                            {
                                num2 += (int)propertyValue;
                                goto IL_17A;
                            }
                            goto IL_17A;
                        }
                    }
                    flag |= this.WorldPositionningService.IsWaterTile(worldPosition2);
                    worldPositionScore.Add(this.GetWorldPositionScore(empire.Index, worldPosition2), 1f);
                    worldPositionScore.NewDistrictNeighbourgNumber++;
                    if (!this.WorldPositionningService.IsWaterTile(worldPosition2))
                    {
                        worldPositionScore.NewDistrictNotWaterNeighbourNumber++;
                    }
                }
            }
            IL_17A :;
        }
        worldPositionScore.SumOfNumberOfExtensionAround = num2;
        worldPositionScore.HasCostalTile = flag;
        return(worldPositionScore);
    }
コード例 #12
0
 public CreepingNode(GameEntityGUID guid, global::Empire empire, PointOfInterest poi, CreepingNodeImprovementDefinition definition) : this(guid, empire)
 {
     this.PointOfInterest     = poi;
     this.NodeDefinition      = definition;
     this.UpgradeReachedTurn  = -1;
     this.DismantlingArmyGUID = GameEntityGUID.Zero;
     this.Life = 0f;
     this.LastTurnWhenDismantleBegun = 0;
     this.MaxLife = this.ConstructionTurns * this.NodeDefinition.GrowthPerTurn;
 }
コード例 #13
0
 public EvaluableCreepingNode(PointOfInterest poi, CreepingNodeImprovementDefinition definition)
 {
     this.pointOfInterest = poi;
     this.nodeDefinition  = definition;
     this.score           = 0f;
 }
コード例 #14
0
    public override void ReadXml(XmlReader reader)
    {
        int num = reader.ReadVersionAttribute();

        this.GUID          = reader.GetAttribute <ulong>("GUID");
        this.ArmyPillaging = reader.GetAttribute <ulong>("ArmyPillaging");
        base.ReadXml(reader);
        string text = reader.GetAttribute("PointOfInterestTemplateName");

        reader.ReadStartElement("PointOfInterestDefinition");
        this.PointOfInterestDefinition = new PointOfInterestDefinition();
        if (text == "QuestLocation_SunkenRuin")
        {
            text = "NavalQuestLocation_SunkenRuin";
        }
        IDatabase <PointOfInterestTemplate> database = Databases.GetDatabase <PointOfInterestTemplate>(true);

        this.PointOfInterestDefinition.PointOfInterestTemplateName = text;
        this.PointOfInterestDefinition.PointOfInterestTemplate     = database.GetValue(text);
        this.PointOfInterestDefinition.WorldPosition = reader.ReadElementSerializable <WorldPosition>();
        int attribute = reader.GetAttribute <int>("Count");

        reader.ReadStartElement("Overrides");
        for (int i = 0; i < attribute; i++)
        {
            string attribute2 = reader.GetAttribute("Key");
            string attribute3 = reader.GetAttribute("Value");
            this.PointOfInterestDefinition.Overrides.Add(attribute2, attribute3);
        }
        reader.ReadEndElement("Overrides");
        reader.ReadEndElement("PointOfInterestDefinition");
        this.Interaction.Bits = reader.GetAttribute <int>("Bits");
        int attribute4 = reader.GetAttribute <int>("InteractionLockCount");

        reader.ReadStartElement("Interaction");
        for (int j = 0; j < attribute4; j++)
        {
            int attribute5 = reader.GetAttribute <int>("Key");
            int attribute6 = reader.GetAttribute <int>("ValueCount");
            reader.ReadStartElement("InteractionLock");
            for (int k = 0; k < attribute6; k++)
            {
                string attribute7 = reader.GetAttribute <string>("Key");
                int    attribute8 = reader.GetAttribute <int>("Value");
                reader.ReadStartElement("Value");
                if (!this.Interaction.InteractionLockCount.ContainsKey(attribute5))
                {
                    this.Interaction.InteractionLockCount.Add(attribute5, new Dictionary <string, int>());
                }
                this.Interaction.InteractionLockCount[attribute5].Add(attribute7, attribute8);
                reader.ReadEndElement("Value");
            }
            reader.ReadEndElement("InteractionLock");
        }
        reader.ReadEndElement("Interaction");
        string text2 = reader.ReadElementString("PointOfInterestImprovement");

        if (!string.IsNullOrEmpty(text2))
        {
            IDatabase <DepartmentOfIndustry.ConstructibleElement> database2 = Databases.GetDatabase <DepartmentOfIndustry.ConstructibleElement>(true);
            DepartmentOfIndustry.ConstructibleElement             pointOfInterestImprovement = null;
            if (database2.TryGetValue(text2, out pointOfInterestImprovement))
            {
                this.PointOfInterestImprovement = pointOfInterestImprovement;
                if (this.PointOfInterestImprovement != null)
                {
                    for (int l = 0; l < this.PointOfInterestImprovement.Descriptors.Length; l++)
                    {
                        if (!base.SimulationObject.Tags.Contains(this.PointOfInterestImprovement.Descriptors[l].Name))
                        {
                            base.AddDescriptor(this.PointOfInterestImprovement.Descriptors[l], false);
                        }
                    }
                }
            }
            reader.ReadEndElement("PointOfInterestImprovement");
        }
        if (reader.IsStartElement("AffinityMapping"))
        {
            this.AffinityMapping = reader.ReadElementString("AffinityMapping");
        }
        this.QuestStepsUsedBy.Clear();
        if (reader.IsStartElement("QuestStepsUsedBy"))
        {
            int attribute9 = reader.GetAttribute <int>("QuestStepsCount");
            reader.ReadStartElement("QuestStepsUsedBy");
            for (int m = 0; m < attribute9; m++)
            {
                this.QuestStepsUsedBy.Add(reader.ReadString());
            }
            reader.ReadEndElement("QuestStepsUsedBy");
        }
        if (num < 2 && this.Type == Fortress.Citadel)
        {
            base.RemoveDescriptorByType("CitadelType");
            IDatabase <DepartmentOfIndustry.ConstructibleElement> database3 = Databases.GetDatabase <DepartmentOfIndustry.ConstructibleElement>(true);
            DepartmentOfIndustry.ConstructibleElement             pointOfInterestImprovement2 = null;
            if (database3.TryGetValue(this.PointOfInterestDefinition.PointOfInterestTemplate.Properties["Improvement"], out pointOfInterestImprovement2))
            {
                this.PointOfInterestImprovement = pointOfInterestImprovement2;
                if (this.PointOfInterestImprovement != null)
                {
                    for (int n = 0; n < this.PointOfInterestImprovement.Descriptors.Length; n++)
                    {
                        if (!base.SimulationObject.Tags.Contains(this.PointOfInterestImprovement.Descriptors[n].Name))
                        {
                            base.AddDescriptor(this.PointOfInterestImprovement.Descriptors[n], false);
                        }
                    }
                }
            }
        }
        if (num >= 3)
        {
            this.UntappedDustDeposits = reader.ReadElementString <bool>("UntappedDustDeposits");
        }
        if (num >= 4)
        {
            string text3 = reader.ReadElementString("CreepingNodeImprovement");
            if (!string.IsNullOrEmpty(text3))
            {
                IDatabase <CreepingNodeImprovementDefinition> database4 = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true);
                CreepingNodeImprovementDefinition             creepingNodeImprovement = null;
                if (database4.TryGetValue(text3, out creepingNodeImprovement))
                {
                    this.CreepingNodeImprovement = creepingNodeImprovement;
                    if (Amplitude.Unity.Framework.Application.Preferences.EnableModdingTools && this.CreepingNodeImprovement != null)
                    {
                        for (int num2 = 0; num2 < this.CreepingNodeImprovement.Descriptors.Length; num2++)
                        {
                            if (base.SimulationObject.Tags.Contains(this.CreepingNodeImprovement.Descriptors[num2].Name))
                            {
                                base.RemoveDescriptor(this.CreepingNodeImprovement.Descriptors[num2]);
                            }
                        }
                    }
                }
            }
            this.CreepingNodeGUID = reader.ReadElementString <ulong>("CreepingNodeGUID");
        }
    }
コード例 #15
0
    protected override void RefreshLayerLabel()
    {
        if (!base.IsVisible)
        {
            return;
        }
        if (base.Empire == null || this.departmentOfTheInterior.MainCity == null)
        {
            return;
        }
        if (this.departmentOfTheInterior == null || this.departmentOfTheInterior.MainCity == null)
        {
            return;
        }
        this.validPointsOfInterest.Clear();
        this.validImprovements.Clear();
        if (this.departmentOfTheInterior.MainCity != null && base.Empire.SimulationObject.Tags.Contains("FactionTraitMimics1"))
        {
            List <StaticString> list = new List <StaticString>();
            CreepingNodeImprovementDefinition[] values = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true).GetValues();
            if (this.entities == null)
            {
                this.entities = new List <IWorldEntityWithCulling>();
            }
            else
            {
                this.entities.Clear();
            }
            ReadOnlyCollection <IWorldEntityWithCulling> collection;
            if (base.WorldEntityCullingService.TryGetVisibleEntities <WorldPointOfInterest_QuestLocation>(out collection))
            {
                this.entities.AddRange(collection);
            }
            ReadOnlyCollection <IWorldEntityWithCulling> collection2;
            if (base.WorldEntityCullingService.TryGetVisibleEntities <WorldPointOfInterest>(out collection2))
            {
                this.entities.AddRange(collection2);
            }
            for (int i = 0; i < this.entities.Count; i++)
            {
                PointOfInterest pointOfInterest = (this.entities[i] as WorldPointOfInterest).PointOfInterest;
                Region          region          = base.WorldPositionningService.GetRegion(pointOfInterest.WorldPosition);
                int             num             = region.IsRegionColonized() ? 1 : 0;
                bool            flag            = region.Kaiju != null;
                bool            flag2           = region.BelongToEmpire(base.Empire);
                bool            flag3           = this.departmentOfCreepingNodes.POIIsOnCooldown(pointOfInterest.GUID);
                if (ELCPUtilities.UseELCPPeacefulCreepingNodes && !flag2 && region.Owner != null && region.Owner is MajorEmpire && pointOfInterest.Type == "QuestLocation")
                {
                    flag2 = (this.departmentOfForeignAffairs.IsFriend(region.Owner) && this.departmentOfForeignAffairs.CanMoveOn(region.Index, false));
                }
                bool flag4 = false;
                if (flag)
                {
                    flag4 = (region.Kaiju.IsWild() || region.Kaiju.OwnerEmpireIndex == base.Empire.Index);
                }
                if ((num == 0 || flag2 || (flag && flag4)) && !flag3)
                {
                    bool flag5 = this.IsPoiUnlocked(pointOfInterest);
                    if (pointOfInterest.CreepingNodeImprovement == null && (!(pointOfInterest.Type != "Village") || pointOfInterest.PointOfInterestImprovement == null) && ((base.WorldPositionningService.GetExplorationBits(pointOfInterest.WorldPosition) & base.Empire.Bits) > 0 && flag5))
                    {
                        List <CreepingNodeImprovementDefinition> list2 = new List <CreepingNodeImprovementDefinition>();
                        foreach (CreepingNodeImprovementDefinition creepingNodeImprovementDefinition in values)
                        {
                            if (creepingNodeImprovementDefinition.PointOfInterestTemplateName == pointOfInterest.PointOfInterestDefinition.PointOfInterestTemplateName && (!(pointOfInterest.Type == "Village") || (pointOfInterest.SimulationObject.Tags.Contains(Village.PacifiedVillage) && !pointOfInterest.SimulationObject.Tags.Contains(Village.ConvertedVillage))))
                            {
                                list.Clear();
                                DepartmentOfTheTreasury.CheckConstructiblePrerequisites(this.departmentOfTheInterior.MainCity, creepingNodeImprovementDefinition, ref list, new string[]
                                {
                                    ConstructionFlags.Prerequisite
                                });
                                if (!list.Contains(ConstructionFlags.Discard) && this.departmentOfTheTreasury.CheckConstructibleInstantCosts(this.departmentOfTheInterior.MainCity, creepingNodeImprovementDefinition))
                                {
                                    CreepingNodeImprovementDefinition bestCreepingNodeDefinition = this.departmentOfCreepingNodes.GetBestCreepingNodeDefinition(this.departmentOfTheInterior.MainCity, pointOfInterest, creepingNodeImprovementDefinition, list);
                                    if (!list2.Contains(bestCreepingNodeDefinition))
                                    {
                                        list2.Add(bestCreepingNodeDefinition);
                                    }
                                }
                            }
                        }
                        if (list2.Count > 0)
                        {
                            for (int k = 0; k < list2.Count; k++)
                            {
                                this.validPointsOfInterest.Add(pointOfInterest);
                                this.validImprovements.Add(list2[k]);
                            }
                        }
                    }
                }
            }
        }
        this.LabelsTable.ReserveChildren(this.validPointsOfInterest.Count, this.LabelPrefab, "ConstructibleLabel");
        this.LabelsTable.RefreshChildrenIList <PointOfInterest>(this.validPointsOfInterest, new AgeTransform.RefreshTableItem <PointOfInterest>(this.RefreshPointOfInterest), true, false);
        Transform transform = this.cameraController.Camera.transform;
        List <CreepingNodeImprovementLabel> children = this.LabelsTable.GetChildren <CreepingNodeImprovementLabel>(true);

        for (int l = 0; l < children.Count; l++)
        {
            CreepingNodeImprovementLabel creepingNodeImprovementLabel = children[l];
            PointOfInterest pointOfInterest2 = creepingNodeImprovementLabel.CreepingNodeInfo.PointOfInterest;
            if (pointOfInterest2 != null)
            {
                List <int> list3 = new List <int>();
                for (int m = 0; m < this.validPointsOfInterest.Count; m++)
                {
                    if (this.validPointsOfInterest[m] == pointOfInterest2)
                    {
                        list3.Add(m);
                    }
                }
                int     num2   = list3.IndexOf(l);
                Vector3 vector = this.GlobalPositionningService.Get3DPosition(pointOfInterest2.WorldPosition);
                bool    flag6  = this.IsInsideCamera(this.cameraController.Camera, vector, creepingNodeImprovementLabel.Width, creepingNodeImprovementLabel.Height, 1f);
                creepingNodeImprovementLabel.AgeTransform.Visible = flag6;
                if (flag6)
                {
                    Vector3 lhs     = vector - transform.position;
                    Vector3 forward = transform.forward;
                    float   num3    = Vector3.Dot(lhs, forward);
                    float   num4    = 0.01f;
                    if (num3 < num4)
                    {
                        vector += forward * (num4 - num3);
                    }
                    Vector3 vector2 = this.cameraController.Camera.WorldToScreenPoint(vector);
                    Vector2 vector3 = new Vector3(vector2.x + ((float)num2 + (float)list3.Count * 0.5f * -1f) * creepingNodeImprovementLabel.Width, (float)Screen.height - vector2.y - this.LabelsTable.Y);
                    creepingNodeImprovementLabel.Foreground.TiltAngle = 0f;
                    if (vector3.x < 0f)
                    {
                        vector3.x  = 0f;
                        vector3.y += ((float)num2 + (float)list3.Count * 0.5f * -1f) * creepingNodeImprovementLabel.Height;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 270f;
                    }
                    if (vector3.x > this.LabelsTable.Width - creepingNodeImprovementLabel.Width)
                    {
                        vector3.x  = this.LabelsTable.Width - creepingNodeImprovementLabel.Width;
                        vector3.y += ((float)num2 + (float)list3.Count * 0.5f * -1f) * creepingNodeImprovementLabel.Height;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 90f;
                    }
                    if (vector3.y < 0f)
                    {
                        vector3.y = 0f;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 0f;
                    }
                    if (vector3.y > this.LabelsTable.Height - creepingNodeImprovementLabel.Height)
                    {
                        vector3.y = this.LabelsTable.Height - creepingNodeImprovementLabel.Height;
                        creepingNodeImprovementLabel.Foreground.TiltAngle = 180f;
                    }
                    creepingNodeImprovementLabel.AgeTransform.X = vector3.x;
                    creepingNodeImprovementLabel.AgeTransform.Y = vector3.y;
                }
            }
        }
        if (base.LabelLayer != null)
        {
            base.AgeTransform.Alpha = base.LabelLayer.Opacity;
        }
    }
コード例 #16
0
    private void ComputeScoresByResource()
    {
        Dictionary <StaticString, int> dictionary            = new Dictionary <StaticString, int>();
        IEnumerable <EvaluableMessage_ResourceNeed> messages = base.AIEntity.AIPlayer.Blackboard.GetMessages <EvaluableMessage_ResourceNeed>(BlackboardLayerID.Empire, (EvaluableMessage_ResourceNeed match) => match.EvaluationState == EvaluableMessage.EvaluableMessageState.Pending || match.EvaluationState == EvaluableMessage.EvaluableMessageState.Validate);

        if (messages.Any <EvaluableMessage_ResourceNeed>())
        {
            foreach (EvaluableMessage_ResourceNeed evaluableMessage_ResourceNeed in messages)
            {
                if (evaluableMessage_ResourceNeed.MissingResources != null)
                {
                    foreach (MissingResource missingResource in evaluableMessage_ResourceNeed.MissingResources)
                    {
                        if (dictionary.ContainsKey(missingResource.ResourceName))
                        {
                            Dictionary <StaticString, int> dictionary2 = dictionary;
                            StaticString resourceName;
                            int          num = dictionary2[resourceName = missingResource.ResourceName];
                            dictionary2[resourceName] = num + 1;
                        }
                        else
                        {
                            dictionary.Add(missingResource.ResourceName, 1);
                        }
                    }
                }
            }
        }
        List <float> list = new List <float>();
        int          i    = 0;

        while (i < this.availableNodes.Count)
        {
            AILayer_CreepingNode.EvaluableCreepingNode evaluableCreepingNode = this.availableNodes[i];
            PointOfInterest pointOfInterest = evaluableCreepingNode.pointOfInterest;
            CreepingNodeImprovementDefinition nodeDefinition = evaluableCreepingNode.nodeDefinition;
            float num2 = 0f;
            if (!(pointOfInterest.Type == "ResourceDeposit"))
            {
                goto IL_184;
            }
            string x;
            if (pointOfInterest.PointOfInterestDefinition.TryGetValue("ResourceName", out x))
            {
                num2 = 0.5f;
                if (dictionary.ContainsKey(x))
                {
                    num2 = Mathf.Max(num2, (float)dictionary[x]);
                    goto IL_184;
                }
                goto IL_184;
            }
IL_17E:
            i++;
            continue;
IL_184:
            list.Add(num2);
            goto IL_17E;
        }
        if (list.Count > 0)
        {
            float num3 = list.Min();
            float num4 = list.Max();
            for (int j = 0; j < list.Count; j++)
            {
                if (!(this.availableNodes[j].pointOfInterest.Type != "ResourceDeposit"))
                {
                    float num5        = (num3 == num4) ? this.NormalizationFailSafeValue : Mathf.InverseLerp(num3, num4, list[j]);
                    float score       = this.availableNodes[j].score;
                    float boostFactor = num5 * this.ResourceWeight;
                    this.availableNodes[j].score = AILayer.Boost(score, boostFactor);
                }
            }
        }
    }
コード例 #17
0
 public void Show(ConstructibleTooltipData constructibleData)
 {
     this.ConstructibleTitle.Text = AgeLocalizer.Instance.LocalizeString(constructibleData.Title);
     this.effectDescriptions.Clear();
     this.simulationEffectParser.ParseSimulationDescriptor(constructibleData, this.effectDescriptions, null, false, false);
     this.EffectMapper.LoadEffects(this.effectDescriptions, true);
     if (this.EffectMapper.EffectsList.Height == 0f)
     {
         this.EffectTitle.Text = AgeLocalizer.Instance.LocalizeString("%FeatureNoEffectsTitle");
     }
     else
     {
         this.EffectTitle.Text = AgeLocalizer.Instance.LocalizeString("%FeatureEffectsTitle");
     }
     this.EffectGroup.Height  = this.EffectMapper.EffectsList.PixelOffsetTop + this.EffectMapper.EffectsList.PixelMarginTop + this.EffectMapper.EffectsList.Height + this.EffectMapper.EffectsList.PixelMarginBottom + this.EffectMapper.EffectsList.PixelOffsetBottom;
     this.CostGroup.Visible   = true;
     this.CostGroup.Y         = this.ConstructibleTitle.AgeTransform.Height + this.EffectGroup.Height;
     this.AgeTransform.Height = this.CostGroup.Y;
     if (constructibleData != null && ((ICostFeatureProvider)constructibleData).Constructible != null && ((ICostFeatureProvider)constructibleData).Empire != null)
     {
         DepartmentOfTheTreasury agency  = ((ICostFeatureProvider)constructibleData).Empire.GetAgency <DepartmentOfTheTreasury>();
         SimulationObjectWrapper context = (((ICostFeatureProvider)constructibleData).Context == null) ? ((ICostFeatureProvider)constructibleData).Empire : ((ICostFeatureProvider)constructibleData).Context;
         string text = string.Empty;
         int    num;
         PanelFeatureCost.ComputeCostAndTurn(this.guiService, ((ICostFeatureProvider)constructibleData).Constructible, agency, context, out text, out num);
         this.TurnIcon.AgeTransform.Visible  = false;
         this.TurnValue.AgeTransform.Visible = false;
         if (((ICostFeatureProvider)constructibleData).Constructible is CreepingNodeImprovementDefinition)
         {
             IDatabase <SimulationDescriptor> database = Databases.GetDatabase <SimulationDescriptor>(false);
             text = ((!(text == "-")) ? text : string.Empty);
             CreepingNodeImprovementDefinition creepingNodeImprovementDefinition = ((ICostFeatureProvider)constructibleData).Constructible as CreepingNodeImprovementDefinition;
             SimulationObject     simulationObject = new SimulationObject("DummyNode");
             SimulationDescriptor descriptor       = null;
             if (database.TryGetValue("ClassCreepingNode", out descriptor))
             {
                 simulationObject.AddDescriptor(descriptor);
             }
             else
             {
                 Diagnostics.LogError("Could not find the class creeping node descriptor");
             }
             float propertyBaseValue = simulationObject.GetPropertyBaseValue(creepingNodeImprovementDefinition.BaseCostPropertyName);
             float num2          = simulationObject.GetPropertyBaseValue(SimulationProperties.NodeCostIncrement);
             float propertyValue = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NodeCostIncrementModifier);
             num2 *= propertyValue;
             if (creepingNodeImprovementDefinition.SubCategory == "SubCategoryVillage")
             {
                 num2 *= ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NodeOvergrownVillageCostModifier);
             }
             float  propertyValue2 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NumberOfCreepingNodes);
             float  propertyValue3 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.NumberOfFinishedCreepingNodes);
             int    num3           = Mathf.CeilToInt(propertyBaseValue + num2 * (2f * propertyValue2 - propertyValue3 + 1f));
             float  propertyValue4 = ((ICostFeatureProvider)constructibleData).Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);
             int    num4           = (int)Math.Max(0.0, Math.Ceiling((double)((float)creepingNodeImprovementDefinition.ConstructionTurns * propertyValue4)));
             string str            = string.Format(AgeLocalizer.Instance.LocalizeString("%FeaturePanelNodeCost"), num3.ToString(), num4.ToString());
             text = text + " " + str;
         }
         if (!string.IsNullOrEmpty(text))
         {
             this.CostValue.Text = text;
             if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
             {
                 this.CostValue.AgeTransform.PixelMarginLeft = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
             }
             this.AgeTransform.Height += this.CostTitle.AgeTransform.Height;
             return;
         }
     }
     else
     {
         this.CostGroup.Visible = false;
     }
 }
コード例 #18
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        ConstructibleTooltipData constructibleTooltipData = this.context as ConstructibleTooltipData;

        if (constructibleTooltipData != null && constructibleTooltipData.Empire != null && constructibleTooltipData.Constructible != null)
        {
            DepartmentOfTheTreasury agency  = constructibleTooltipData.Empire.GetAgency <DepartmentOfTheTreasury>();
            DepartmentOfTheInterior agency2 = constructibleTooltipData.Empire.GetAgency <DepartmentOfTheInterior>();
            string text = string.Empty;
            if (agency2.MainCity != null)
            {
                int num;
                PanelFeatureCost.ComputeCostAndTurn(this.guiService, constructibleTooltipData.Constructible, agency, agency2.MainCity, out text, out num);
            }
            else
            {
                int num2;
                PanelFeatureCost.ComputeCostAndTurn(this.guiService, constructibleTooltipData.Constructible, agency, constructibleTooltipData.Empire, out text, out num2);
            }
            text = ((!(text == "-")) ? text : string.Empty);
            CreepingNodeImprovementDefinition creepingNodeImprovementDefinition = constructibleTooltipData.Constructible as CreepingNodeImprovementDefinition;
            SimulationObject     simulationObject = new SimulationObject("DummyNode");
            SimulationDescriptor descriptor       = null;
            if (this.simulationDescriptorDatabase.TryGetValue("ClassCreepingNode", out descriptor))
            {
                simulationObject.AddDescriptor(descriptor);
            }
            else
            {
                Diagnostics.LogError("Could not find the class creeping node descriptor");
            }
            float propertyBaseValue = simulationObject.GetPropertyBaseValue(creepingNodeImprovementDefinition.BaseCostPropertyName);
            float num3          = simulationObject.GetPropertyBaseValue(SimulationProperties.NodeCostIncrement);
            float propertyValue = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NodeCostIncrementModifier);
            num3 *= propertyValue;
            if (creepingNodeImprovementDefinition.SubCategory == "SubCategoryVillage")
            {
                num3 *= constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NodeOvergrownVillageCostModifier);
            }
            float  propertyValue2 = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NumberOfCreepingNodes);
            float  propertyValue3 = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.NumberOfFinishedCreepingNodes);
            int    num4           = Mathf.CeilToInt(propertyBaseValue + num3 * (2f * propertyValue2 - propertyValue3 + 1f));
            float  propertyValue4 = constructibleTooltipData.Empire.GetPropertyValue(SimulationProperties.GameSpeedMultiplier);
            int    num5           = (int)Math.Max(0.0, Math.Ceiling((double)((float)creepingNodeImprovementDefinition.ConstructionTurns * propertyValue4)));
            string str            = string.Format(AgeLocalizer.Instance.LocalizeString("%FeaturePanelNodeCost"), num4.ToString(), num5.ToString());
            text = text + " " + str;
            bool flag = this.CanAfforFoodCost(constructibleTooltipData.Empire, creepingNodeImprovementDefinition);
            if (!string.IsNullOrEmpty(text))
            {
                this.CostValue.Text      = text;
                this.CostValue.TintColor = ((!flag) ? this.CantAffordColor : this.CanAffordColor);
                if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
                {
                    this.CostValue.AgeTransform.PixelMarginLeft = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
                }
            }
        }
        yield return(base.OnShow(parameters));

        yield break;
    }