Exemplo n.º 1
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);
                }
            }
        }
Exemplo n.º 2
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);
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void ApplyAttributesPatch(EntityTypeCollection entityTypeCollection, AttributesPatch attributesPatch)
        {
            foreach (var kvp in attributesPatch.Entities)
            {
                var entityTypeName  = kvp.Key;
                var entityTypePatch = kvp.Value;

                var entityType = entityTypeCollection.GetEntityType(entityTypeName);

                using (logger.BeginScope($"EntityType: {entityTypeName}"))
                {
                    if (entityType == null)
                    {
                        logger.Log($"NOTICE: EntityType not found");
                        continue;
                    }

                    applyUnnamedComponentPatch <ExperienceAttributesPatch, ExperienceAttributes, ExperienceAttributesWrapper>(entityType, entityTypePatch.ExperienceAttributes, x => new ExperienceAttributesWrapper(x), ApplyExperienceAttributesPatch);
                    applyUnnamedComponentPatch <UnitAttributesPatch, UnitAttributes, UnitAttributesWrapper>(entityType, entityTypePatch.UnitAttributes, x => new UnitAttributesWrapper(x), ApplyUnitAttributesPatch);
                    applyUnnamedComponentPatch <ResearchItemAttributesPatch, ResearchItemAttributes, ResearchItemAttributesWrapper>(entityType, entityTypePatch.ResearchItemAttributes, x => new ResearchItemAttributesWrapper(x), ApplyResearchItemAttributesPatch);
                    applyUnnamedComponentPatch <UnitHangarAttributesPatch, UnitHangarAttributes, UnitHangarAttributesWrapper>(entityType, entityTypePatch.UnitHangarAttributes, x => new UnitHangarAttributesWrapper(x), ApplyUnitHangarAttributesPatch);
                    applyUnnamedComponentPatch <DetectableAttributesPatch, DetectableAttributes, DetectableAttributesWrapper>(entityType, entityTypePatch.DetectableAttributes, x => new DetectableAttributesWrapper(x), ApplyDetectableAttributesPatch);
                    applyUnnamedComponentPatch <UnitMovementAttributesPatch, UnitMovementAttributes, UnitMovementAttributesWrapper>(entityType, entityTypePatch.UnitMovementAttributes, x => new UnitMovementAttributesWrapper(x), ApplyUnitMovementAttributesPatch);

                    applyNamedComponentPatch <AbilityAttributesPatch, AbilityAttributes, AbilityAttributesWrapper>(entityType, entityTypePatch.AbilityAttributes, x => new AbilityAttributesWrapper(x), ApplyAbilityAttributesPatch);
                    applyNamedComponentPatch <StorageAttributesPatch, StorageAttributes, StorageAttributesWrapper>(entityType, entityTypePatch.StorageAttributes, x => new StorageAttributesWrapper(x), ApplyStorageAttributesPatch);
                    applyNamedComponentPatch <WeaponAttributesPatch, WeaponAttributes, WeaponAttributesWrapper>(entityType, entityTypePatch.WeaponAttributes, x => new WeaponAttributesWrapper(x), (patch, wrapper) =>
                    {
                        ApplyWeaponAttributesPatch(patch, wrapper);
                        rebindWeaponAttributes(entityType, wrapper);
                    });
                }
            }

            File.WriteAllText(Path.Combine(Application.dataPath, "Subsystem.log"), writer.ToString());
            Debug.Log($"[SUBSYSTEM] Applied attributes patch. See Subsystem.log for details.");
        }
