Esempio n. 1
0
        protected void OutputForMovement(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, StatsSheetSettings.UnitSetting unitSetting = null)
        {
            UnitAttributes unitAttributes = entityTypeAttributes.Get <UnitAttributes>();

            if (unitAttributes == null)
            {
                return;
            }

            UnitMovementAttributes movement = entityTypeAttributes.Get <UnitMovementAttributes>();

            if (movement == null)
            {
                return;
            }

            using (BeginScope(entityTypeAttributes.Name))
            {
                // Unit Attributes
                Print($"readableName: {unitSetting.readableName}");
                Print($"cu: {unitAttributes.Resource1Cost}");
                Print($"ru: {unitAttributes.Resource2Cost}");
                Print($"time: {unitAttributes.ProductionTime}");
                Print($"pop: {unitAttributes.PopCapCost}");
                Print($"hp: {unitAttributes.MaxHealth}");
                Print($"armor: {unitAttributes.Armour}");
                Print($"sensor: {unitAttributes.SensorRadius}");

                OutputForMovementAttributes(movement, true);
            }
        }
Esempio n. 2
0
        protected void OutputForExperience(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, StatsSheetSettings.UnitSetting unitSetting = null)
        {
            UnitAttributes unitAttributes = entityTypeAttributes.Get <UnitAttributes>();

            if (unitAttributes == null)
            {
                return;
            }

            using (BeginScope(entityTypeAttributes.Name))
            {
                // Unit Attributes
                Print($"readableName: {unitSetting.readableName}");
                Print($"cu: {unitAttributes.Resource1Cost}");
                Print($"ru: {unitAttributes.Resource2Cost}");
                Print($"time: {unitAttributes.ProductionTime}");
                Print($"pop: {unitAttributes.PopCapCost}");
                Print($"hp: {unitAttributes.MaxHealth}");
                Print($"armor: {unitAttributes.Armour}");
                Print($"sensor: {unitAttributes.SensorRadius}");
                Print($"contact: {unitAttributes.ContactRadius}");
                Print($"xp: {unitAttributes.ExperienceValue}");

                // Experience Attributes
                ExperienceAttributes experience = entityTypeAttributes.Get <ExperienceAttributes>();
                if (experience != null)
                {
                    OutputForExperienceAttributes(experience);
                }
            }
        }
Esempio n. 3
0
        protected void OutputForDPS(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, StatsSheetSettings.UnitSetting unitSetting = null)
        {
            UnitAttributes unitAttributes = entityTypeAttributes.Get <UnitAttributes>();

            if (unitAttributes == null)
            {
                return;
            }

            if (unitAttributes.WeaponLoadout.Length == 0 || !(unitSetting.weapons == null || unitSetting.weapons.Length > 0))
            {
                return;
            }

            using (BeginScope(entityTypeAttributes.Name))
            {
                // Unit Attributes
                Print($"readableName: {unitSetting.readableName}");
                Print($"cu: {unitAttributes.Resource1Cost}");
                Print($"ru: {unitAttributes.Resource2Cost}");
                Print($"time: {unitAttributes.ProductionTime}");
                Print($"pop: {unitAttributes.PopCapCost}");
                Print($"hp: {unitAttributes.MaxHealth}");
                Print($"armor: {unitAttributes.Armour}");
                Print($"sensor: {unitAttributes.SensorRadius}");

                // Weapons
                OutputForWeapons(entityTypeCollection, entityTypeAttributes, unitSetting.weapons, true);
            }
        }
Esempio n. 4
0
        private static void rebindWeaponAttributes(EntityTypeAttributes entityType, WeaponAttributesWrapper weaponAttributesWrapper)
        {
            var unitAttributes = entityType.Get <UnitAttributes>();

            if (unitAttributes != null)
            {
                for (var i = 0; i < unitAttributes.WeaponLoadout.Length; i++)
                {
                    var weaponBinding = unitAttributes.WeaponLoadout[i];
                    if (weaponBinding.Weapon.Name == weaponAttributesWrapper.Name)
                    {
                        unitAttributes.WeaponLoadout[i] = new WeaponBinding(
                            weaponID: weaponBinding.WeaponID,
                            weaponBindingIndex: weaponBinding.WeaponBindingIndex,
                            weapon: weaponAttributesWrapper,
                            ammoID: weaponBinding.AmmoID,
                            turretIndex: weaponBinding.TurretIndex,
                            defaultTurretAngleOffsetRadians: weaponBinding.DefaultTurretAngleOffsetRadians,
                            disabledOnSpawn: weaponBinding.DisabledOnSpawn,
                            weaponOffsetFromUnitOrigin: weaponBinding.OffsetFromUnitCenterInLocalSpace,
                            showAmmoOnHUD: weaponBinding.ShowAmmoOnHUD
                            );
                    }
                }
            }
        }
Esempio n. 5
0
        protected void OutputForGeneral(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, StatsSheetSettings.UnitSetting unitSetting = null)
        {
            UnitAttributes unitAttributes = entityTypeAttributes.Get <UnitAttributes>();

            if (unitAttributes == null)
            {
                return;
            }

            using (BeginScope(entityTypeAttributes.Name))
            {
                // Unit Attributes
                Print($"readableName: {unitSetting.readableName}");
                Print($"cu: {unitAttributes.Resource1Cost}");
                Print($"ru: {unitAttributes.Resource2Cost}");
                Print($"time: {unitAttributes.ProductionTime}");
                Print($"pop: {unitAttributes.PopCapCost}");
                Print($"hp: {unitAttributes.MaxHealth}");
                Print($"armor: {unitAttributes.Armour}");
                Print($"sensor: {unitAttributes.SensorRadius}");
                Print($"contact: {unitAttributes.ContactRadius}");
                Print($"xp: {unitAttributes.ExperienceValue}");
                Print($"priorityAsTarget: {unitAttributes.PriorityAsTarget}");

                // Movement Attributes
                UnitMovementAttributes movement = entityTypeAttributes.Get <UnitMovementAttributes>();
                if (movement != null)
                {
                    OutputForMovementAttributes(movement);
                }

                // Harvester Attributes
                HarvesterAttributes harvester = entityTypeAttributes.Get <HarvesterAttributes>();
                if (harvester != null)
                {
                    OutputForHarvesterAttributes(harvester);
                }

                // Weapons
                if (unitAttributes.WeaponLoadout.Length > 0 && (unitSetting.weapons == null || unitSetting.weapons.Length > 0))
                {
                    OutputForWeapons(entityTypeCollection, entityTypeAttributes, unitSetting.weapons);
                }
            }
        }
