using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DM;
using HarmonyLib;
using SwingTrail;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SwingTrail")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Geezt Jeez")]
[assembly: AssemblyProduct("SFT by FhpSlime")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("SwingTrail")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
public class SwingTrailFunction : AttackEffect
{
private MeleeWeapon meleeWeapon;
public AnimationCurve animationCurve;
private GameObject curTrail;
private GameObject summonParentPositionObject;
public void Start()
{
if (Loader.Enabled)
{
meleeWeapon = ((Component)this).GetComponentInChildren<MeleeWeapon>();
if ((Object)(object)((Component)this).GetComponentInChildren<ForcePoint>() != (Object)null)
{
summonParentPositionObject = ((Component)((Component)this).GetComponentInChildren<ForcePoint>()).gameObject;
}
if (meleeWeapon.canDealDamageOutSideOfSwing)
{
TrailRenderer obj = summonParentPositionObject.AddComponent<TrailRenderer>();
obj.time = Loader.TrailTime;
((Renderer)obj).material = GetMaterial();
obj.widthMultiplier = GetTrailSize();
obj.widthCurve = animationCurve;
}
}
}
public void Update()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (Loader.Enabled && Object.op_Implicit((Object)(object)curTrail) && Object.op_Implicit((Object)(object)summonParentPositionObject))
{
curTrail.transform.position = summonParentPositionObject.transform.position;
if (!meleeWeapon.isSwinging)
{
ReleaseTrails();
}
}
}
public void ReleaseTrails()
{
if (Object.op_Implicit((Object)(object)curTrail))
{
curTrail = null;
}
}
public Material GetMaterial()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
Material val = new Material(Shader.Find("Standard"))
{
name = "SwingTrailMaterial",
color = new Color(Loader.TrailBrightness, Loader.TrailBrightness, Loader.TrailBrightness, Loader.TrailOpacity)
};
val.SetOverrideTag("RenderType", "Transparent");
val.EnableKeyword("_ALPHABLEND_ON");
val.SetInt("_DstBlend", 10);
val.SetInt("_SrcBlend", 5);
val.SetFloat("_Mode", 3f);
val.renderQueue = 3000;
return val;
}
public static GameObject InstantiateEmpty(string name, Vector3 position, Quaternion rotation, Transform parent)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
GameObject val = new GameObject(name);
val.transform.position = position;
val.transform.rotation = rotation;
val.transform.parent = parent;
return val;
}
public override void DoEffect(Rigidbody target, Vector3 targetDir)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
if (Loader.Enabled)
{
if (Object.op_Implicit((Object)(object)summonParentPositionObject))
{
SetTrail("SwingTrail", summonParentPositionObject.transform.position);
}
else if (Object.op_Implicit((Object)(object)meleeWeapon))
{
SetTrail("SwingTrail", ((Component)meleeWeapon).gameObject.transform.position);
}
}
}
public float GetTrailSize()
{
float num = Loader.TrailSize;
CollisionWeapon val = default(CollisionWeapon);
if (Loader.DamageBased && ((Component)this).TryGetComponent<CollisionWeapon>(ref val))
{
num += ((Component)this).gameObject.GetComponentInChildren<CollisionWeapon>().damage / 500f;
}
return num;
}
public void SetTrail(string name, Vector3 position)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
curTrail = InstantiateEmpty(name, position, Quaternion.identity, null);
TrailRenderer obj = curTrail.AddComponent<TrailRenderer>();
obj.time = Loader.TrailTime;
((Renderer)obj).material = GetMaterial();
obj.widthMultiplier = GetTrailSize();
obj.widthCurve = animationCurve;
RemoveAfterSeconds obj2 = curTrail.AddComponent<RemoveAfterSeconds>();
obj2.seconds = Loader.TrailTime * 4f;
obj2.shrink = true;
}
}
namespace SwingTrail;
[BepInPlugin("BepInEx.SwingTrail", "SwingTrail", "1.0.9")]
internal class Loader : BaseUnityPlugin
{
private static ConfigEntry<float> configTrailSize;
private static ConfigEntry<float> configTrailOpacity;
private static ConfigEntry<float> configTrailBrightness;
private static ConfigEntry<bool> configEnableMod;
private static ConfigEntry<bool> configUseDamage;
private static ConfigEntry<float> configTrailTime;
public bool debug;
public static bool Enabled => configEnableMod.Value;
public static float TrailSize => configTrailSize.Value;
public static float TrailOpacity => configTrailOpacity.Value;
public static float TrailBrightness => configTrailBrightness.Value;
public static float TrailTime => configTrailTime.Value;
public static bool DamageBased => configUseDamage.Value;
private void Awake()
{
((MonoBehaviour)this).StartCoroutine("Call");
}
private IEnumerator Call()
{
yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
yield return (object)new WaitForSeconds(1f);
SLMALoader.GetInstance();
_ = ContentDatabase.Instance().LandfallContentDatabase;
new Harmony("SwingTrail").PatchAll();
Debug.Log((object)"Loading Swing Trail...");
GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
MeleeWeapon val3 = default(MeleeWeapon);
for (int i = 0; i < array.Length; i++)
{
if (Object.op_Implicit((Object)(object)array[i].GetComponentInChildren<MeleeWeapon>()))
{
GameObject val = array[i];
if (debug)
{
Debug.Log((object)("Trying to add Swing Trail for " + ((Object)val).name));
}
AnimationCurve val2 = new AnimationCurve();
val2.AddKey(0f, 0f);
val2.AddKey(0.25f, 0.75f);
val2.AddKey(1f, 0f);
if (val.TryGetComponent<MeleeWeapon>(ref val3))
{
val.AddComponent<SwingTrailFunction>().animationCurve = val2;
}
}
}
DoConfig();
((MonoBehaviour)this).StartCoroutine(GenerateSettings());
Debug.Log((object)"Loaded Swing Trail Successfully!");
}
private IEnumerator GenerateSettings()
{
GlobalSettingsHandler service = null;
yield return (object)new WaitUntil((Func<bool>)(() => Object.op_Implicit((Object)(object)(service = ServiceLocator.GetService<GlobalSettingsHandler>()))));
List<SettingsInstance> list = service.GameplaySettings.ToList();
SettingsInstance val2 = new SettingsInstance();
val2.settingsType = (SettingsType)0;
val2.options = new string[2] { "On", "Off" };
val2.currentValue = ((!configEnableMod.Value) ? 1 : 0);
val2.m_settingsKey = "Use Swing Trail";
val2.toolTip = "Enables Swing Trail mod.";
SettingsInstance val3 = val2;
val3.OnValueChanged += delegate(int val)
{
configEnableMod.Value = val == 0;
};
list.Add(val3);
val2 = new SettingsInstance();
val2.settingsType = (SettingsType)0;
val2.options = new string[2] { "On", "Off" };
val2.currentValue = ((!configUseDamage.Value) ? 1 : 0);
val2.m_settingsKey = "Damage Based";
val2.toolTip = "Turn trail size to be also based off weapon damage.";
SettingsInstance val4 = val2;
val4.OnValueChanged += delegate(int val)
{
configUseDamage.Value = val == 0;
};
list.Add(val4);
SettingsInstance val5 = new SettingsInstance
{
currentSliderValue = configTrailSize.Value,
defaultSliderValue = 1f,
max = 2f,
min = 0f,
m_settingsKey = "Trail Size",
settingsType = (SettingsType)1,
toolTip = "Determines the size of trail. (default: 1)"
};
val5.OnSliderValueChanged += delegate(float val)
{
configTrailSize.Value = val;
};
list.Add(val5);
SettingsInstance val6 = new SettingsInstance
{
currentSliderValue = configTrailOpacity.Value,
defaultSliderValue = 1.25f,
max = 1.5f,
min = 0f,
m_settingsKey = "Trail Opacity",
settingsType = (SettingsType)1,
toolTip = "Determines the opacity of trail. (default: 1.25)"
};
val6.OnSliderValueChanged += delegate(float val)
{
configTrailOpacity.Value = val;
};
list.Add(val6);
SettingsInstance val7 = new SettingsInstance
{
currentSliderValue = configTrailBrightness.Value,
defaultSliderValue = 0.4f,
max = 1f,
min = 0f,
m_settingsKey = "Trail Brightness",
settingsType = (SettingsType)1,
toolTip = "Determines the brightness of trail. (default: 0.4)"
};
val7.OnSliderValueChanged += delegate(float val)
{
configTrailBrightness.Value = val;
};
list.Add(val7);
SettingsInstance val8 = new SettingsInstance
{
currentSliderValue = configTrailTime.Value,
defaultSliderValue = 1f,
max = 10f,
min = 0f,
m_settingsKey = "Trail Duration",
settingsType = (SettingsType)1,
toolTip = "Determines the duration of trail. (default: 1)"
};
val8.OnSliderValueChanged += delegate(float val)
{
configTrailTime.Value = val;
};
list.Add(val8);
((object)service).GetType().GetField("m_gameplaySettings", (BindingFlags)(-1)).SetValue(service, list.ToArray());
}
private void DoConfig()
{
configEnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable Fat Maker Mod");
configUseDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DamageBased", true, "Enables Damage Size");
configTrailSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TrailSize", 1f, "Determines the size of trail");
configTrailOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TrailOpacity", 0.75f, "Determines the opacity of trail");
configTrailBrightness = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TrailBrightness", 0.4f, "Determines the brightness of trail");
configTrailTime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TrailTime", 1f, "Determines the duration of trail");
}
}