Remove projectile and missile projectile configuration from ModuleWeaponGunManager
This commit is contained in:
@@ -9,10 +9,6 @@ namespace TerraTech {
|
|||||||
new MultipliedObjectManager<ModuleWeaponGun>(ConfigureManager);
|
new MultipliedObjectManager<ModuleWeaponGun>(ConfigureManager);
|
||||||
private static readonly MultipliedObjectManager<FireData> fireDataManager =
|
private static readonly MultipliedObjectManager<FireData> fireDataManager =
|
||||||
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
new MultipliedObjectManager<FireData>(ConfigureFireData);
|
||||||
private static readonly MultipliedObjectManager<Projectile> projectileManager =
|
|
||||||
new MultipliedObjectManager<Projectile>(ConfigureProjectile);
|
|
||||||
private static readonly MultipliedObjectManager<MissileProjectile> missileProjectileManager =
|
|
||||||
new MultipliedObjectManager<MissileProjectile>(ConfigureMissileProjectile);
|
|
||||||
|
|
||||||
public static ConfigEntry<bool> playerOnly;
|
public static ConfigEntry<bool> playerOnly;
|
||||||
public static ConfigEntry<float> kickbackStrengthMultiplier;
|
public static ConfigEntry<float> kickbackStrengthMultiplier;
|
||||||
@@ -22,9 +18,6 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> shotCooldownMultiplier;
|
public static ConfigEntry<float> shotCooldownMultiplier;
|
||||||
public static ConfigEntry<bool> seekingRoundsAll;
|
public static ConfigEntry<bool> seekingRoundsAll;
|
||||||
public static ConfigEntry<bool> resetBurstOnInterruptAll;
|
public static ConfigEntry<bool> resetBurstOnInterruptAll;
|
||||||
public static ConfigEntry<float> projectileLifetimeMultiplier;
|
|
||||||
public static ConfigEntry<float> missileProjectileBoosterLifetimeMultiplier;
|
|
||||||
public static ConfigEntry<bool> projectileExplodeOnStickAll;
|
|
||||||
|
|
||||||
public static void Setup(ConfigFile config) {
|
public static void Setup(ConfigFile config) {
|
||||||
float min = 0.01f;
|
float min = 0.01f;
|
||||||
@@ -67,22 +60,6 @@ namespace TerraTech {
|
|||||||
"FireData", "Reset Burst On Interrupt All", false,
|
"FireData", "Reset Burst On Interrupt All", false,
|
||||||
new ConfigDescription("Reset Burst On Interrupt All", new AcceptableValueRange<bool>(false, true)));
|
new ConfigDescription("Reset Burst On Interrupt All", new AcceptableValueRange<bool>(false, true)));
|
||||||
resetBurstOnInterruptAll.SettingChanged += (sender, args) => DoPatch();
|
resetBurstOnInterruptAll.SettingChanged += (sender, args) => DoPatch();
|
||||||
|
|
||||||
projectileLifetimeMultiplier = config.Bind(
|
|
||||||
"Projectile", "Lifetime Multiplier", 1f,
|
|
||||||
new ConfigDescription("Projectile Lifetime Multiplier", new AcceptableValueRange<float>(min, max)));
|
|
||||||
projectileLifetimeMultiplier.SettingChanged += (sender, args) => DoPatch();
|
|
||||||
|
|
||||||
missileProjectileBoosterLifetimeMultiplier =
|
|
||||||
config.Bind("MissileProjectile", "Booster Lifetime Multiplier", 1f,
|
|
||||||
new ConfigDescription("Missile Projectile Booster Lifetime Multiplier",
|
|
||||||
new AcceptableValueRange<float>(min, max)));
|
|
||||||
missileProjectileBoosterLifetimeMultiplier.SettingChanged += (sender, args) => DoPatch();
|
|
||||||
|
|
||||||
projectileExplodeOnStickAll = config.Bind(
|
|
||||||
"Projectile", "Explode On Stick All", false,
|
|
||||||
new ConfigDescription("Projectile Explode On Stick All", new AcceptableValueRange<bool>(false, true)));
|
|
||||||
projectileExplodeOnStickAll.SettingChanged += (sender, args) => DoPatch();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureManager(MultipliedObject<ModuleWeaponGun> obj) {
|
private static void ConfigureManager(MultipliedObject<ModuleWeaponGun> obj) {
|
||||||
@@ -99,16 +76,6 @@ namespace TerraTech {
|
|||||||
obj.AddField(new FieldConfiguration<float, float>("m_KickbackStrength", kickbackStrengthMultiplier));
|
obj.AddField(new FieldConfiguration<float, float>("m_KickbackStrength", kickbackStrengthMultiplier));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ConfigureProjectile(MultipliedObject<Projectile> obj) {
|
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_Lifetime", projectileLifetimeMultiplier));
|
|
||||||
obj.AddField(new FieldConfiguration<bool, bool>("m_ExplodeOnStick", projectileExplodeOnStickAll));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConfigureMissileProjectile(MultipliedObject<MissileProjectile> obj) {
|
|
||||||
obj.AddField(new FieldConfiguration<float, float>("m_MaxBoosterLifetime",
|
|
||||||
missileProjectileBoosterLifetimeMultiplier));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly Func<object, bool> ShouldApply = obj => {
|
private static readonly Func<object, bool> ShouldApply = obj => {
|
||||||
if (!playerOnly.Value)
|
if (!playerOnly.Value)
|
||||||
return true;
|
return true;
|
||||||
@@ -124,20 +91,7 @@ namespace TerraTech {
|
|||||||
|
|
||||||
var trav = Traverse.Create(__instance);
|
var trav = Traverse.Create(__instance);
|
||||||
var firingData = trav.Field("m_FiringData");
|
var firingData = trav.Field("m_FiringData");
|
||||||
var projectile = trav.Field("m_BulletPrefab");
|
|
||||||
var projectileType = projectile.GetValueType();
|
|
||||||
var isMissileProjectile = projectileType == typeof(MissileProjectile);
|
|
||||||
|
|
||||||
fireDataManager.OnObjectAttached(firingData.GetValue<FireData>());
|
fireDataManager.OnObjectAttached(firingData.GetValue<FireData>());
|
||||||
if (isMissileProjectile) {
|
|
||||||
var mproj = projectile.GetValue<MissileProjectile>();
|
|
||||||
if (mproj != null)
|
|
||||||
missileProjectileManager.OnObjectAttached(mproj);
|
|
||||||
} else {
|
|
||||||
var proj = projectile.GetValue<Projectile>();
|
|
||||||
if (proj != null)
|
|
||||||
projectileManager.OnObjectAttached(proj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
@@ -149,28 +103,12 @@ namespace TerraTech {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var firingData = trav.Field("m_FiringData");
|
var firingData = trav.Field("m_FiringData");
|
||||||
var projectile = trav.Field("m_BulletPrefab");
|
|
||||||
var projectileType = projectile.GetValueType();
|
|
||||||
var isMissileProjectile = projectileType == typeof(MissileProjectile);
|
|
||||||
|
|
||||||
fireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
fireDataManager.OnObjectDetached(firingData.GetValue<FireData>());
|
||||||
manager.OnObjectDetached(__instance);
|
|
||||||
if (isMissileProjectile) {
|
|
||||||
var mproj = projectile.GetValue<MissileProjectile>();
|
|
||||||
if (mproj != null)
|
|
||||||
missileProjectileManager.OnObjectDetached(mproj);
|
|
||||||
} else {
|
|
||||||
var proj = projectile.GetValue<Projectile>();
|
|
||||||
if (proj != null)
|
|
||||||
projectileManager.OnObjectDetached(proj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DoPatch() {
|
public static void DoPatch() {
|
||||||
fireDataManager.ApplyAll();
|
fireDataManager.ApplyAll();
|
||||||
manager.ApplyAll();
|
manager.ApplyAll();
|
||||||
projectileManager.ApplyAll();
|
|
||||||
missileProjectileManager.ApplyAll();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user