public void ApplyWeaponAttributesPatch(WeaponAttributesPatch weaponAttributesPatch, WeaponAttributesWrapper weaponAttributesWrapper) { applyPropertyPatch(weaponAttributesPatch.ExcludeFromAutoTargetAcquisition, () => weaponAttributesWrapper.ExcludeFromAutoTargetAcquisition); applyPropertyPatch(weaponAttributesPatch.ExcludeFromAutoFire, () => weaponAttributesWrapper.ExcludeFromAutoFire); applyPropertyPatch(weaponAttributesPatch.ExcludeFromHeightAdvantage, () => weaponAttributesWrapper.ExcludeFromHeightAdvantage); applyPropertyPatch(weaponAttributesPatch.DamageType, () => weaponAttributesWrapper.DamageType); applyPropertyPatch(weaponAttributesPatch.IsTracer, () => weaponAttributesWrapper.IsTracer); applyPropertyPatch(weaponAttributesPatch.TracerSpeed, () => weaponAttributesWrapper.TracerSpeed, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(weaponAttributesPatch.TracerLength, () => weaponAttributesWrapper.TracerLength, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(weaponAttributesPatch.BaseDamagePerRound, () => weaponAttributesWrapper.BaseDamagePerRound, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(weaponAttributesPatch.BaseWreckDamagePerRound, () => weaponAttributesWrapper.BaseWreckDamagePerRound, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(weaponAttributesPatch.FiringRecoil, () => weaponAttributesWrapper.FiringRecoil); applyPropertyPatch(weaponAttributesPatch.WindUpTimeMS, () => weaponAttributesWrapper.WindUpTimeMS); applyPropertyPatch(weaponAttributesPatch.RateOfFire, () => weaponAttributesWrapper.RateOfFire); applyPropertyPatch(weaponAttributesPatch.NumberOfBursts, () => weaponAttributesWrapper.NumberOfBursts); applyPropertyPatch(weaponAttributesPatch.DamagePacketsPerShot, () => weaponAttributesWrapper.DamagePacketsPerShot); applyPropertyPatch(weaponAttributesPatch.BurstPeriodMinTimeMS, () => weaponAttributesWrapper.BurstPeriodMinTimeMS); applyPropertyPatch(weaponAttributesPatch.BurstPeriodMaxTimeMS, () => weaponAttributesWrapper.BurstPeriodMaxTimeMS); applyPropertyPatch(weaponAttributesPatch.CooldownTimeMS, () => weaponAttributesWrapper.CooldownTimeMS); applyPropertyPatch(weaponAttributesPatch.WindDownTimeMS, () => weaponAttributesWrapper.WindDownTimeMS); applyPropertyPatch(weaponAttributesPatch.ReloadTimeMS, () => weaponAttributesWrapper.ReloadTimeMS); applyPropertyPatch(weaponAttributesPatch.LineOfSightRequired, () => weaponAttributesWrapper.LineOfSightRequired); applyPropertyPatch(weaponAttributesPatch.LeadsTarget, () => weaponAttributesWrapper.LeadsTarget); applyPropertyPatch(weaponAttributesPatch.KillSkipsUnitDeathSequence, () => weaponAttributesWrapper.KillSkipsUnitDeathSequence); applyPropertyPatch(weaponAttributesPatch.RevealTriggers, () => weaponAttributesWrapper.RevealTriggers); applyPropertyPatch(weaponAttributesPatch.UnitStatusAttackingTriggers, () => weaponAttributesWrapper.UnitStatusAttackingTriggers); applyPropertyPatch(weaponAttributesPatch.TargetStyle, () => weaponAttributesWrapper.TargetStyle); applyWeaponModifiers(weaponAttributesPatch, weaponAttributesWrapper); applyPropertyPatch(weaponAttributesPatch.AreaOfEffectFalloffType, () => weaponAttributesWrapper.AreaOfEffectFalloffType); applyPropertyPatch(weaponAttributesPatch.AreaOfEffectRadius, () => weaponAttributesWrapper.AreaOfEffectRadius, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(weaponAttributesPatch.ExcludeWeaponOwnerFromAreaOfEffect, () => weaponAttributesWrapper.ExcludeWeaponOwnerFromAreaOfEffect); applyPropertyPatch(weaponAttributesPatch.FriendlyFireDamageScalar, () => weaponAttributesWrapper.FriendlyFireDamageScalar, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(weaponAttributesPatch.WeaponOwnerFriendlyFireDamageScalar, () => weaponAttributesWrapper.WeaponOwnerFriendlyFireDamageScalar, x => Fixed64.UnsafeFromDouble(x)); if (weaponAttributesPatch.Turret != null) { using (logger.BeginScope($"Turret:")) { var turret = weaponAttributesWrapper.Turret; var turretWrapper = new TurretAttributesWrapper(turret); ApplyTurretAttributesPatch(weaponAttributesPatch.Turret, turretWrapper); weaponAttributesWrapper.Turret = turretWrapper; } } applyRangeAttributes(WeaponRange.Short, weaponAttributesPatch.RangeAttributesShort, weaponAttributesWrapper); applyRangeAttributes(WeaponRange.Medium, weaponAttributesPatch.RangeAttributesMedium, weaponAttributesWrapper); applyRangeAttributes(WeaponRange.Long, weaponAttributesPatch.RangeAttributesLong, weaponAttributesWrapper); applyPropertyPatch(weaponAttributesPatch.ProjectileEntityTypeToSpawn, () => weaponAttributesWrapper.ProjectileEntityTypeToSpawn); applyPropertyPatch(weaponAttributesPatch.StatusEffectsTargetAlignment, () => weaponAttributesWrapper.StatusEffectsTargetAlignment); applyPropertyPatch(weaponAttributesPatch.StatusEffectsExcludeTargetType, () => weaponAttributesWrapper.StatusEffectsExcludeTargetType); applyPropertyPatch(weaponAttributesPatch.ActiveStatusEffectsIndex, () => weaponAttributesWrapper.ActiveStatusEffectsIndex); applyEntityTypesToSpawnOnImpact(weaponAttributesPatch, weaponAttributesWrapper); if (weaponAttributesPatch.TargetPrioritizationAttributes != null) { using (logger.BeginScope($"TargetPrioritizationAttributes:")) { var targetPrioritizationWrapper = new TargetPriorizationAttributesWrapper(weaponAttributesWrapper.TargetPriorizationAttributes); ApplyTargetPrioritizationAttributesPatch(weaponAttributesPatch.TargetPrioritizationAttributes, targetPrioritizationWrapper); weaponAttributesWrapper.TargetPriorizationAttributes = targetPrioritizationWrapper; } } }
public void ApplyTurretAttributesPatch(TurretAttributesPatch turretPatch, TurretAttributesWrapper turretWrapper) { applyPropertyPatch(turretPatch.FieldOfFire, () => turretWrapper.FieldOfFire, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(turretPatch.FieldOfView, () => turretWrapper.FieldOfView, x => Fixed64.UnsafeFromDouble(x)); applyPropertyPatch(turretPatch.RotationSpeed, () => turretWrapper.RotationSpeed, x => Fixed64.UnsafeFromDouble(x)); }
protected override void Apply(AttributeLoader loader, object wrapperObj) { if (!(wrapperObj is WeaponAttributesWrapper w)) { throw new System.InvalidCastException(); } loader.ApplyPPatch(TracerSpeed, () => w.TracerSpeed, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(TracerSpeedMult, () => w.TracerSpeed); loader.ApplyPPatch(TracerLength, () => w.TracerLength, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(TracerLengthMult, () => w.TracerLength); loader.ApplyPPatch(BaseDamagePerRound, () => w.BaseDamagePerRound, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(BaseDamagePerRoundMult, () => w.BaseDamagePerRound); loader.ApplyPPatch(BaseWreckDamagePerRound, () => w.BaseWreckDamagePerRound, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(BaseWreckDamagePerRoundMult, () => w.BaseWreckDamagePerRound); loader.ApplyPPatch(FiringRecoil, () => w.FiringRecoil); loader.ApplyPMultPatch(FiringRecoilMult, () => w.FiringRecoil); loader.ApplyPPatch(WindUpTimeMS, () => w.WindUpTimeMS); loader.ApplyPMultPatch(WindUpTimeMSMult, () => w.WindUpTimeMS); loader.ApplyPPatch(RateOfFire, () => w.RateOfFire); loader.ApplyPMultPatch(RateOfFireMult, () => w.RateOfFire); loader.ApplyPPatch(NumberOfBursts, () => w.NumberOfBursts); loader.ApplyPMultPatch(NumberOfBurstsMult, () => w.NumberOfBursts); loader.ApplyPPatch(DamagePacketsPerShot, () => w.DamagePacketsPerShot); loader.ApplyPMultPatch(DamagePacketsPerShotMult, () => w.DamagePacketsPerShot); loader.ApplyPPatch(BurstPeriodMinTimeMS, () => w.BurstPeriodMinTimeMS); loader.ApplyPMultPatch(BurstPeriodMinTimeMSMult, () => w.BurstPeriodMinTimeMS); loader.ApplyPPatch(BurstPeriodMaxTimeMS, () => w.BurstPeriodMaxTimeMS); loader.ApplyPMultPatch(BurstPeriodMaxTimeMSMult, () => w.BurstPeriodMaxTimeMS); loader.ApplyPPatch(CooldownTimeMS, () => w.CooldownTimeMS); loader.ApplyPMultPatch(CooldownTimeMSMult, () => w.CooldownTimeMS); loader.ApplyPPatch(WindDownTimeMS, () => w.WindDownTimeMS); loader.ApplyPMultPatch(WindDownTimeMSMult, () => w.WindDownTimeMS); loader.ApplyPPatch(ReloadTimeMS, () => w.ReloadTimeMS); loader.ApplyPMultPatch(ReloadTimeMSMult, () => w.ReloadTimeMS); loader.ApplyPPatch(AreaOfEffectRadius, () => w.AreaOfEffectRadius, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(AreaOfEffectRadiusMult, () => w.AreaOfEffectRadius); loader.ApplyPPatch(FriendlyFireDamageScalar, () => w.FriendlyFireDamageScalar, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(FriendlyFireDamageScalarMult, () => w.FriendlyFireDamageScalar); loader.ApplyPPatch(WeaponOwnerFriendlyFireDamageScalar, () => w.WeaponOwnerFriendlyFireDamageScalar, Fixed64.UnsafeFromDouble); loader.ApplyPMultPatch(WeaponOwnerFriendlyFireDamageScalarMult, () => w.WeaponOwnerFriendlyFireDamageScalar); loader.ApplyPPatch(ExcludeFromAutoTargetAcquisition, () => w.ExcludeFromAutoTargetAcquisition); loader.ApplyPPatch(ExcludeFromAutoFire, () => w.ExcludeFromAutoFire); loader.ApplyPPatch(ExcludeFromHeightAdvantage, () => w.ExcludeFromHeightAdvantage); loader.ApplyPPatch(DamageType, () => w.DamageType); loader.ApplyPPatch(IsTracer, () => w.IsTracer); loader.ApplyPPatch(LineOfSightRequired, () => w.LineOfSightRequired); loader.ApplyPPatch(LeadsTarget, () => w.LeadsTarget); loader.ApplyPPatch(KillSkipsUnitDeathSequence, () => w.KillSkipsUnitDeathSequence); loader.ApplyPPatch(RevealTriggers, () => w.RevealTriggers); loader.ApplyPPatch(UnitStatusAttackingTriggers, () => w.UnitStatusAttackingTriggers); loader.ApplyPPatch(TargetStyle, () => w.TargetStyle); loader.ApplyPPatch(ActiveStatusEffectsIndex, () => w.ActiveStatusEffectsIndex); if (Modifiers != null) { var l = w.Modifiers?.Select(x => new WeaponModifierInfoWrapper(x)).ToList() ?? new List <WeaponModifierInfoWrapper>(); loader.ApplyLPatch(Modifiers, l, () => new WeaponModifierInfoWrapper(), nameof(WeaponModifierInfo)); w.Modifiers = l.ToArray(); } loader.ApplyPPatch(AreaOfEffectFalloffType, () => w.AreaOfEffectFalloffType); loader.ApplyPPatch(ExcludeWeaponOwnerFromAreaOfEffect, () => w.ExcludeWeaponOwnerFromAreaOfEffect); if (Turret != null) { using (loader.logger.BeginScope($"Turret:")) { var w2 = new TurretAttributesWrapper(w.Turret); Turret.Apply(loader, w2, null); w.Turret = w2; } } ApplyRangeAttributes(loader, WeaponRange.Short, RangeAttributesShort, w); ApplyRangeAttributes(loader, WeaponRange.Medium, RangeAttributesMedium, w); ApplyRangeAttributes(loader, WeaponRange.Long, RangeAttributesLong, w); loader.ApplyPPatch(ProjectileEntityTypeToSpawn, () => w.ProjectileEntityTypeToSpawn); loader.ApplyPPatch(StatusEffectsTargetAlignment, () => w.StatusEffectsTargetAlignment); loader.ApplyPPatch(StatusEffectsExcludeTargetType, () => w.StatusEffectsExcludeTargetType); if (StatusEffectsSets != null) { var l = w.StatusEffectsSets?.Select(x => new StatusEffectsSetAttributesWrapper(x)).ToList() ?? new List <StatusEffectsSetAttributesWrapper>(); loader.ApplyLPatch(StatusEffectsSets, l, () => new StatusEffectsSetAttributesWrapper(), nameof(StatusEffectsSetAttributes)); w.StatusEffectsSets = l.Where(x => x != null).ToArray(); } if (TargetPrioritizationAttributes != null) { using (loader.logger.BeginScope($"TargetPrioritizationAttributes:")) { var w2 = new TargetPriorizationAttributesWrapper(w.TargetPriorizationAttributes); TargetPrioritizationAttributes.Apply(loader, w2, null); w.TargetPriorizationAttributes = w2; } } if (EntityTypesToSpawnOnImpact != null) { var l = w.EntityTypesToSpawnOnImpact?.Select(x => new EntityTypeToSpawnAttributesWrapper(x)).ToList() ?? new List <EntityTypeToSpawnAttributesWrapper>(); loader.ApplyLPatch(EntityTypesToSpawnOnImpact, l, () => new EntityTypeToSpawnAttributesWrapper(), nameof(EntityTypeToSpawnAttributes)); w.EntityTypesToSpawnOnImpact = l.Where(x => x != null).ToArray(); } if (OutputDPS == true) { OutputWeaponDPS(loader, w); } }