예제 #1
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);
    }
예제 #2
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);
    }
예제 #3
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);
    }
예제 #4
0
    public void AddFidsModifierDescriptors(SimulationObject district, WorldPosition worldPosition, bool districtIsProxy)
    {
        List <SimulationDescriptor> fidsModifierDescriptorsHavingAnEffectOnPosition = this.GetFidsModifierDescriptorsHavingAnEffectOnPosition(worldPosition);

        for (int i = 0; i < fidsModifierDescriptorsHavingAnEffectOnPosition.Count; i++)
        {
            SimulationDescriptor simulationDescriptor = fidsModifierDescriptorsHavingAnEffectOnPosition[i];
            district.AddDescriptor(simulationDescriptor);
            if (!districtIsProxy)
            {
                if (!this.descriptorsAppliedOnDistrict.ContainsKey(worldPosition))
                {
                    this.descriptorsAppliedOnDistrict.Add(worldPosition, new List <string>());
                }
                this.descriptorsAppliedOnDistrict[worldPosition].Add(simulationDescriptor.Name);
            }
        }
        district.Refresh();
    }
예제 #5
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;
     }
 }
예제 #6
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;
    }