public static InterpreterContext.InterpreterSession CreateSession(SimulationObjectWrapper simObject, IEnumerable <QuestVariable> variables)
 {
     InterpreterContext.InterpreterSession result = new InterpreterContext.InterpreterSession(simObject);
     if (variables != null)
     {
         foreach (QuestVariable questVariable in variables)
         {
             if (questVariable.Object is float)
             {
                 result.Context.Register(questVariable.Name, (float)Convert.ChangeType(questVariable.Object, typeof(float)));
             }
             else if (questVariable.Object is IList)
             {
                 IList list = (IList)questVariable.Object;
                 if (list.Count == 1)
                 {
                     object obj = list[0];
                     if (obj is float)
                     {
                         result.Context.Register(questVariable.Name, (float)Convert.ChangeType(obj, typeof(float)));
                     }
                 }
             }
         }
     }
     return(result);
 }
Ejemplo n.º 2
0
 public static bool CheckPrerequisites(BoosterEffect effect, SimulationObjectWrapper context)
 {
     if (effect.Prerequisites == null || effect.Prerequisites.Length == 0)
     {
         return(true);
     }
     for (int i = 0; i < effect.Prerequisites.Length; i++)
     {
         if (!effect.Prerequisites[i].Check(context))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 3
0
    public ApprovalStatus GetApprovalStatusFor(SimulationObjectWrapper simulationObjectWrapper)
    {
        StaticString          descriptorNameFromType = simulationObjectWrapper.GetDescriptorNameFromType("Class");
        float                 num = 0f;
        List <ApprovalStatus> list;

        if (!this.approvalStatusByClass.TryGetValue(descriptorNameFromType, out list))
        {
            return(null);
        }
        Diagnostics.Assert(list != null);
        if (simulationObjectWrapper.HasProperty(SimulationProperties.NetCityApproval))
        {
            num = simulationObjectWrapper.GetPropertyValue(SimulationProperties.NetCityApproval);
        }
        else if (simulationObjectWrapper.HasProperty(SimulationProperties.NetEmpireApproval))
        {
            num = simulationObjectWrapper.GetPropertyValue(SimulationProperties.NetEmpireApproval);
        }
        else
        {
            Diagnostics.LogError("Can't found the approval value for simulation object wrapper {0}", new object[]
            {
                simulationObjectWrapper.Name
            });
        }
        ApprovalStatus approvalStatus = null;

        for (int i = 0; i < list.Count; i++)
        {
            ApprovalStatus approvalStatus2 = list[i];
            Diagnostics.Assert(approvalStatus2 != null);
            if (num >= (float)approvalStatus2.MinimalApproval && num <= (float)approvalStatus2.MaximalApproval)
            {
                approvalStatus = approvalStatus2;
            }
        }
        if (approvalStatus == null)
        {
            Diagnostics.LogWarning("No approval status found for approval value {0}.", new object[]
            {
                num
            });
        }
        return(approvalStatus);
    }
Ejemplo n.º 4
0
 private void SwapApprovalStatus(SimulationObjectWrapper simulationObjectWrapper, ApprovalStatus oldStatus, ApprovalStatus newStatus)
 {
     if (newStatus == oldStatus)
     {
         return;
     }
     if (oldStatus != null && oldStatus.SimulationDescriptors != null)
     {
         for (int i = 0; i < oldStatus.SimulationDescriptors.Length; i++)
         {
             simulationObjectWrapper.RemoveDescriptor(oldStatus.SimulationDescriptors[i]);
         }
     }
     if (newStatus != null && newStatus.SimulationDescriptors != null)
     {
         for (int j = 0; j < newStatus.SimulationDescriptors.Length; j++)
         {
             simulationObjectWrapper.AddDescriptor(newStatus.SimulationDescriptors[j], false);
         }
     }
 }
Ejemplo n.º 5
0
    bool IWorldEntityMappingOverride.TryResolve(out InterpreterContext context)
    {
        SimulationObject simulationObject = null;
        IGameService     service          = Services.GetService <IGameService>();

        if (service != null)
        {
            IGameEntityRepositoryService service2 = service.Game.Services.GetService <IGameEntityRepositoryService>();
            IGameEntity gameEntity;
            if (service2 != null && service2.TryGetValue(this.BoundTargetGUID, out gameEntity))
            {
                SimulationObjectWrapper simulationObjectWrapper = gameEntity as SimulationObjectWrapper;
                if (simulationObjectWrapper != null)
                {
                    simulationObject = simulationObjectWrapper.SimulationObject;
                }
            }
        }
        context = new InterpreterContext(simulationObject);
        context.Register("WorldMarkerType", this.MarkerTypeName);
        return(true);
    }
Ejemplo n.º 6
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;
     }
 }