Esempio n. 6
0
        private void applyCPatch <TAttributes, TWrapper>(
            EntityTypeAttributes entityType, SubsystemPatch patch, Func <TAttributes, TWrapper> createWrapper, string name = null)
            where TAttributes : class
            where TWrapper : TAttributes
        {
            var attributes = name != null?entityType.Get <TAttributes>(name) : entityType.Get <TAttributes>();

            if (attributes == null)
            {
                if (notFoundErrors)
                {
                    logger.Log($"ERROR: {typeof(TAttributes).Name}" + (name != null ? $": {name}" : "") + " not found");
                }
                return;
            }
            using (logger.BeginScope($"{typeof(TAttributes).Name}: {name}"))
            {
                var wrapper = createWrapper(attributes);
                patch.Apply(this, wrapper, entityType);
                entityType.Replace(attributes, wrapper);
            }
        }
Esempio n. 7
0
        private void applyComponentPatch <TPatch, TAttributes, TWrapper>(EntityTypeAttributes entityType, TPatch patch, Func <TAttributes, TWrapper> createWrapper, Action <TPatch, TWrapper> applyPatch, string name = null)
            where TAttributes : class
            where TWrapper : TAttributes
        {
            using (logger.BeginScope($"{typeof(TAttributes).Name}: {name}"))
            {
                var attributes = name != null
                    ? entityType.Get <TAttributes>(name)
                    : entityType.Get <TAttributes>();

                if (attributes == null)
                {
                    logger.Log($"ERROR: {typeof(TAttributes).Name} not found");
                    return;
                }

                var wrapper = createWrapper(attributes);

                applyPatch(patch, wrapper);

                entityType.Replace(attributes, wrapper);
            }
        }
Esempio n. 8
0
        protected void OutputForUpgradeResearch(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes)
        {
            TechTreeAttributes techTreeAttributes = entityTypeAttributes.Get <TechTreeAttributes>();

            for (int i = 0; i < techTreeAttributes.TechTrees.Length; ++i)
            {
                TechTree techTree = techTreeAttributes.TechTrees[i];
                for (int j = 0; j < techTree.Upgrades.Length; ++j)
                {
                    TechUpgrade            upgrade = techTree.Upgrades[j];
                    EntityTypeAttributes   researchItemEntityTypeAttributes = entityTypeCollection.GetEntityType(upgrade.ResearchItem);
                    ResearchItemAttributes researchItemAttributes           = researchItemEntityTypeAttributes.Get <ResearchItemAttributes>();
                    OutputForResearchItem(researchItemAttributes);
                }
            }
        }
Esempio n. 9
0
        protected void OutputForTierResearch(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes)
        {
            TechTreeAttributes techTreeAttributes = entityTypeAttributes.Get <TechTreeAttributes>();

            for (int i = 0; i < techTreeAttributes.TechTrees.Length; ++i)
            {
                TechTree techTree = techTreeAttributes.TechTrees[i];
                for (int j = 0; j < techTree.Tiers.Length; ++j)
                {
                    TechTreeTier tier = techTree.Tiers[j];
                    for (int k = 0; k < tier.ResearchItems.Length; ++k)
                    {
                        EntityTypeAttributes   researchItemEntityTypeAttributes = entityTypeCollection.GetEntityType(tier.ResearchItems[k]);
                        ResearchItemAttributes researchItemAttributes           = researchItemEntityTypeAttributes.Get <ResearchItemAttributes>();
                        OutputForResearchItem(researchItemAttributes);
                    }
                }
            }
        }
Esempio n. 10
0
 protected void OutputForTechTree(EntityTypeAttributes entityTypeAttributes)
 {
     using (BeginScope("entries"))
     {
         TechTreeAttributes techTreeAttributes = entityTypeAttributes.Get <TechTreeAttributes>();
         for (int i = 0; i < techTreeAttributes.TechTrees.Length; ++i)
         {
             TechTree techTree = techTreeAttributes.TechTrees[i];
             using (BeginScope(techTree.TechTreeName))
             {
                 Print($"icon: {techTree.IconSpriteName}");
                 using (BeginScope("tiers"))
                 {
                     for (int j = 0; j < techTree.Tiers.Length; ++j)
                     {
                         TechTreeTier tier = techTree.Tiers[j];
                         using (BeginScope(tier.TierName))
                         {
                             for (int k = 0; k < tier.ResearchItems.Length; ++k)
                             {
                                 Print($"- {tier.ResearchItems[k]}");
                             }
                         }
                     }
                 }
                 using (BeginScope("upgrades"))
                 {
                     for (int j = 0; j < techTree.Upgrades.Length; ++j)
                     {
                         TechUpgrade upgrade = techTree.Upgrades[j];
                         using (BeginScope(upgrade.UpgradeName))
                         {
                             Print($"researchItem: {upgrade.ResearchItem}");
                         }
                     }
                 }
             }
         }
     }
 }