private void applyNamedCPatch <TAttributes, TWrapper, TSubsystemPatch>( EntityTypeAttributes entityType, Dictionary <string, TSubsystemPatch> patch, Func <TAttributes, TWrapper> createWrapper) where TAttributes : class where TWrapper : TAttributes where TSubsystemPatch : SubsystemPatch { foreach (var kvp in patch) { if (kvp.Key != "Any") { applyCPatch(entityType, kvp.Value, createWrapper, kvp.Key); } } if (patch.ContainsKey("Any")) { TSubsystemPatch anyPatch = patch["Any"]; foreach (var attributes in entityType.GetAll <TAttributes>()) { if (attributes is INamed a) { applyCPatch(entityType, anyPatch, createWrapper, a.Name); } } } }
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]}"); } } } } } } } } }
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."); }