Ejemplo n.º 7
0
    private bool CheckPrerequisites(QuestBehaviour questBehaviour, Dictionary <StaticString, IEnumerable <SimulationObjectWrapper> > targets)
    {
        if (this.Prerequisites == null || this.Prerequisites.Length == 0)
        {
            return(true);
        }
        if (this.Prerequisites.Length > 1)
        {
            Diagnostics.LogWarning("TODO: FIX THIS CODE TO SUPPORT MORE THAN 1 PREREQUISITE OF TYPE QUESTBEHAVIOURPREREQUISITES. Concerned quest is '{0}'.", new object[]
            {
                questBehaviour.Quest.Name
            });
        }
        if (global::GameManager.Preferences.QuestVerboseMode)
        {
            Diagnostics.Log("ELCP: {0} quest {1} begins prereq check", new object[]
            {
                questBehaviour.Initiator,
                questBehaviour.Quest.Name
            });
        }
        int i = 0;

        while (i < this.Prerequisites.Length)
        {
            QuestBehaviourPrerequisites           questBehaviourPrerequisites = this.Prerequisites[i];
            IEnumerable <SimulationObjectWrapper> enumerable = null;
            if (questBehaviourPrerequisites.Target == null)
            {
                enumerable = new SimulationObjectWrapper[1];
            }
            else
            {
                SimulationObjectWrapper targetSimulationObjectWrapper = questBehaviourPrerequisites.GetTargetSimulationObjectWrapper(questBehaviour);
                if (targetSimulationObjectWrapper != null && targetSimulationObjectWrapper.SimulationObject != null)
                {
                    enumerable = new SimulationObjectWrapper[]
                    {
                        targetSimulationObjectWrapper
                    };
                }
                else
                {
                    targets.TryGetValue(questBehaviourPrerequisites.Target, out enumerable);
                }
            }
            if (enumerable != null)
            {
                bool flag = false;
                foreach (SimulationObjectWrapper simulationObjectWrapper in enumerable)
                {
                    if (global::GameManager.Preferences.QuestVerboseMode)
                    {
                        Diagnostics.Log("ELCP: {0} simulationObjectWrapper {1}", new object[]
                        {
                            questBehaviour.Initiator,
                            (simulationObjectWrapper is Garrison) ? (simulationObjectWrapper as Garrison).LocalizedName : simulationObjectWrapper.GetType().ToString()
                        });
                    }
                    flag = false;
                    using (InterpreterContext.InterpreterSession interpreterSession = new InterpreterContext.InterpreterSession(simulationObjectWrapper))
                    {
                        foreach (QuestVariable questVariable in questBehaviour.QuestVariables)
                        {
                            if (questVariable.Object is float)
                            {
                                interpreterSession.Context.Register(questVariable.Name, questVariable.Object);
                            }
                        }
                        int j = 0;
                        while (j < questBehaviourPrerequisites.Prerequisites.Length)
                        {
                            if (!questBehaviourPrerequisites.Prerequisites[j].Check(interpreterSession.Context))
                            {
                                if (global::GameManager.Preferences.QuestVerboseMode)
                                {
                                    Diagnostics.Log("ELCP: context check failed for {0} {1}", new object[]
                                    {
                                        j,
                                        questBehaviourPrerequisites.ToString()
                                    });
                                }
                                if (questBehaviourPrerequisites.AnyTarget)
                                {
                                    flag = true;
                                    break;
                                }
                                return(false);
                            }
                            else
                            {
                                j++;
                            }
                        }
                    }
                    if (!flag && questBehaviourPrerequisites.AnyTarget)
                    {
                        return(true);
                    }
                }
                if (flag)
                {
                    return(false);
                }
                i++;
                continue;
            }
            if (global::GameManager.Preferences.QuestVerboseMode)
            {
                Diagnostics.LogWarning("[Quest] Could not find prerequisite target {0} in quest {1}", new object[]
                {
                    questBehaviourPrerequisites.Target,
                    questBehaviour.Quest.Name
                });
            }
            return(false);
        }
        return(true);
    }
