23 lines
1.0 KiB
C#
23 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using HarmonyLib;
|
|
using UnityEngine;
|
|
|
|
namespace TerraTech {
|
|
[HarmonyPatch(typeof(Projectile), "Fire")]
|
|
public class HomingAndVelocityProjectilePatch {
|
|
private static Dictionary<FireData, float> velocities = new Dictionary<FireData, float>();
|
|
|
|
static void Prefix(Vector3 fireDirection, ref FireData fireData, ref ModuleWeaponGun weapon, Tank shooter,
|
|
ref bool seekingRounds, bool replayRounds) {
|
|
if (Main.allProjectilesHoming.Value) {
|
|
seekingRounds = true;
|
|
}
|
|
if (!velocities.ContainsKey(fireData)) {
|
|
velocities.Add(fireData, fireData.m_MuzzleVelocity);
|
|
fireData.m_MuzzleVelocity *= Main.muzzleVelocityMultiplier.Value;
|
|
} else if (velocities[fireData] != fireData.m_MuzzleVelocity * Main.muzzleVelocityMultiplier.Value) {
|
|
fireData.m_MuzzleVelocity = velocities[fireData] * Main.muzzleVelocityMultiplier.Value;
|
|
}
|
|
}
|
|
}
|
|
} |