Exemplo n.º 4
0
        public void Generate(EntityTypeCollection entityTypeCollection)
        {
            System.Text.StringBuilder sb = writer.GetStringBuilder();

            indent = 0;

            // Tech / Research
            using (BeginScope("techTrees"))
            {
                foreach (var treeName in settings.TechTrees)
                {
                    using (BeginScope(treeName))
                    {
                        EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(treeName);
                        if (entityTypeAttributes != null)
                        {
                            OutputForTechTree(entityTypeAttributes);
                        }
                    }
                }
            }
            using (BeginScope("tierResearch"))
            {
                foreach (var treeName in settings.TechTrees)
                {
                    using (BeginScope(treeName))
                    {
                        EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(treeName);
                        if (entityTypeAttributes != null)
                        {
                            OutputForTierResearch(entityTypeCollection, entityTypeAttributes);
                        }
                    }
                }
            }
            using (BeginScope("upgradeResearch"))
            {
                foreach (var treeName in settings.TechTrees)
                {
                    using (BeginScope(treeName))
                    {
                        EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(treeName);
                        if (entityTypeAttributes != null)
                        {
                            OutputForUpgradeResearch(entityTypeCollection, entityTypeAttributes);
                        }
                    }
                }
            }
            File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameResearch), writer.ToString());
            sb.Remove(0, sb.Length);

            // General
            foreach (var kvp in settings.UnitList)
            {
                EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(kvp.Key);
                if (entityTypeAttributes != null)
                {
                    OutputForGeneral(entityTypeCollection, entityTypeAttributes, kvp.Value);
                }
            }
            File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameGeneral), writer.ToString());
            sb.Remove(0, sb.Length);

            // Carrier
            foreach (var kvp in settings.CarrierList)
            {
                EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(kvp.Key);
                if (entityTypeAttributes != null)
                {
                    OutputForCarrier(entityTypeCollection, entityTypeAttributes, kvp.Value);
                }
            }
            File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameCarrier), writer.ToString());
            sb.Remove(0, sb.Length);

            // Experience
            foreach (var kvp in settings.UnitList)
            {
                EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(kvp.Key);
                if (entityTypeAttributes != null)
                {
                    OutputForExperience(entityTypeCollection, entityTypeAttributes, kvp.Value);
                }
            }
            File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameExperience), writer.ToString());
            sb.Remove(0, sb.Length);

            // Movement
            foreach (var kvp in settings.UnitList)
            {
                EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(kvp.Key);
                if (entityTypeAttributes != null)
                {
                    OutputForMovement(entityTypeCollection, entityTypeAttributes, kvp.Value);
                }
            }
            File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameMovement), writer.ToString());
            sb.Remove(0, sb.Length);

            // DPS
            foreach (var kvp in settings.UnitList)
            {
                EntityTypeAttributes entityTypeAttributes = entityTypeCollection.GetEntityType(kvp.Key);
                if (entityTypeAttributes != null)
                {
                    OutputForDPS(entityTypeCollection, entityTypeAttributes, kvp.Value);
                }
            }
            File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameDPS), writer.ToString());
            sb.Remove(0, sb.Length);

            // Other

            /*using (BeginScope("ranges"))
             * {
             *      WeaponRange[] allRanges = (WeaponRange[])Enum.GetValues(typeof(WeaponRange));
             *      for (int i = 0; i < allRanges.Length; ++i)
             *              Print($"{allRanges[i]}");
             * }
             * using (BeginScope("falloffTypes"))
             * {
             *      AOEFalloffType[] allFallofftypes = (AOEFalloffType[])Enum.GetValues(typeof(AOEFalloffType));
             *      for (int i = 0; i < allFallofftypes.Length; ++i)
             *              Print($"{allFallofftypes[i]}");
             * }
             * File.WriteAllText(Path.Combine(Application.dataPath, settings.FilenameOther), writer.ToString());
             * sb.Remove(0, sb.Length);*/
        }