Ejemplo n.º 8
0
 public static void ComputeCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, ConstructibleElement constructible, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn)
 {
     PanelFeatureCost.costByResource.Clear();
     if (constructible.Costs != null)
     {
         if (constructible is TechnologyDefinition && context.SimulationObject.Tags.Contains(FactionTrait.FactionTraitReplicants1) && (constructible as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.OrbUnlock && (constructible as TechnologyDefinition).TechnologyFlags != DepartmentOfScience.ConstructibleElement.TechnologyFlag.KaijuUnlock)
         {
             costString = string.Empty;
             turn       = -1;
             global::Empire empire = context as global::Empire;
             if (empire == null)
             {
                 Diagnostics.LogError("Empire is null.");
                 return;
             }
             DepartmentOfScience agency = empire.GetAgency <DepartmentOfScience>();
             if (agency == null)
             {
                 Diagnostics.LogError("Department of science is null");
                 return;
             }
             float buyOutTechnologyCost = agency.GetBuyOutTechnologyCost(constructible);
             if (buyOutTechnologyCost != 3.40282347E+38f)
             {
                 costString = GuiFormater.FormatInstantCost(empire, buyOutTechnologyCost, DepartmentOfTheTreasury.Resources.EmpireMoney, true, 0);
                 return;
             }
             costString = "-";
             return;
         }
         else
         {
             for (int i = 0; i < constructible.Costs.Length; i++)
             {
                 if (constructible.Costs[i] is PopulationConstructionCost)
                 {
                     PopulationConstructionCost populationConstructionCost = constructible.Costs[i] as PopulationConstructionCost;
                     PanelFeatureCost.AppendCost(SimulationProperties.Population, populationConstructionCost.PopulationValue, true);
                 }
                 else
                 {
                     float productionCostWithBonus = DepartmentOfTheTreasury.GetProductionCostWithBonus(context, constructible, constructible.Costs[i], true);
                     PanelFeatureCost.AppendCost(constructible.Costs[i].ResourceName, productionCostWithBonus, constructible.Costs[i].Instant || constructible.Costs[i].InstantOnCompletion);
                 }
             }
         }
     }
     PanelFeatureCost.GetCostAndTurn(guiService, departmentOfTheTreasury, context, out costString, out turn);
 }
Ejemplo n.º 9
0
    protected override IEnumerator OnShow(params object[] parameters)
    {
        this.CostValue.Text = string.Empty;
        this.TurnValue.Text = string.Empty + GuiFormater.Infinite;
        ICostFeatureProvider provider = this.context as ICostFeatureProvider;

        if (provider != null && provider.Constructible != null && provider.Empire != null)
        {
            DepartmentOfTheTreasury departmentOfTheTreasury = provider.Empire.GetAgency <DepartmentOfTheTreasury>();
            SimulationObjectWrapper context = (provider.Context == null) ? provider.Empire : provider.Context;
            string costString;
            int    turn;
            PanelFeatureCost.ComputeCostAndTurn(base.GuiService, provider.Constructible, departmentOfTheTreasury, context, out costString, out turn);
            this.CostValue.AgeTransform.PixelMarginRight = 0f;
            if (this.DisplayTurnCost)
            {
                this.CostValue.AgeTransform.PixelMarginRight = base.AgeTransform.Width - this.TurnValue.AgeTransform.X - 20f * AgeUtils.CurrentUpscaleFactor();
            }
            this.CostValue.AgeTransform.ComputeExtents(Rect.MinMaxRect(0f, 0f, 0f, 0f));
            this.CostValue.Text = costString;
            this.CostTitle.Text = "%FeatureCostTitle";
            if (provider.Constructible is KaijuTechnologyDefinition)
            {
                KaijuTechnologyDefinition kaijuTechnologyDefinition = provider.Constructible as KaijuTechnologyDefinition;
                IGameService       gameService       = Services.GetService <IGameService>();
                IKaijuTechsService kaijuTechsService = gameService.Game.Services.GetService <IKaijuTechsService>();
                if (kaijuTechsService.GetTechnologyState(kaijuTechnologyDefinition, provider.Empire) == DepartmentOfScience.ConstructibleElement.State.Researched)
                {
                    this.CostTitle.Text = "%FeatureAlreadyUnlockedTitle";
                    costString          = " ";
                }
            }
            this.CostValue.Text = costString;
            if (this.CostValue.AgeTransform.PixelMarginTop == this.CostTitle.AgeTransform.PixelMarginTop)
            {
                float pixelMargin = 2f * this.CostTitle.AgeTransform.PixelMarginLeft + this.CostTitle.Font.ComputeTextWidth(AgeLocalizer.Instance.LocalizeString(this.CostTitle.Text), this.CostTitle.ForceCaps, false);
                this.CostValue.AgeTransform.PixelMarginLeft = pixelMargin;
            }
            if (provider.Context == null)
            {
                this.TurnValue.Text = string.Empty;
                this.TurnIcon.AgeTransform.Visible = false;
            }
            else
            {
                this.TurnIcon.AgeTransform.Visible = true;
                if (turn == 2147483647)
                {
                    this.TurnValue.Text = string.Empty + GuiFormater.Infinite;
                }
                else
                {
                    turn = Mathf.Max(1, turn);
                    this.TurnValue.Text = turn.ToString();
                }
            }
        }
        yield return(base.OnShow(parameters));

        this.CostValue.AgeTransform.Height = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count;
        base.AgeTransform.Height           = this.CostValue.Font.LineHeight * (float)this.CostValue.TextLines.Count + this.CostValue.AgeTransform.PixelMarginTop + this.CostValue.AgeTransform.PixelMarginBottom;
        base.AgeTransform.Visible          = !string.IsNullOrEmpty(this.CostValue.Text);
        if (!this.DisplayTurnCost)
        {
            this.TurnIcon.AgeTransform.Visible  = false;
            this.TurnValue.AgeTransform.Visible = false;
        }
        yield break;
    }
Ejemplo n.º 10
0
    public static void GetCostAndTurn(Amplitude.Unity.Gui.IGuiService guiService, DepartmentOfTheTreasury departmentOfTheTreasury, SimulationObjectWrapper context, out string costString, out int turn)
    {
        turn = 0;
        StringBuilder stringBuilder = new StringBuilder();

        if (PanelFeatureCost.costByResource.Count > 0)
        {
            bool flag = false;
            IDatabase <ResourceDefinition> database = Databases.GetDatabase <ResourceDefinition>(false);
            foreach (KeyValuePair <StaticString, PanelFeatureCost.CostResume> keyValuePair in PanelFeatureCost.costByResource)
            {
                if (keyValuePair.Key == SimulationProperties.Population)
                {
                    stringBuilder.Append(GuiFormater.FormatGui(keyValuePair.Value.Cost, false, true, false, 1));
                    stringBuilder.Append(guiService.FormatSymbol(keyValuePair.Key));
                }
                else if (keyValuePair.Key == DepartmentOfTheTreasury.Resources.FreeBorough)
                {
                    stringBuilder.Append(GuiFormater.FormatGui(keyValuePair.Value.Cost, false, true, false, 1));
                    stringBuilder.Append(guiService.FormatSymbol(keyValuePair.Key));
                    float num;
                    if (!departmentOfTheTreasury.TryGetResourceStockValue(context.SimulationObject, DepartmentOfTheTreasury.Resources.QueuedFreeBorough, out num, true))
                    {
                        Diagnostics.Log("Can't get resource stock value {0} on simulation object {1}.", new object[]
                        {
                            DepartmentOfTheTreasury.Resources.QueuedFreeBorough,
                            context.SimulationObject.Name
                        });
                    }
                    else
                    {
                        stringBuilder.Append(string.Format(AgeLocalizer.Instance.LocalizeString("%CityFreeBoroughsLeft"), num));
                    }
                }
                else
                {
                    float              cost = keyValuePair.Value.Cost;
                    StaticString       key  = keyValuePair.Key;
                    ResourceDefinition resourceDefinition;
                    if (!database.TryGetValue(key, out resourceDefinition))
                    {
                        Diagnostics.LogError("Invalid resource name. The resource {0} does not exist in the resource database.", new object[]
                        {
                            key
                        });
                    }
                    else
                    {
                        string value = guiService.FormatSymbol(resourceDefinition.GetName(departmentOfTheTreasury.Empire));
                        if (!string.IsNullOrEmpty(value))
                        {
                            global::Empire empire = null;
                            if (context is City)
                            {
                                empire = (context as City).Empire;
                            }
                            else if (context is global::Empire)
                            {
                                empire = (context as global::Empire);
                            }
                            if (empire.SimulationObject.Tags.Contains(FactionTrait.FactionTraitMimics2) && key == DepartmentOfTheTreasury.Resources.Production)
                            {
                                ResourceDefinition resourceDefinition2;
                                if (!database.TryGetValue(SimulationProperties.CityGrowth, out resourceDefinition2))
                                {
                                    Diagnostics.LogError("Invalid resource name. The resource {0} does not exist in the resource database.", new object[]
                                    {
                                        key
                                    });
                                    continue;
                                }
                                value = guiService.FormatSymbol(resourceDefinition2.GetName(departmentOfTheTreasury.Empire));
                                if (string.IsNullOrEmpty(value))
                                {
                                    continue;
                                }
                            }
                            float num2;
                            if (!departmentOfTheTreasury.TryGetResourceStockValue(context.SimulationObject, key, out num2, true))
                            {
                                num2 = 0f;
                            }
                            if (keyValuePair.Value.Instant && num2 < cost)
                            {
                                AgeUtils.ColorToHexaKey(Color.red, ref stringBuilder, false);
                                flag = true;
                            }
                            stringBuilder.Append(GuiFormater.FormatGui(cost, false, true, false, 1));
                            stringBuilder.Append(value);
                            if (flag)
                            {
                                stringBuilder.Append("#REVERT#");
                                flag = false;
                            }
                            if (!keyValuePair.Value.Instant)
                            {
                                float num3;
                                if (!departmentOfTheTreasury.TryGetNetResourceValue(context.SimulationObject, key, out num3, true))
                                {
                                    num3 = 0f;
                                }
                                if (cost > num2)
                                {
                                    if (num3 <= 0f)
                                    {
                                        turn = int.MaxValue;
                                    }
                                    else
                                    {
                                        int num4 = Mathf.CeilToInt((cost - num2) / num3);
                                        if (num4 > turn)
                                        {
                                            turn = num4;
                                        }
                                    }
                                }
                            }
                            stringBuilder.Append(" ");
                        }
                    }
                }
            }
        }
        costString = stringBuilder.ToString();
        if (string.IsNullOrEmpty(costString))
        {
            costString = "-";
        }
    }
Ejemplo n.º 11
0
 public static bool CanActivate(BoosterDefinition boosterDefinition, SimulationObjectWrapper context)
 {
     return(Booster.CheckActivationPrerequisites(boosterDefinition, context) && (boosterDefinition.Effects == null || Booster.CanApplyAtLeastOneEffect(boosterDefinition, context)));
 }
Ejemplo n.º 12
0
 protected static bool CanApplyAtLeastOneEffect(BoosterDefinition boosterDefinition, SimulationObjectWrapper context)
 {
     if (boosterDefinition.Effects == null)
     {
         return(false);
     }
     for (int i = 0; i < boosterDefinition.Effects.Length; i++)
     {
         if (Booster.CheckPrerequisites(boosterDefinition.Effects[i], context))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 13
0
 protected static bool CheckActivationPrerequisites(BoosterDefinition boosterDefinition, SimulationObjectWrapper context)
 {
     if (boosterDefinition.Prerequisites == null || boosterDefinition.Prerequisites.Length == 0)
     {
         return(true);
     }
     for (int i = 0; i < boosterDefinition.Prerequisites.Length; i++)
     {
         if (!boosterDefinition.Prerequisites[i].Check(context))
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 14
0
    public Booster(GameEntityGUID boosterGUID, BoosterDefinition boosterDefinition, global::Empire empire, SimulationObjectWrapper context, GameEntityGUID contextGUID, int duration, int instigatorEmpireIndex) : base("Booster#" + boosterGUID)
    {
        this.GUID = boosterGUID;
        this.BoosterDefinition     = boosterDefinition;
        this.empire                = empire;
        this.Duration              = duration;
        this.TurnWhenStarted       = -1;
        this.RemainingTime         = -1;
        this.Context               = context;
        this.TargetGUID            = contextGUID;
        this.InstigatorEmpireIndex = instigatorEmpireIndex;
        IGameService service = Services.GetService <IGameService>();

        if (service != null)
        {
            this.game = (service.Game as global::Game);
        }
        this.simulationDescriptorsDatatable = Databases.GetDatabase <SimulationDescriptor>(false);
    }
Ejemplo n.º 15
0
 public static bool IsTargetValid(BoosterDefinition boosterDefinition, SimulationObjectWrapper context)
 {
     return(boosterDefinition.TargetPath == null || string.IsNullOrEmpty(boosterDefinition.TargetPath.ToString()) || boosterDefinition.TargetPath.IsSimulationObjectValid(context));
 }