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> seekingProjectileVisionConeAngleMultiplier;
|
||||||
public static ConfigEntry<float> seekingProjectileVisionRangeMultiplier;
|
public static ConfigEntry<float> seekingProjectileVisionRangeMultiplier;
|
||||||
public static ConfigEntry<float> seekingProjectileTurningSpeedMultiplier;
|
public static ConfigEntry<float> seekingProjectileTurningSpeedMultiplier;
|
||||||
|
public static ConfigEntry<bool> projectileExplodeOnStick;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
debug = Config.Bind("General", "Debug", false);
|
debug = Config.Bind("General", "Debug", false);
|
||||||
@@ -65,6 +66,9 @@ namespace TerraTech {
|
|||||||
Config.Bind("Weapons", "Seeking Projectile Turn Speed Multiplier", 1f,
|
Config.Bind("Weapons", "Seeking Projectile Turn Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Seeking Projectile Turn Speed Multiplier",
|
new ConfigDescription("Seeking Projectile Turn Speed Multiplier",
|
||||||
new AcceptableValueRange<float>(min, max)));
|
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");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
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")]
|
[HarmonyPatch(typeof(SeekingProjectile), "OnSpawn")]
|
||||||
class Patch {
|
class Patch {
|
||||||
static void Postfix(SeekingProjectile __instance) {
|
static void Postfix(SeekingProjectile __instance) {
|
||||||
Console.WriteLine("SeekingProjectile created");
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("SeekingProjectile created");
|
||||||
|
|
||||||
SetField(
|
SetField(
|
||||||
__instance, "m_VisionConeAngle",
|
__instance, "m_VisionConeAngle",
|
||||||
Main.seekingProjectileVisionConeAngleMultiplier.Value * GetField(__instance, "m_VisionConeAngle"));
|
Main.seekingProjectileVisionConeAngleMultiplier.Value * GetField(__instance, "m_VisionConeAngle"));
|
||||||
|
@@ -58,6 +58,7 @@
|
|||||||
<Compile Include="CykUtil.cs" />
|
<Compile Include="CykUtil.cs" />
|
||||||
<Compile Include="ModuleHeartManager.cs" />
|
<Compile Include="ModuleHeartManager.cs" />
|
||||||
<Compile Include="ModuleFuelTankManager.cs" />
|
<Compile Include="ModuleFuelTankManager.cs" />
|
||||||
|
<Compile Include="ProjectilePatch.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<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