Exemplo n.º 5
0
        protected void OutputForWeapons(EntityTypeCollection entityTypeCollection, EntityTypeAttributes entityTypeAttributes, string[] selectedWeapons, bool dps = false)
        {
            using (BeginScope("weapons"))
            {
                WeaponAttributes[] weaponAttributes = entityTypeAttributes.GetAll <WeaponAttributes>();
                for (int i = 0; i < weaponAttributes.Length; ++i)
                {
                    WeaponAttributes w = weaponAttributes[i];
                    if (selectedWeapons == null || Array.IndexOf(selectedWeapons, w.Name) >= 0)
                    {
                        using (BeginScope(w.Name))
                        {
                            Print($"damageType: {w.DamageType}");
                            Print($"dmg: {w.BaseDamagePerRound}");
                            Print($"packets: {w.DamagePacketsPerShot}");
                            Print($"excludeFromHighGround: {w.ExcludeFromHeightAdvantage}");
                            Print($"lineOfSightRequired: {w.LineOfSightRequired}");
                            Print($"friendlyFireDamageScalar: {w.FriendlyFireDamageScalar}");
                            Print($"leadsTarget: {w.LeadsTarget}");
                            Print($"windUp: {w.WindUpTimeMS}");
                            Print($"windDown: {w.WindDownTimeMS}");
                            Print($"rof: {w.RateOfFire}");
                            Print($"burstMin: {w.BurstPeriodMinTimeMS}");
                            Print($"burstMax: {w.BurstPeriodMaxTimeMS}");
                            Print($"numBursts: {w.NumberOfBursts}");
                            Print($"cooldown: {w.CooldownTimeMS}");
                            Print($"reload: {w.ReloadTimeMS}");
                            Print($"aoe: {w.AreaOfEffectRadius}");
                            Print($"falloff: {Enum.GetName(typeof(AOEFalloffType), w.AreaOfEffectFalloffType)}");

                            using (BeginScope($"ranges"))
                            {
                                foreach (var r in w.Ranges)
                                {
                                    using (BeginScope(Enum.GetName(typeof(WeaponRange), r.Range)))
                                    {
                                        Print($"distance: {r.Distance}");
                                        Print($"accuracy: {r.Accuracy}");
                                    }
                                }
                            }

                            if (!dps)
                            {
                                using (BeginScope($"turret"))
                                {
                                    Print($"fieldOfView: {w.Turret.FieldOfView}");
                                    Print($"fieldOfFire: {w.Turret.FieldOfFire}");
                                    Print($"rotationSpeed: {w.Turret.RotationSpeed}");
                                }

                                if (w.Modifiers.Length > 0)
                                {
                                    using (BeginScope($"modifiers"))
                                    {
                                        for (int j = 0; j < w.Modifiers.Length; ++j)
                                        {
                                            WeaponModifierInfo modifierInfo = w.Modifiers[j];
                                            using (BeginScope(j.ToString()))
                                            {
                                                Print($"targetClass: {modifierInfo.TargetClass}");
                                                Print($"classOperator: {modifierInfo.ClassOperator}");
                                                Print($"modifierType: {modifierInfo.Modifier}");
                                                Print($"amount: {modifierInfo.Amount}");
                                            }
                                        }
                                    }
                                }
                                if (w.StatusEffectsSets.Length > 0)
                                {
                                    Print($"statusEffectsExcludeTargetType: {w.StatusEffectsExcludeTargetType}");
                                    Print($"statusEffectsTargetAlignment: {w.StatusEffectsTargetAlignment}");
                                    using (BeginScope("statusEffectSets"))
                                    {
                                        for (int j = 0; j < w.StatusEffectsSets.Length; ++j)
                                        {
                                            for (int k = 0; k < w.StatusEffectsSets[j].StatusEffects.Length; ++k)
                                            {
                                                using (BeginScope(w.StatusEffectsSets[j].StatusEffects[k]))
                                                {
                                                    EntityTypeAttributes     seEntityTypeAttributes = entityTypeCollection.GetEntityType(w.StatusEffectsSets[j].StatusEffects[k]);
                                                    StatusEffectAttributes[] statusEffectAttributes = seEntityTypeAttributes.GetAll <StatusEffectAttributes>();
                                                    if (statusEffectAttributes.Length > 0)
                                                    {
                                                        OutputForStatusEffect(statusEffectAttributes[0]);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            WeaponDPSInfo weaponDPSInfo = new WeaponDPSInfo(w);
                            using (BeginScope("dpsInfo"))
                            {
                                Print($"avgShots: {weaponDPSInfo.AverageShotsPerBurst}");
                                Print($"trueROF: {weaponDPSInfo.TrueROF}");
                                Print($"sequenceDuration: {weaponDPSInfo.SequenceDuration}");
                                if (dps)
                                {
                                    using (BeginScope("dpsVsArmor"))
                                    {
                                        int[] armorVals = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 18, 21, 25, 50, 75, 100 };
                                        for (int j = 0; j < armorVals.Length; ++j)
                                        {
                                            using (BeginScope(armorVals[j].ToString()))
                                            {
                                                double armorDPS = weaponDPSInfo.ArmorDPS(armorVals[j]);
                                                Print($"dpsBeforeAccuracy: {armorDPS}");

                                                using (BeginScope("accuracyDps"))
                                                {
                                                    Dictionary <WeaponRange, double> rangeDPS = weaponDPSInfo.RangeDPS(armorDPS);
                                                    foreach (RangeBasedWeaponAttributes r in w.Ranges)
                                                    {
                                                        Print($"{Enum.GetName(typeof(WeaponRange), r.Range)}: {rangeDPS[r.Range]}");
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    double armorDPS = weaponDPSInfo.ArmorDPS(0);
                                    Print($"dpsBeforeAccuracy: {armorDPS}");

                                    using (BeginScope("accuracyDps"))
                                    {
                                        Dictionary <WeaponRange, double> rangeDPS = weaponDPSInfo.RangeDPS(armorDPS);
                                        foreach (RangeBasedWeaponAttributes r in w.Ranges)
                                        {
                                            Print($"{Enum.GetName(typeof(WeaponRange), r.Range)}: {rangeDPS[r.Range]}");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void ApplyAttributesPatch(EntityTypeCollection entityTypeCollection, AttributesPatch attributesPatch)
        {
            logger.Log("[ APPLYING ENTITY TYPE ATTRIBUTES ]");

            foreach (var kvp in attributesPatch.Entities)
            {
                string          entityTypeName  = kvp.Key;
                EntityTypePatch entityTypePatch = kvp.Value;

                EntityTypeAttributes entityType;
                if (!entityTypePatch.CloneFrom.IsNullOrEmpty())
                {
                    EntityTypeAttributes toClone = entityTypeCollection.GetEntityType(entityTypePatch.CloneFrom);
                    if (toClone == null)
                    {
                        logger.Log($"ERROR: CloneFrom {entityTypePatch.CloneFrom} attributes not found");
                        continue;
                    }

                    entityType = new EntityTypeAttributes(entityTypeName)
                    {
                        Flags = toClone.Flags
                    };

                    var attributes = toClone.GetAll <object>();
                    foreach (var w in attributes)
                    {
                        entityType.Add(w);
                    }

                    entityTypeCollection.Add(entityType);

                    logger.BeginScope($"Cloned {entityTypeName} from {entityTypePatch.CloneFrom}").Dispose();
                }
                else
                {
                    entityType = entityTypeCollection.GetEntityType(entityTypeName);
                }

                using (logger.BeginScope($"EntityType: {entityTypeName}"))
                {
                    if (entityType == null)
                    {
                        if (entityTypePatch.CloneFrom.IsNullOrEmpty())
                        {
                            logger.Log("NOTICE: EntityType not found");
                        }
                        else
                        {
                            logger.Log("ERROR: Entity cloning failed");
                        }
                        continue;
                    }

                    ApplyEntityTypePatch(entityType, entityTypePatch);
                }
            }

            if (attributesPatch.Global != null)
            {
                logger.Log("[ APPLYING GLOBAL TYPE ATTRIBUTES ]");
                //logger.enable = false;
                notFoundErrors = false;
                foreach (var kvp in entityTypeCollection.GetAllEntityTypeNames())
                {
                    using (logger.BeginScope($"{kvp}:"))
                    {
                        ApplyEntityTypePatch(entityTypeCollection.GetEntityType(kvp), attributesPatch.Global);
                    }
                }
                //logger.enable = true;
                notFoundErrors = true;
            }

            Debug.Log($"[SUBSYSTEM] Applied attributes patch. See Subsystem.log for details.");
        }