Пример #1
0
 /// <summary>
 /// Primary Constructor for ComponentDesignAbilityDB
 /// </summary>
 /// <param name="expressionString"></param>
 /// <param name="designAbility"></param>
 /// <param name="factionTech"></param>
 /// <param name="staticDataStore"></param>
 internal ChainedExpression(string expressionString, ComponentDesignAbility designAbility, FactionTechDB factionTech, StaticDataStore staticDataStore)
 {
     _staticDataStore = staticDataStore;
     _factionTechDB   = factionTech;
     _design          = designAbility.ParentComponent;
     _designAbility   = designAbility;
     ReplaceExpression(expressionString);
 }
Пример #2
0
 /// <summary>
 /// a private constructor that is used internaly for a one use Expression
 /// </summary>
 /// <param name="expression"></param>
 /// <param name="designAbility"></param>
 /// <param name="factionTech"></param>
 /// <param name="staticDataStore"></param>
 private ChainedExpression(Expression expression, ComponentDesignAbility designAbility, FactionTechDB factionTech, StaticDataStore staticDataStore)
 {
     _staticDataStore = staticDataStore;
     _factionTechDB   = factionTech;
     _design          = designAbility.ParentComponent;
     _designAbility   = designAbility;
     _expression      = expression;
     SetupExpression();
 }
Пример #3
0
        /// <summary>
        /// takes a ComponentSD staticData and turns it into a DesignDB
        /// </summary>
        /// <param name="component">the componentSD</param>
        /// <param name="factionTech">this factions TechDB</param>
        /// <param name="staticData">the game staticData</param>
        /// <returns></returns>
        public static ComponentDesign StaticToDesign(ComponentTemplateSD component, FactionTechDB factionTech, StaticDataStore staticData)
        {
            ComponentDesign design = new ComponentDesign();

            design.Name        = component.Name;
            design.Description = component.Description;

            design.MassFormula         = new ChainedExpression(component.MassFormula, design, factionTech, staticData);
            design.VolumeFormula       = new ChainedExpression(component.VolumeFormula, design, factionTech, staticData);
            design.CrewFormula         = new ChainedExpression(component.CrewReqFormula, design, factionTech, staticData);
            design.HTKFormula          = new ChainedExpression(component.HTKFormula, design, factionTech, staticData);
            design.ResearchCostFormula = new ChainedExpression(component.ResearchCostFormula, design, factionTech, staticData);
            design.BuildCostFormula    = new ChainedExpression(component.BuildPointCostFormula, design, factionTech, staticData);
            design.MineralCostFormulas = new Dictionary <Guid, ChainedExpression>();
            design.CreditCostFormula   = new ChainedExpression(component.CreditCostFormula, design, factionTech, staticData);
            design.ComponentMountType  = component.MountType;
            design.ConstructionType    = component.ConstructionType;
            design.CargoTypeID         = component.CargoTypeID;

            foreach (var kvp in component.MineralCostFormula)
            {
                design.MineralCostFormulas.Add(kvp.Key, new ChainedExpression(kvp.Value, design, factionTech, staticData));
            }

            design.ComponentDesignAbilities = new List <ComponentDesignAbility>();
            foreach (var abilitySD in component.ComponentAbilitySDs)
            {
                ComponentDesignAbility designAbility = new ComponentDesignAbility(design);

                designAbility.Name        = abilitySD.Name;
                designAbility.Description = abilitySD.Description;
                designAbility.GuiHint     = abilitySD.GuiHint;

                if (abilitySD.AbilityFormula != null)
                {
                    designAbility.Formula = new ChainedExpression(abilitySD.AbilityFormula, designAbility, factionTech, staticData);
                }

                if (abilitySD.GuidDictionary != null)
                {
                    designAbility.GuidDictionary = new Dictionary <object, ChainedExpression>();
                    if (designAbility.GuiHint == GuiHint.GuiTechSelectionList)
                    {
                        foreach (var kvp in abilitySD.GuidDictionary)
                        {
                            if (factionTech.ResearchedTechs.ContainsKey(Guid.Parse(kvp.Key.ToString())))
                            {
                                TechSD techSD = staticData.Techs[Guid.Parse(kvp.Key.ToString())];
                                designAbility.GuidDictionary.Add(kvp.Key, new ChainedExpression(TechProcessor.DataFormula(factionTech, techSD).ToString(), designAbility, factionTech, staticData));
                            }
                        }
                    }
                    else
                    {
                        foreach (var kvp in abilitySD.GuidDictionary)
                        {
                            designAbility.GuidDictionary.Add(kvp.Key, new ChainedExpression(kvp.Value, designAbility, factionTech, staticData));
                        }
                    }
                }
                if (designAbility.GuiHint == GuiHint.GuiSelectionMaxMin)
                {
                    designAbility.MaxValueFormula  = new ChainedExpression(abilitySD.MaxFormula, designAbility, factionTech, staticData);
                    designAbility.MinValueFormula  = new ChainedExpression(abilitySD.MinFormula, designAbility, factionTech, staticData);
                    designAbility.StepValueFormula = new ChainedExpression(abilitySD.StepFormula, designAbility, factionTech, staticData);
                }
                if (abilitySD.AbilityDataBlobType != null)
                {
                    designAbility.DataBlobType = Type.GetType(abilitySD.AbilityDataBlobType);
                }

                design.ComponentDesignAbilities.Add(designAbility);
            }

            design.MassFormula.Evaluate();
            design.SetCrew();
            design.SetHTK();
            design.SetResearchCost();
            design.SetBuildCost();
            design.SetMineralCosts();

            return(design);
        }