Add projectile explode on stick configuration option
This commit is contained in:
@@ -21,6 +21,7 @@ namespace TerraTech {
|
||||
public static ConfigEntry<float> seekingProjectileVisionConeAngleMultiplier;
|
||||
public static ConfigEntry<float> seekingProjectileVisionRangeMultiplier;
|
||||
public static ConfigEntry<float> seekingProjectileTurningSpeedMultiplier;
|
||||
public static ConfigEntry<bool> projectileExplodeOnStick;
|
||||
|
||||
public void Awake() {
|
||||
debug = Config.Bind("General", "Debug", false);
|
||||
@@ -65,6 +66,9 @@ namespace TerraTech {
|
||||
Config.Bind("Weapons", "Seeking Projectile Turn Speed Multiplier", 1f,
|
||||
new ConfigDescription("Seeking Projectile Turn Speed Multiplier",
|
||||
new AcceptableValueRange<float>(min, max)));
|
||||
projectileExplodeOnStick = Config.Bind(
|
||||
"Weapons", "Projectile Explode On Stick", false,
|
||||
new ConfigDescription("Projectile Explode On Stick", new AcceptableValueRange<bool>(false, true)));
|
||||
|
||||
Logger.LogInfo("Cyka mod loaded");
|
||||
HarmonyFileLog.Enabled = true;
|
||||
|
22
Projects/TerraTech/TerraTech/ProjectilePatch.cs
Normal file
22
Projects/TerraTech/TerraTech/ProjectilePatch.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace TerraTech {
|
||||
[HarmonyPatch]
|
||||
public class ProjectilePatch {
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(Projectile), "StickToObjectWithVisuals")]
|
||||
static void Prefix(Projectile __instance) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Projectile created");
|
||||
var trav = Traverse.Create(__instance);
|
||||
var explodeOnStick = trav.Field("m_ExplodeOnStick");
|
||||
|
||||
if (!explodeOnStick.GetValue<bool>()) {
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("Exploding on stick");
|
||||
explodeOnStick.SetValue(Main.projectileExplodeOnStick.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -6,7 +6,9 @@ namespace TerraTech {
|
||||
[HarmonyPatch(typeof(SeekingProjectile), "OnSpawn")]
|
||||
class Patch {
|
||||
static void Postfix(SeekingProjectile __instance) {
|
||||
Console.WriteLine("SeekingProjectile created");
|
||||
if (Main.debug.Value)
|
||||
Console.WriteLine("SeekingProjectile created");
|
||||
|
||||
SetField(
|
||||
__instance, "m_VisionConeAngle",
|
||||
Main.seekingProjectileVisionConeAngleMultiplier.Value * GetField(__instance, "m_VisionConeAngle"));
|
||||
@@ -25,4 +27,4 @@ namespace TerraTech {
|
||||
Traverse.Create(seekingProjectile).Field(field).SetValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -58,6 +58,7 @@
|
||||
<Compile Include="CykUtil.cs" />
|
||||
<Compile Include="ModuleHeartManager.cs" />
|
||||
<Compile Include="ModuleFuelTankManager.cs" />
|
||||
<Compile Include="ProjectilePatch.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="0Harmony">
|
||||
|
@@ -1 +1 @@
|
||||
wgo -dir TerraTech -debounce 1s echo "Formatters" :: clang-format -i TerraTech/*.cs
|
||||
clang-format -i TerraTech/*.cs
|
||||
|
Reference in New Issue
Block a user