using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.Json.Serialization;
using AK;
using Agents;
using AssetShards;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using ExtraSyringeCustomization.Converters;
using ExtraSyringeCustomization.Packets;
using ExtraSyringeCustomization.Properties;
using ExtraSyringeCustomization.Properties.BuiltIn;
using ExtraSyringeCustomization.Registries;
using ExtraSyringeCustomization.Utils;
using FX_EffectSystem;
using Flaff.Collections.Registries;
using GTFO.API;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using MTFO.Managers;
using Microsoft.CodeAnalysis;
using MovementSpeedAPI;
using Player;
using SNetwork;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ExtraSyringeCustomization")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ExtraSyringeCustomization")]
[assembly: AssemblyTitle("ExtraSyringeCustomization")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ExtraSyringeCustomization
{
public class CustomSyringeDefinition : IRegisterable
{
[CompilerGenerated]
private sealed class <ActivateSequence>d__13 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CustomSyringeDefinition <>4__this;
public PlayerAgent player;
public SyringeFirstPerson syringe;
public Random random;
private SyringePropertyBase[] <properties>5__2;
private int <index>5__3;
private int <propertyCount>5__4;
private List<SyringePropertyBase> <batch>5__5;
private List<(IEnumerator, SyringePropertyBase)> <batchSequences>5__6;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ActivateSequence>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<properties>5__2 = null;
<batch>5__5 = null;
<batchSequences>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
CustomSyringeDefinition customSyringeDefinition = <>4__this;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
goto IL_021d;
}
<>1__state = -1;
<properties>5__2 = customSyringeDefinition.Properties.GetProperties();
<index>5__3 = 0;
<propertyCount>5__4 = <properties>5__2.Length;
<batch>5__5 = new List<SyringePropertyBase>(<propertyCount>5__4);
goto IL_0250;
IL_021d:
if (<batchSequences>5__6.Count > 0)
{
int num2 = 0;
while (num2 < <batchSequences>5__6.Count)
{
var (enumerator, syringePropertyBase) = <batchSequences>5__6[num2];
try
{
if (!enumerator.MoveNext())
{
<batchSequences>5__6.RemoveAt(num2);
}
else
{
num2++;
}
}
catch (Exception value)
{
L.Error($"Error whilst processing property '{syringePropertyBase.Name}' on player {player.PlayerName} with syringe ID {customSyringeDefinition.SyringeID}: {value}");
<batchSequences>5__6.RemoveAt(num2);
}
}
<>2__current = null;
<>1__state = 1;
return true;
}
<batch>5__5.Clear();
<index>5__3++;
<batchSequences>5__6 = null;
goto IL_0250;
IL_0250:
while (true)
{
if (<index>5__3 < <propertyCount>5__4)
{
SyringePropertyBase item = <properties>5__2[<index>5__3];
<batch>5__5.Add(item);
if (<index>5__3 + 1 >= <propertyCount>5__4 || <properties>5__2[<index>5__3].Timing.IsRelativeToPreviousProperties)
{
break;
}
<index>5__3++;
continue;
}
return false;
}
<batchSequences>5__6 = new List<(IEnumerator, SyringePropertyBase)>();
foreach (SyringePropertyBase item2 in <batch>5__5)
{
<batchSequences>5__6.Add((customSyringeDefinition.CreatePropertySequence(player, syringe, item2, random), item2));
}
goto IL_021d;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <CreatePropertyInnerSequence>d__15 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringePropertyBase property;
public Random random;
public SyringePropertySequenceInfo info;
public PlayerAgent player;
public SyringeFirstPerson syringe;
private double <delay>5__2;
private double <t>5__3;
private IEnumerator <sequence>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreatePropertyInnerSequence>d__15(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<sequence>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<delay>5__2 = property.Timing.Delay.GetValue(random);
<t>5__3 = 0.0;
goto IL_0083;
case 1:
<>1__state = -1;
<t>5__3 += info.DeltaTime;
goto IL_0083;
case 2:
{
<>1__state = -1;
break;
}
IL_0083:
if (<t>5__3 < <delay>5__2 && !info.ForceComplete)
{
<>2__current = null;
<>1__state = 1;
return true;
}
if (info.ForceComplete)
{
return false;
}
<sequence>5__4 = property.Apply(player, syringe, random, info);
break;
}
if (<sequence>5__4.MoveNext())
{
<>2__current = <sequence>5__4.Current;
<>1__state = 2;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <CreatePropertySequence>d__14 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public CustomSyringeDefinition <>4__this;
public PlayerAgent player;
public SyringeFirstPerson syringe;
public SyringePropertyBase property;
public Random random;
private SyringePropertySequenceInfo <info>5__2;
private IEnumerator <enumerator>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreatePropertySequence>d__14(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<info>5__2 = null;
<enumerator>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Invalid comparison between Unknown and I4
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
int num = <>1__state;
CustomSyringeDefinition customSyringeDefinition = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<info>5__2 = new SyringePropertySequenceInfo();
if ((int)GameStateManager.CurrentStateName != 10)
{
<info>5__2.ForceCompletion();
}
<enumerator>5__3 = customSyringeDefinition.CreatePropertyInnerSequence(player, syringe, property, random, <info>5__2);
break;
case 1:
<>1__state = -1;
break;
}
if (<enumerator>5__3.MoveNext() && !<info>5__2.ForceComplete)
{
if ((int)GameStateManager.CurrentStateName != 10)
{
<info>5__2.ForceCompletion();
}
<>2__current = <enumerator>5__3.Current;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public uint SyringeID { get; set; }
public string? DebugName { get; set; }
public SyringePropertyList Properties { get; set; }
public CustomSyringeDefinition()
{
Properties = new SyringePropertyList();
}
[IteratorStateMachine(typeof(<ActivateSequence>d__13))]
internal IEnumerator ActivateSequence(PlayerAgent player, SyringeFirstPerson syringe, Random random)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ActivateSequence>d__13(0)
{
<>4__this = this,
player = player,
syringe = syringe,
random = random
};
}
[IteratorStateMachine(typeof(<CreatePropertySequence>d__14))]
private IEnumerator CreatePropertySequence(PlayerAgent player, SyringeFirstPerson syringe, SyringePropertyBase property, Random random)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreatePropertySequence>d__14(0)
{
<>4__this = this,
player = player,
syringe = syringe,
property = property,
random = random
};
}
[IteratorStateMachine(typeof(<CreatePropertyInnerSequence>d__15))]
private IEnumerator CreatePropertyInnerSequence(PlayerAgent player, SyringeFirstPerson syringe, SyringePropertyBase property, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreatePropertyInnerSequence>d__15(0)
{
player = player,
syringe = syringe,
property = property,
random = random,
info = info
};
}
string IRegisterable.GetID()
{
return CustomSyringeRegistry.SyringeIDToRegistryID(SyringeID);
}
}
public sealed class ExtraSyringeHandler : MonoBehaviour
{
private class SyringeWrapper
{
private enum SyringeState
{
NONE,
SETUP,
INJECT,
CLEANUP
}
private readonly Random m_random;
private readonly _ApplySyringe_d__18 m_enumerator;
private readonly SyringeFirstPerson m_instance;
private readonly CustomSyringeDefinition? m_syringe;
private SyringeState m_state;
public SyringeWrapper(_ApplySyringe_d__18 enumerator)
{
m_random = new Random();
m_enumerator = enumerator;
m_instance = enumerator.__4__this;
SyringeRegistryHandler.Syringes.TryGetEntry(((GameDataBlockBase<ItemDataBlock>)(object)((Item)m_instance).ItemDataBlock).persistentID, out m_syringe);
m_state = SyringeState.NONE;
}
public bool Equals(SyringeFirstPerson other)
{
return ((Il2CppObjectBase)m_instance).Pointer == ((Il2CppObjectBase)other).Pointer;
}
public bool Equals(SyringeWrapper other)
{
return ((Il2CppObjectBase)m_enumerator).Pointer == ((Il2CppObjectBase)other.m_enumerator).Pointer;
}
public bool Equals(_ApplySyringe_d__18 other)
{
return ((Il2CppObjectBase)m_enumerator).Pointer == ((Il2CppObjectBase)other).Pointer;
}
public void OnUnWield()
{
RemoveFromWrappers();
if (m_state == SyringeState.INJECT)
{
Cleanup();
}
}
public bool OnMoveNext(ref bool result)
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
m_state++;
SyringeFirstPerson instance = m_instance;
L.Debug("MoveNext Syringe (" + ((GameDataBlockBase<ItemDataBlock>)(object)((Item)instance).ItemDataBlock).persistentID + ") " + m_state);
if (m_syringe != null)
{
if (m_state == SyringeState.SETUP)
{
return true;
}
if (m_state == SyringeState.INJECT)
{
((Item)instance).Owner.FPItemHolder.ItemHiddenTrigger = true;
Current.StartCoroutine(m_syringe.ActivateSequence(((Item)instance).Owner, instance, m_random));
m_enumerator.__2__current = (Object)new WaitForSeconds(0.7f);
result = true;
return false;
}
if (m_state == SyringeState.CLEANUP)
{
RemoveFromWrappers();
Cleanup();
result = false;
return false;
}
}
else
{
L.Debug("Custom Syringe was null!");
}
return true;
}
private void RemoveFromWrappers()
{
for (int i = 0; i < s_syringeWrappers.Count; i++)
{
if (s_syringeWrappers[i].Equals(this))
{
s_syringeWrappers.RemoveAt(i);
break;
}
}
}
private void Cleanup()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)m_instance == (Object)null))
{
FirstPersonItemHolder fPItemHolder = ((ItemEquippable)m_instance).FPItemHolder;
if (fPItemHolder != null)
{
fPItemHolder.AnimationSequenceEnd();
}
pItemData_Custom customData = ((Item)m_instance).GetCustomData();
if ((customData.ammo -= 1f) <= 0.01f)
{
ItemDataBlock itemDataBlock = ((Item)m_instance).ItemDataBlock;
PlayerBackpackManager.ClearLocalSlot((InventorySlot)((itemDataBlock == null) ? 5 : ((int)itemDataBlock.inventorySlot)), true, true);
}
else
{
((Item)m_instance).SetCustomData(customData, true);
}
m_instance.m_applyTriggered = false;
}
}
}
private static ExtraSyringeHandler? s_current;
private static readonly List<SyringeWrapper> s_syringeWrappers;
public static string ConfigPath { get; internal set; }
public static ExtraSyringeHandler Current
{
get
{
//IL_000d: 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_0022: Expected O, but got Unknown
if ((Object)(object)s_current == (Object)null)
{
GameObject val = new GameObject();
s_current = val.AddComponent<ExtraSyringeHandler>();
Object.DontDestroyOnLoad((Object)val);
}
return s_current;
}
}
static ExtraSyringeHandler()
{
s_syringeWrappers = new List<SyringeWrapper>();
ConfigPath = "";
ClassInjector.RegisterTypeInIl2Cpp<ExtraSyringeHandler>();
}
[HideFromIl2Cpp]
public Coroutine StartCoroutine(CustomRoutine routine)
{
return ((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp((IEnumerator)routine));
}
[HideFromIl2Cpp]
public Coroutine StartCoroutine(IEnumerator routine)
{
return ((MonoBehaviour)this).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
}
internal static void ClearSyringeList()
{
s_syringeWrappers.Clear();
}
internal static bool InvokeMoveNextOnApplySyringe(_ApplySyringe_d__18 instance, ref bool result)
{
SyringeWrapper syringeWrapper = null;
for (int i = 0; i < s_syringeWrappers.Count; i++)
{
SyringeWrapper syringeWrapper2 = s_syringeWrappers[i];
if (syringeWrapper2.Equals(instance))
{
syringeWrapper = syringeWrapper2;
break;
}
}
if (syringeWrapper == null)
{
syringeWrapper = new SyringeWrapper(instance);
s_syringeWrappers.Add(syringeWrapper);
}
return syringeWrapper.OnMoveNext(ref result);
}
internal static void InvokeUnWieldSyringe(SyringeFirstPerson instance)
{
SyringeWrapper syringeWrapper = null;
for (int i = 0; i < s_syringeWrappers.Count; i++)
{
SyringeWrapper syringeWrapper2 = s_syringeWrappers[i];
if (syringeWrapper2.Equals(instance))
{
syringeWrapper = syringeWrapper2;
break;
}
}
syringeWrapper?.OnUnWield();
}
}
[BepInPlugin("dev.flaff.gtfo.ExtraSyringeCustomization", "ExtraSyringeCustomization", "0.3.7")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class MainPlugin : BasePlugin
{
internal static ManualLogSource? LogSource;
public override void Load()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
LogSource = ((BasePlugin)this).Log;
new Harmony("dev.flaff.gtfo.ExtraSyringeCustomization").PatchAll();
SyringeRegistryHandler.Properties.Register<SyringeMeleeBuffTimeProperty>();
SyringeRegistryHandler.Properties.Register<SyringeMovementMultiplierProperty>();
SyringeRegistryHandler.Properties.Register<SyringeHealthValueProperty>();
SyringeRegistryHandler.Properties.Register<SyringeAmmoValueProperty>();
SyringeRegistryHandler.Properties.Register<SyringeToolValueProperty>();
SyringeRegistryHandler.Properties.Register<SyringeDisinfectionValueProperty>();
SyringeRegistryHandler.Properties.Register<SyringeInfectionValueProperty>();
SyringeRegistryHandler.Properties.Register<SyringeSelfDestructProperty>();
SyringeRegistryHandler.Properties.Register<SyringeDOTProperty>();
SyringeRegistryHandler.Properties.Register<SyringeROTProperty>();
NetworkAPI.RegisterEvent<SelfDestruct>("Syringe-Self-Destruct", (Action<ulong, SelfDestruct>)delegate(ulong _, SelfDestruct packet)
{
SNet_Player val = default(SNet_Player);
if (SNet.Core.TryGetPlayer(packet.playerID, ref val, false))
{
SyringeSelfDestructProperty.DoExplodeEffect(((Il2CppObjectBase)val.PlayerAgent).Cast<PlayerAgent>());
}
});
}
}
internal static class PLUGIN_CONSTANTS
{
public const string PLUGIN_NAME = "ExtraSyringeCustomization";
public const string PLUGIN_VERSION = "0.3.7";
public const string PLUGIN_GUID = "dev.flaff.gtfo.ExtraSyringeCustomization";
}
internal sealed class SyringePropertyInfo : IRegisterable
{
public string PropertyName { get; }
public Type PropertyType { get; }
public SyringePropertyInfo(string name, Type type)
{
PropertyName = name;
PropertyType = type;
}
public static SyringePropertyInfo Create<T>() where T : SyringePropertyBase, new()
{
return new SyringePropertyInfo(new T().Name, typeof(T));
}
string IRegisterable.GetID()
{
return PropertyName;
}
}
}
namespace ExtraSyringeCustomization.Utils
{
internal abstract class AppliedRoutine : DelayedRoutineBase
{
[CompilerGenerated]
private sealed class <>c__DisplayClass6_0
{
public float t;
internal void <CreateRoutine>b__0(float newT)
{
t = newT;
}
}
[CompilerGenerated]
private sealed class <CreateRoutine>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AppliedRoutine <>4__this;
private <>c__DisplayClass6_0 <>8__1;
private IEnumerator <routine>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateRoutine>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<routine>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
AppliedRoutine appliedRoutine = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass6_0();
<>8__1.t = 0f;
<routine>5__2 = appliedRoutine.CreateDelayRoutine(delegate(float newT)
{
<>8__1.t = newT;
});
goto IL_0084;
case 1:
<>1__state = -1;
goto IL_0084;
case 2:
{
<>1__state = -1;
<>8__1.t += Time.deltaTime;
break;
}
IL_0084:
if (<routine>5__2.MoveNext())
{
<>2__current = <routine>5__2.Current;
<>1__state = 1;
return true;
}
appliedRoutine.Apply();
break;
}
if ((double)<>8__1.t < appliedRoutine.Time)
{
<>2__current = null;
<>1__state = 2;
return true;
}
appliedRoutine.Remove();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public double Time { get; }
protected AppliedRoutine(double delay, double time)
: base(delay)
{
Time = time;
}
public abstract void Apply();
public abstract void Remove();
[IteratorStateMachine(typeof(<CreateRoutine>d__6))]
protected override IEnumerator CreateRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateRoutine>d__6(0)
{
<>4__this = this
};
}
}
public abstract class CustomRoutine : IEnumerator
{
private readonly IEnumerator m_routine;
object IEnumerator.Current => m_routine.Current;
protected CustomRoutine()
{
m_routine = CreateRoutine();
}
protected abstract IEnumerator CreateRoutine();
bool IEnumerator.MoveNext()
{
return m_routine.MoveNext();
}
void IEnumerator.Reset()
{
m_routine.Reset();
}
}
public abstract class DelayedRoutine : DelayedRoutineBase
{
[CompilerGenerated]
private sealed class <CreateRoutine>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DelayedRoutine <>4__this;
private IEnumerator <routine>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateRoutine>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<routine>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
DelayedRoutine delayedRoutine = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<routine>5__2 = delayedRoutine.CreateDelayRoutine();
break;
case 1:
<>1__state = -1;
break;
}
if (<routine>5__2.MoveNext())
{
<>2__current = <routine>5__2.Current;
<>1__state = 1;
return true;
}
delayedRoutine.Activate();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
protected DelayedRoutine(double delay)
: base(delay)
{
}
public abstract void Activate();
[IteratorStateMachine(typeof(<CreateRoutine>d__2))]
protected override IEnumerator CreateRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateRoutine>d__2(0)
{
<>4__this = this
};
}
}
public abstract class DelayedRoutineBase : CustomRoutine
{
[CompilerGenerated]
private sealed class <CreateDelayRoutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public DelayedRoutineBase <>4__this;
public Action<float> timeRemainderCallback;
private float <t>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CreateDelayRoutine>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
DelayedRoutineBase delayedRoutineBase = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<t>5__2 = 0f;
break;
case 1:
<>1__state = -1;
<t>5__2 += Time.deltaTime;
break;
}
if ((double)<t>5__2 < delayedRoutineBase.Delay)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<t>5__2 -= (float)delayedRoutineBase.Delay;
timeRemainderCallback?.Invoke(<t>5__2);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public double Delay { get; }
protected DelayedRoutineBase(double delay)
{
Delay = delay;
}
protected IEnumerator CreateDelayRoutine()
{
return CreateDelayRoutine(null);
}
[IteratorStateMachine(typeof(<CreateDelayRoutine>d__5))]
protected IEnumerator CreateDelayRoutine(Action<float>? timeRemainderCallback)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CreateDelayRoutine>d__5(0)
{
<>4__this = this,
timeRemainderCallback = timeRemainderCallback
};
}
}
public class DelayValue : MinMaxValue
{
public bool HasDelay { get; set; }
public override double GetValue(Random random)
{
if (!HasDelay)
{
return double.NaN;
}
return base.GetValue(random);
}
}
internal static class L
{
private static ManualLogSource Source => MainPlugin.LogSource;
public static void Msg(object data)
{
Source.LogMessage(data);
}
public static void Info(object data)
{
Source.LogInfo(data);
}
public static void Debug(object data)
{
Source.LogDebug(data);
}
public static void Warn(object data)
{
Source.LogWarning(data);
}
public static void Error(object data)
{
Source.LogError(data);
}
}
public class MinMaxValue
{
public double Min { get; set; }
public double Max { get; set; }
public virtual double GetValue(double t)
{
if (t < 0.0)
{
t = 0.0;
}
else if (t > 1.0)
{
t = 1.0;
}
return GetValueUnclamped(t);
}
public virtual double GetValueUnclamped(double t)
{
double num = Min;
if (num != Max)
{
num += (Max - Min) * t;
}
return num;
}
public virtual double GetValue(Random random)
{
double num = Min;
if (num != Max)
{
num += random.NextDouble() * (Max - Min);
}
return num;
}
}
public class OverTimeIntervalValue : MinMaxValue
{
public bool RandomizeEveryInterval { get; set; }
}
public class OverTimeValue : MinMaxValue
{
public bool IsTimeBased { get; set; }
}
public static class PathUtil
{
public static string NiceRelativePath(string relativeTo, string path)
{
path = path.Replace(Path.DirectorySeparatorChar, '/');
string text = Path.GetRelativePath(relativeTo.Replace('/', Path.DirectorySeparatorChar), path.EndsWith('/') ? path : (path + "/")).Replace(Path.DirectorySeparatorChar, '/');
if (text == ".")
{
text = "";
}
text = "/" + text;
if (text.EndsWith("/"))
{
text = text.Substring(0, text.Length - 1);
}
return text;
}
}
}
namespace ExtraSyringeCustomization.Registries
{
public sealed class CustomSyringePropertyRegistry
{
internal sealed class RegistryImpl : Registry<SyringePropertyInfo>
{
protected override void OnRegisterFailed(SyringePropertyInfo entry, string failReason)
{
L.Warn("Failed to add syringe property with name '" + entry.PropertyName + "': " + failReason);
}
protected override void OnRegistered(SyringePropertyInfo entry)
{
L.Info("Added syringe property with name '" + entry.PropertyName + "'");
}
}
private readonly RegistryImpl m_registry;
internal RegistryImpl Registry => m_registry;
public CustomSyringePropertyRegistry()
{
m_registry = new RegistryImpl();
}
public void Register<T>() where T : SyringePropertyBase, new()
{
((RegistryBase<SyringePropertyInfo>)(object)Registry).Register(SyringePropertyInfo.Create<T>());
}
public void UnRegister<T>() where T : SyringePropertyBase, new()
{
((RegistryBase<SyringePropertyInfo>)(object)Registry).UnRegister(SyringePropertyInfo.Create<T>());
}
}
public sealed class CustomSyringeRegistry : Registry<CustomSyringeDefinition>
{
private const string SYRINGE_PREFIX = "SYRINGE_";
public bool TryGetEntry(uint syringeID, [NotNullWhen(true)] out CustomSyringeDefinition? syringe)
{
return ((RegistryBase<CustomSyringeDefinition>)(object)this).TryGetEntry(SyringeIDToRegistryID(syringeID), ref syringe);
}
protected override void OnRegistered(CustomSyringeDefinition entry)
{
uint syringeID = entry.SyringeID;
Dictionary<uint, ItemDataBlock> s_blockByID = GameDataBlockBase<ItemDataBlock>.s_blockByID;
if (s_blockByID == null || !s_blockByID.ContainsKey(syringeID))
{
L.Debug($"Added syringe with id '{syringeID}'");
L.Warn($"Custom Syringe Definition with ID '{syringeID}' does not currently have an item datablock entry");
}
else
{
L.Debug($"Added syringe with id '{syringeID}' (ItemDataBlock - {((GameDataBlockBase<ItemDataBlock>)(object)GameDataBlockBase<ItemDataBlock>.GetBlock(syringeID)).name})");
}
}
public static string SyringeIDToRegistryID(uint id)
{
return "SYRINGE_" + id;
}
public static uint RegistryIDToSyringeID(string id)
{
if (id.StartsWith("SYRINGE_"))
{
return uint.Parse(id.Substring("SYRINGE_".Length));
}
throw new ArgumentException("Invalid Registry ID given", "id");
}
}
public static class SyringeRegistryHandler
{
public static CustomSyringeRegistry Syringes { get; } = new CustomSyringeRegistry();
public static CustomSyringePropertyRegistry Properties { get; } = new CustomSyringePropertyRegistry();
}
}
namespace ExtraSyringeCustomization.Properties
{
public class PropertySequenceTiming
{
public bool IsRelativeToPreviousProperties { get; set; }
public DelayValue Delay { get; set; } = new DelayValue();
}
public abstract class SyringePropertyBase : IRegisterable
{
public bool Enabled { get; set; }
public PropertySequenceTiming Timing { get; set; } = new PropertySequenceTiming();
public abstract string Name { get; }
public abstract IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo sequenceInfo);
string IRegisterable.GetID()
{
return Name;
}
public virtual Type? GetDataType()
{
return null;
}
public virtual SyringePropertyData? GetData()
{
return null;
}
public virtual void SetData(SyringePropertyData? data)
{
}
}
public abstract class SyringePropertyBase<T> : SyringePropertyBase where T : SyringePropertyData, new()
{
public T Data { get; set; } = new T();
public override Type? GetDataType()
{
return typeof(T);
}
public sealed override SyringePropertyData? GetData()
{
return Data;
}
public sealed override void SetData(SyringePropertyData? data)
{
if (data is T data2)
{
Data = data2;
}
else
{
Data = new T();
}
}
}
public class SyringePropertyData
{
}
[JsonConverter(typeof(SyringePropertyListConverter))]
public sealed class SyringePropertyList
{
[CompilerGenerated]
private sealed class <GetEntries>d__4 : IEnumerable<KeyValuePair<string, SyringePropertyBase>>, IEnumerable, IEnumerator<KeyValuePair<string, SyringePropertyBase>>, IEnumerator, IDisposable
{
private int <>1__state;
private KeyValuePair<string, SyringePropertyBase> <>2__current;
private int <>l__initialThreadId;
public SyringePropertyList <>4__this;
private Dictionary<string, SyringePropertyBase>.KeyCollection.Enumerator <>7__wrap1;
KeyValuePair<string, SyringePropertyBase> IEnumerator<KeyValuePair<string, SyringePropertyBase>>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GetEntries>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<>7__wrap1 = default(Dictionary<string, SyringePropertyBase>.KeyCollection.Enumerator);
<>1__state = -2;
}
private bool MoveNext()
{
try
{
int num = <>1__state;
SyringePropertyList syringePropertyList = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>7__wrap1 = syringePropertyList.m_properties.Keys.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
break;
}
if (<>7__wrap1.MoveNext())
{
string current = <>7__wrap1.Current;
<>2__current = new KeyValuePair<string, SyringePropertyBase>(current, syringePropertyList.m_properties[current]);
<>1__state = 1;
return true;
}
<>m__Finally1();
<>7__wrap1 = default(Dictionary<string, SyringePropertyBase>.KeyCollection.Enumerator);
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((IDisposable)<>7__wrap1).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<KeyValuePair<string, SyringePropertyBase>> IEnumerable<KeyValuePair<string, SyringePropertyBase>>.GetEnumerator()
{
<GetEntries>d__4 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <GetEntries>d__4(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<KeyValuePair<string, SyringePropertyBase>>)this).GetEnumerator();
}
}
private readonly Dictionary<string, SyringePropertyBase> m_properties = new Dictionary<string, SyringePropertyBase>();
public void AddProperty(SyringePropertyBase property)
{
if (property == null)
{
throw new ArgumentNullException("property");
}
string name = property.Name;
if (m_properties.ContainsKey(name))
{
throw new ArgumentException("Syringe Property with name '" + name + "' already exists!", "property");
}
m_properties.Add(name, property);
}
public IEnumerator<SyringePropertyBase> GetAllProperties()
{
return m_properties.Values.GetEnumerator();
}
public SyringePropertyBase[] GetProperties()
{
return m_properties.Values.Where((SyringePropertyBase property) => property.Enabled).ToArray();
}
[IteratorStateMachine(typeof(<GetEntries>d__4))]
public IEnumerable<KeyValuePair<string, SyringePropertyBase>> GetEntries()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetEntries>d__4(-2)
{
<>4__this = this
};
}
}
public sealed class SyringePropertySequenceInfo
{
private bool m_forceComplete;
public bool ForceComplete => m_forceComplete;
public double DeltaTime
{
get
{
if (m_forceComplete)
{
return double.MaxValue;
}
return Time.deltaTime;
}
}
public void ForceCompletion()
{
m_forceComplete = true;
}
}
}
namespace ExtraSyringeCustomization.Properties.BuiltIn
{
public sealed class SyringeAmmoValueProperty : SyringePropertyMinMaxBase
{
[CompilerGenerated]
private sealed class <Apply>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeAmmoValueProperty <>4__this;
public Random random;
public PlayerAgent player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
SyringeAmmoValueProperty syringeAmmoValueProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
float num2 = (float)syringeAmmoValueProperty.Data.GetValue(random);
PlayerBackpackManager.GiveAmmoToPlayer(player.Owner, num2, num2, 0f);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "Ammo";
[IteratorStateMachine(typeof(<Apply>d__2))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__2(0)
{
<>4__this = this,
player = player,
random = random
};
}
}
public sealed class SyringeDisinfectionValueProperty : SyringePropertyMinMaxBase
{
[CompilerGenerated]
private sealed class <Apply>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAgent player;
public SyringeDisinfectionValueProperty <>4__this;
public Random random;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
SyringeDisinfectionValueProperty syringeDisinfectionValueProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
player.Damage.ModifyInfection(new pInfection
{
amount = 0f - (float)syringeDisinfectionValueProperty.Data.GetValue(random),
effect = (pInfectionEffect)1,
mode = (pInfectionMode)1
}, true, true);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "Disinfection";
[IteratorStateMachine(typeof(<Apply>d__2))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__2(0)
{
<>4__this = this,
player = player,
random = random
};
}
}
public sealed class SyringeDOTProperty : SyringePropertyBase<SyringeDOTProperty.JsonData>
{
public sealed class JsonData : SyringePropertyData
{
public MinMaxValue TotalTime { get; set; } = new MinMaxValue();
public OverTimeIntervalValue DamageInterval { get; set; } = new OverTimeIntervalValue();
public OverTimeValue Damage { get; set; } = new OverTimeValue();
public bool ClearWhenDown { get; set; } = true;
}
[CompilerGenerated]
private sealed class <Apply>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeDOTProperty <>4__this;
public Random random;
public PlayerAgent player;
public SyringePropertySequenceInfo info;
private IEnumerator <routine>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<routine>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
SyringeDOTProperty syringeDOTProperty = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
double value = syringeDOTProperty.Data.TotalTime.GetValue(random);
L.Debug($"Apply DOT! (Total Time: {value})");
<routine>5__2 = syringeDOTProperty.InnerRoutine(player, random, value, info);
break;
}
case 1:
<>1__state = -1;
break;
}
if (!info.ForceComplete && <routine>5__2.MoveNext())
{
<>2__current = <routine>5__2.Current;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <InnerRoutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeDOTProperty <>4__this;
public Random random;
public SyringePropertySequenceInfo info;
public double totalTime;
public PlayerAgent player;
private double <t>5__2;
private double <interval>5__3;
private double <damageInterval>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InnerRoutine>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Invalid comparison between Unknown and I4
int num = <>1__state;
SyringeDOTProperty syringeDOTProperty = <>4__this;
double num2;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<t>5__2 = 0.0;
<interval>5__3 = 0.0;
<damageInterval>5__4 = syringeDOTProperty.Data.DamageInterval.GetValue(random);
goto IL_01a5;
case 1:
<>1__state = -1;
<interval>5__3 += info.DeltaTime;
<t>5__2 += info.DeltaTime;
goto IL_00af;
case 2:
{
<>1__state = -1;
goto IL_01a5;
}
IL_01a5:
if (!(<t>5__2 < totalTime))
{
return false;
}
goto IL_00af;
IL_00af:
if (<interval>5__3 < <damageInterval>5__4 && <t>5__2 < totalTime)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<interval>5__3 -= <damageInterval>5__4;
if ((int)player.Locomotion.m_currentStateEnum == 7)
{
if (syringeDOTProperty.Data.ClearWhenDown)
{
return false;
}
<>2__current = null;
<>1__state = 2;
return true;
}
num2 = ((!syringeDOTProperty.Data.Damage.IsTimeBased) ? syringeDOTProperty.Data.Damage.GetValue(random) : syringeDOTProperty.Data.Damage.GetValue(<t>5__2 / totalTime));
((Dam_SyncedDamageBase)player.Damage).NoAirDamage((float)num2);
if (syringeDOTProperty.Data.DamageInterval.RandomizeEveryInterval)
{
<damageInterval>5__4 = syringeDOTProperty.Data.DamageInterval.GetValue(random);
}
goto IL_01a5;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "DamageOverTime";
[IteratorStateMachine(typeof(<Apply>d__3))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__3(0)
{
<>4__this = this,
player = player,
random = random,
info = info
};
}
[IteratorStateMachine(typeof(<InnerRoutine>d__4))]
private IEnumerator InnerRoutine(PlayerAgent player, Random random, double totalTime, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InnerRoutine>d__4(0)
{
<>4__this = this,
player = player,
random = random,
totalTime = totalTime,
info = info
};
}
}
public sealed class SyringeHealthValueProperty : SyringePropertyMinMaxBase
{
[CompilerGenerated]
private sealed class <Apply>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeHealthValueProperty <>4__this;
public Random random;
public PlayerAgent player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
SyringeHealthValueProperty syringeHealthValueProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
PlayerBackpackManager.PickupHealthRel((float)syringeHealthValueProperty.Data.GetValue(random), player);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "Health";
[IteratorStateMachine(typeof(<Apply>d__2))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__2(0)
{
<>4__this = this,
player = player,
random = random
};
}
}
public sealed class SyringeInfectionValueProperty : SyringePropertyMinMaxBase
{
[CompilerGenerated]
private sealed class <Apply>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAgent player;
public SyringeInfectionValueProperty <>4__this;
public Random random;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0027: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
SyringeInfectionValueProperty syringeInfectionValueProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
player.Damage.ModifyInfection(new pInfection
{
amount = (float)syringeInfectionValueProperty.Data.GetValue(random),
effect = (pInfectionEffect)0,
mode = (pInfectionMode)1
}, true, true);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "Infection";
[IteratorStateMachine(typeof(<Apply>d__2))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__2(0)
{
<>4__this = this,
player = player,
random = random
};
}
}
public sealed class SyringeMeleeBuffTimeProperty : SyringePropertyMinMaxBase
{
[CompilerGenerated]
private sealed class <Apply>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeMeleeBuffTimeProperty <>4__this;
public Random random;
public PlayerAgent player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
SyringeMeleeBuffTimeProperty syringeMeleeBuffTimeProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
double value = syringeMeleeBuffTimeProperty.Data.GetValue(random);
float num2 = (float)(Clock.TimeDouble + value);
L.Debug($"Apply MeleeBuffTime! (Time: {value}, Game End Time: {num2})");
player.MeleeBuffTimer = num2;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "MeleeBuffTime";
[IteratorStateMachine(typeof(<Apply>d__2))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__2(0)
{
<>4__this = this,
player = player,
random = random
};
}
}
public sealed class SyringeMovementMultiplierProperty : SyringePropertyMinMaxBase<SyringeMovementMultiplierProperty.JsonData>
{
public sealed class JsonData : BasicMinMaxData
{
public MinMaxValue Time { get; set; } = new MinMaxValue();
public bool ClearWhenDown { get; set; } = true;
}
[CompilerGenerated]
private sealed class <Apply>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeMovementMultiplierProperty <>4__this;
public Random random;
public SyringePropertySequenceInfo info;
public PlayerAgent player;
private ISpeedModifier <modifier>5__2;
private IEnumerator <routine>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<modifier>5__2 = null;
<routine>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Invalid comparison between Unknown and I4
int num = <>1__state;
SyringeMovementMultiplierProperty syringeMovementMultiplierProperty = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
double value = syringeMovementMultiplierProperty.Data.Time.GetValue(random);
double value2 = syringeMovementMultiplierProperty.Data.GetValue(random);
L.Debug($"Apply Movement Multiplier! (time: {value}, value: {value2})");
<modifier>5__2 = MoveSpeedAPI.AddModifier((float)value2, (StackLayer)0, "Default");
<routine>5__3 = InnerRoutine(value, info);
break;
}
case 1:
<>1__state = -1;
break;
}
if (!info.ForceComplete && <routine>5__3.MoveNext() && (!syringeMovementMultiplierProperty.Data.ClearWhenDown || (int)player.Locomotion.m_currentStateEnum != 7))
{
<>2__current = <routine>5__3.Current;
<>1__state = 1;
return true;
}
<modifier>5__2.Disable();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <InnerRoutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringePropertySequenceInfo info;
public double time;
private double <t>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InnerRoutine>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<t>5__2 = 0.0;
break;
case 1:
<>1__state = -1;
<t>5__2 += info.DeltaTime;
break;
}
if (<t>5__2 < time)
{
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "MovementMultiplier";
[IteratorStateMachine(typeof(<Apply>d__3))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__3(0)
{
<>4__this = this,
player = player,
random = random,
info = info
};
}
[IteratorStateMachine(typeof(<InnerRoutine>d__4))]
private static IEnumerator InnerRoutine(double time, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InnerRoutine>d__4(0)
{
time = time,
info = info
};
}
}
public class BasicMinMaxData : SyringePropertyData
{
public double Min { get; set; }
public double Max { get; set; }
public double GetValue(Random random)
{
double num = Min;
if (num != Max)
{
num += random.NextDouble() * (Max - Min);
}
return num;
}
}
public abstract class SyringePropertyMinMaxBase<TData> : SyringePropertyBase<TData> where TData : BasicMinMaxData, new()
{
}
public abstract class SyringePropertyMinMaxBase : SyringePropertyMinMaxBase<BasicMinMaxData>
{
}
public sealed class SyringeROTProperty : SyringePropertyBase<SyringeROTProperty.JsonData>
{
public sealed class JsonData : SyringePropertyData
{
public MinMaxValue TotalTime { get; set; } = new MinMaxValue();
public OverTimeIntervalValue RegenInterval { get; set; } = new OverTimeIntervalValue();
public OverTimeValue Health { get; set; } = new OverTimeValue();
public bool ClearWhenDown { get; set; } = true;
}
[CompilerGenerated]
private sealed class <Apply>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeROTProperty <>4__this;
public Random random;
public PlayerAgent player;
public SyringePropertySequenceInfo info;
private IEnumerator <routine>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<routine>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
SyringeROTProperty syringeROTProperty = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
double value = syringeROTProperty.Data.TotalTime.GetValue(random);
L.Debug($"Apply ROT! (Total Time: {value})");
<routine>5__2 = syringeROTProperty.InnerRoutine(player, random, value, info);
break;
}
case 1:
<>1__state = -1;
break;
}
if (!info.ForceComplete && <routine>5__2.MoveNext())
{
<>2__current = <routine>5__2.Current;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <InnerRoutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeROTProperty <>4__this;
public Random random;
public SyringePropertySequenceInfo info;
public double totalTime;
public PlayerAgent player;
private double <t>5__2;
private double <interval>5__3;
private double <regenInterval>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InnerRoutine>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Invalid comparison between Unknown and I4
int num = <>1__state;
SyringeROTProperty syringeROTProperty = <>4__this;
double num2;
double num3;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<t>5__2 = 0.0;
<interval>5__3 = 0.0;
<regenInterval>5__4 = syringeROTProperty.Data.RegenInterval.GetValue(random);
goto IL_01ba;
case 1:
<>1__state = -1;
<interval>5__3 += info.DeltaTime;
<t>5__2 += info.DeltaTime;
goto IL_00af;
case 2:
{
<>1__state = -1;
goto IL_01ba;
}
IL_01ba:
if (!(<t>5__2 < totalTime))
{
return false;
}
goto IL_00af;
IL_00af:
if (<interval>5__3 < <regenInterval>5__4 && <t>5__2 < totalTime)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<interval>5__3 -= <regenInterval>5__4;
if ((int)player.Locomotion.m_currentStateEnum == 7)
{
if (syringeROTProperty.Data.ClearWhenDown)
{
return false;
}
<>2__current = null;
<>1__state = 2;
return true;
}
num2 = ((!syringeROTProperty.Data.Health.IsTimeBased) ? syringeROTProperty.Data.Health.GetValue(random) : syringeROTProperty.Data.Health.GetValue(<t>5__2 / totalTime));
num3 = num2 / (double)player.PlayerData.health;
player.GiveHealth(player, (float)num3);
if (syringeROTProperty.Data.RegenInterval.RandomizeEveryInterval)
{
<regenInterval>5__4 = syringeROTProperty.Data.RegenInterval.GetValue(random);
}
goto IL_01ba;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "RegenOverTime";
[IteratorStateMachine(typeof(<Apply>d__3))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__3(0)
{
<>4__this = this,
player = player,
random = random,
info = info
};
}
[IteratorStateMachine(typeof(<InnerRoutine>d__4))]
private IEnumerator InnerRoutine(PlayerAgent player, Random random, double totalTime, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InnerRoutine>d__4(0)
{
<>4__this = this,
player = player,
random = random,
totalTime = totalTime,
info = info
};
}
}
public sealed class SyringeSelfDestructProperty : SyringePropertyBase<SyringeSelfDestructProperty.JsonData>
{
public sealed class JsonData : SyringePropertyData
{
public double Damage { get; set; }
public double Radius { get; set; }
}
[CompilerGenerated]
private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayerAgent player;
public SyringeSelfDestructProperty <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
SyringeSelfDestructProperty syringeSelfDestructProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
L.Debug("Self Destruct : Activate!");
DamageUtil.DoExplosionDamage(player.FPSCamera.Position, (float)syringeSelfDestructProperty.Data.Radius, (float)syringeSelfDestructProperty.Data.Damage, LayerManager.MASK_EXPLOSION_TARGETS, LayerManager.MASK_EXPLOSION_BLOCKERS, false, 0f);
DoExplodeEffect(player);
((Dam_SyncedDamageBase)player.Damage).ExplosionDamage((float)syringeSelfDestructProperty.Data.Damage, ((Agent)player).Position, Vector3.up, 0u);
NetworkAPI.InvokeEvent<SelfDestruct>("Syringe-Self-Destruct", new SelfDestruct
{
playerID = player.Owner.Lookup
}, (SNet_ChannelType)2);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static FX_Pool s_detonateFX;
public override string Name => "SelfDestruct";
private static FX_Pool DetonateFX
{
get
{
if ((Object)(object)s_detonateFX == (Object)null)
{
s_detonateFX = FX_Manager.GetEffectPool(AssetShardManager.GetLoadedAsset<GameObject>("Assets/AssetPrefabs/FX_Effects/FX_Tripmine.prefab", false));
}
return s_detonateFX;
}
}
[IteratorStateMachine(typeof(<Apply>d__4))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__4(0)
{
<>4__this = this,
player = player
};
}
public static void DoExplodeEffect(PlayerAgent player)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
player.Sound.Post(EVENTS.STICKYMINEEXPLODE, true);
((FX_EffectBase)DetonateFX.AquireEffect()).Play((FX_Trigger)null, ((Component)player).transform.position, Quaternion.LookRotation(Vector3.up));
}
}
public sealed class SyringeToolValueProperty : SyringePropertyMinMaxBase
{
[CompilerGenerated]
private sealed class <Apply>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public SyringeToolValueProperty <>4__this;
public Random random;
public PlayerAgent player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Apply>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
SyringeToolValueProperty syringeToolValueProperty = <>4__this;
if (num != 0)
{
return false;
}
<>1__state = -1;
float num2 = (float)syringeToolValueProperty.Data.GetValue(random);
PlayerBackpackManager.GiveAmmoToPlayer(player.Owner, 0f, 0f, num2);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public override string Name => "Tool";
[IteratorStateMachine(typeof(<Apply>d__2))]
public override IEnumerator Apply(PlayerAgent player, SyringeFirstPerson syringe, Random random, SyringePropertySequenceInfo info)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Apply>d__2(0)
{
<>4__this = this,
player = player,
random = random
};
}
}
}
namespace ExtraSyringeCustomization.Patches
{
[HarmonyPatch]
internal sealed class GameDataInitPatch
{
private class RawJSONFile
{
public List<CustomSyringeDefinition> Syringes { get; set; }
public RawJSONFile()
{
Syringes = new List<CustomSyringeDefinition>();
}
}
[HarmonyPatch(typeof(GameDataInit), "Initialize")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void InitializePatch()
{
string text = ConfigManager.CustomPath;
if (text == null)
{
text = Path.Combine(ConfigManager.GameDataPath, "Custom");
}
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
string text2 = Path.Combine(ConfigManager.CustomPath, "ExtraSyringeCustomization");
if (!Directory.Exists(text2))
{
Directory.CreateDirectory(text2);
}
string text3 = Path.Combine(text2, "syringes.json");
string path = Path.Combine(text2, "GENERATED_syringe-properties.json");
string path2 = Path.Combine(text2, "GENERATED_example-syringes.json");
ExtraSyringeHandler.ConfigPath = text2;
IEnumerable<SyringePropertyInfo> entries = ((RegistryBase<SyringePropertyInfo>)(object)SyringeRegistryHandler.Properties.Registry).GetEntries();
if (!File.Exists(path))
{
SyringePropertyList syringePropertyList = new SyringePropertyList();
foreach (SyringePropertyInfo item in entries)
{
syringePropertyList.AddProperty((SyringePropertyBase)Activator.CreateInstance(item.PropertyType));
}
L.Info("Generating List of all Syringe Properties at '" + PathUtil.NiceRelativePath(ConfigManager.GameDataPath, path) + "'");
File.WriteAllText(path, JsonSerializer.Serialize(syringePropertyList, new JsonSerializerOptions
{
WriteIndented = true
}));
}
else
{
L.Debug("Skipping Syringe Property List file generation. (Delete '" + PathUtil.NiceRelativePath(ConfigManager.GameDataPath, path) + "' to regenerate it)");
}
if (!File.Exists(path2))
{
RawJSONFile rawJSONFile = new RawJSONFile();
CustomSyringeDefinition customSyringeDefinition = new CustomSyringeDefinition();
customSyringeDefinition.SyringeID = 999u;
rawJSONFile.Syringes.Add(customSyringeDefinition);
foreach (SyringePropertyInfo item2 in entries)
{
customSyringeDefinition.Properties.AddProperty((SyringePropertyBase)Activator.CreateInstance(item2.PropertyType));
}
L.Info("Generating Syringe Example File at '" + PathUtil.NiceRelativePath(ConfigManager.GameDataPath, path2) + "'");
File.WriteAllText(path2, JsonSerializer.Serialize(rawJSONFile, new JsonSerializerOptions
{
WriteIndented = true
}));
}
else
{
L.Debug("Skipping Syringe Example file generation. (Delete '" + PathUtil.NiceRelativePath(ConfigManager.GameDataPath, path2) + "' to regenerate it)");
}
L.Debug("Custom Syringes Path: " + text3);
if (!File.Exists(text3))
{
L.Warn("No syringe definition file found. (Create one at '" + PathUtil.NiceRelativePath(ConfigManager.GameDataPath, text3) + "')");
return;
}
try
{
RawJSONFile rawJSONFile2 = JsonSerializer.Deserialize<RawJSONFile>(File.ReadAllText(text3), new JsonSerializerOptions
{
AllowTrailingCommas = true
});
if (rawJSONFile2 == null)
{
L.Warn("Syringe File was empty! Rewriting to basic blank json!");
rawJSONFile2 = new RawJSONFile();
File.WriteAllText(text3, JsonSerializer.Serialize(rawJSONFile2, new JsonSerializerOptions
{
WriteIndented = true
}));
return;
}
if (rawJSONFile2.Syringes == null)
{
L.Warn("No 'Syringes' property was defined in JSON! Rewriting json to include it!");
rawJSONFile2.Syringes = new List<CustomSyringeDefinition>();
File.WriteAllText(text3, JsonSerializer.Serialize(rawJSONFile2, new JsonSerializerOptions
{
WriteIndented = true
}));
return;
}
foreach (CustomSyringeDefinition syringe in rawJSONFile2.Syringes)
{
if (syringe != null)
{
try
{
((RegistryBase<CustomSyringeDefinition>)(object)SyringeRegistryHandler.Syringes).Register(syringe);
}
catch (Exception value)
{
L.Error($"Error whilst adding syringe with id {syringe.SyringeID}: {value}");
}
}
}
}
catch (Exception value2)
{
L.Error($"Error whilst reading syringes file: {value2}");
}
}
}
[HarmonyPatch]
internal static class SyringePatches
{
[HarmonyPatch(typeof(_ApplySyringe_d__18), "MoveNext")]
[HarmonyPrefix]
[HarmonyWrapSafe]
public static bool MoveNextPatch(_ApplySyringe_d__18 __instance, ref bool __result)
{
return ExtraSyringeHandler.InvokeMoveNextOnApplySyringe(__instance, ref __result);
}
[HarmonyPatch(typeof(SyringeFirstPerson), "OnUnWield")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void UnWieldPatch(SyringeFirstPerson __instance)
{
ExtraSyringeHandler.InvokeUnWieldSyringe(__instance);
}
[HarmonyPatch(typeof(GS_Lobby), "Enter")]
[HarmonyPostfix]
[HarmonyWrapSafe]
public static void EnterLobbyPatch()
{
ExtraSyringeHandler.ClearSyringeList();
}
}
}
namespace ExtraSyringeCustomization.Packets
{
public struct SelfDestruct
{
public ulong playerID;
}
public struct Vec3
{
public float x;
public float y;
public float z;
public Vec3(Vector3 vec)
: this(vec.x, vec.y, vec.z)
{
}//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
public Vec3(float x, float y, float z)
{
this.x = x;
this.y = y;
this.z = z;
}
public static implicit operator Vec3(Vector3 vec)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return new Vec3(vec);
}
public static implicit operator Vector3(Vec3 vec)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(vec.x, vec.y, vec.z);
}
}
}
namespace ExtraSyringeCustomization.Converters
{
public sealed class SyringePropertyConverter : JsonConverter<SyringePropertyBase>
{
private sealed class V1DataFormat
{
public DelayValue? Delay { get; set; }
public bool Enabled { get; set; }
}
private readonly string? m_fixedID;
private readonly bool m_asMap;
public SyringePropertyConverter()
{
m_fixedID = null;
m_asMap = false;
}
public SyringePropertyConverter(string id)
{
m_fixedID = id;
m_asMap = true;
}
public override bool CanConvert(Type typeToConvert)
{
return typeof(SyringePropertyBase).IsAssignableFrom(typeToConvert);
}
private static string ReadPropertyName(ref Utf8JsonReader reader, JsonSerializerOptions options)
{
string text = reader.GetString();
if (options.PropertyNameCaseInsensitive)
{
text = text.ToLower();
}
return text;
}
private static string GetPropertyName(string baseName, JsonSerializerOptions options)
{
string text = options.PropertyNamingPolicy?.ConvertName(baseName) ?? baseName;
if (options.PropertyNameCaseInsensitive)
{
text = text.ToLower();
}
return text;
}
private void ParseAsV1MapData(ref Utf8JsonReader reader, SyringePropertyBase result, JsonSerializerOptions options)
{
Utf8JsonReader reader2 = reader;
V1DataFormat v1DataFormat = JsonSerializer.Deserialize<V1DataFormat>(ref reader2, options);
result.Enabled = v1DataFormat?.Enabled ?? true;
if (v1DataFormat?.Delay != null)
{
result.Timing.Delay = v1DataFormat.Delay;
}
Type dataType = result.GetDataType();
if (dataType != null)
{
SyringePropertyData syringePropertyData = (SyringePropertyData)JsonSerializer.Deserialize(ref reader, dataType, options);
if (syringePropertyData == null)
{
syringePropertyData = (SyringePropertyData)Activator.CreateInstance(dataType);
}
result.SetData(syringePropertyData);
}
else
{
reader = reader2;
}
}
public override SyringePropertyBase? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
Utf8JsonReader reader2 = reader;
SyringePropertyBase syringePropertyBase = null;
if (reader.TokenType == JsonTokenType.Null)
{
return syringePropertyBase;
}
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException($"Unexpected token '{reader.TokenType}' (expected {1})");
}
string text = m_fixedID;
if (!string.IsNullOrEmpty(text))
{
SyringePropertyInfo syringePropertyInfo = default(SyringePropertyInfo);
if (!((RegistryBase<SyringePropertyInfo>)(object)SyringeRegistryHandler.Properties.Registry).TryGetEntry(text, ref syringePropertyInfo))
{
throw new JsonException("Failed to resolve custom syringe property with id '" + text + "'");
}
syringePropertyBase = (SyringePropertyBase)Activator.CreateInstance(syringePropertyInfo.PropertyType);
}
string propertyName = GetPropertyName("ID", options);
bool? flag = null;
string propertyName2 = GetPropertyName("Enabled", options);
PropertySequenceTiming propertySequenceTiming = null;
string propertyName3 = GetPropertyName("Timing", options);
SyringePropertyData syringePropertyData = null;
string propertyName4 = GetPropertyName("Data", options);
bool flag2 = false;
SyringePropertyInfo syringePropertyInfo2 = default(SyringePropertyInfo);
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
if (text == null || syringePropertyBase == null)
{
throw new JsonException("An ID field is required!");
}
if (!flag.HasValue)
{
flag = true;
}
if (flag2 && syringePropertyData == null)
{
throw new JsonException("A Data field is required!");
}
syringePropertyBase.Enabled = flag.Value;
if (flag2)
{
syringePropertyBase.SetData(syringePropertyData);
}
return syringePropertyBase;
}
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException($"Unexpected token '{reader.TokenType}' (expected {5} or {2})");
}
string text2 = ReadPropertyName(ref reader, options);
if (!reader.Read())
{
break;
}
if (!m_asMap && text2 == propertyName)
{
if (text != null)
{
throw new JsonException("An ID field is already specified!");
}
text = reader.GetString();
if (text == null)
{
throw new JsonException("Syringe Property ID cannot be null");
}
if (!((RegistryBase<SyringePropertyInfo>)(object)SyringeRegistryHandler.Properties.Registry).TryGetEntry(text, ref syringePropertyInfo2))
{
throw new JsonException("Failed to resolve custom syringe property with id '" + text + "'");
}
syringePropertyBase = (SyringePropertyBase)Activator.CreateInstance(syringePropertyInfo2.PropertyType);
flag2 = syringePropertyBase.GetDataType() != null;
}
else if (text2 == propertyName2)
{
if (flag.HasValue)
{
throw new JsonException("An Enabled field is already specified!");
}
flag = reader.GetBoolean();
}
else if (text2 == propertyName3)
{
if (propertySequenceTiming != null)
{
throw new JsonException("A Timing field is already specified!");
}
propertySequenceTiming = JsonSerializer.Deserialize<PropertySequenceTiming>(ref reader, options);
if (propertySequenceTiming == null)
{
propertySequenceTiming = new PropertySequenceTiming();
}
}
else if (text2 == propertyName4)
{
if (syringePropertyData != null)
{
throw new JsonException("A Data field is already specified!");
}
if (text == null)
{
throw new JsonException("An ID field must come before a Data field!");
}
if (!flag2)
{
throw new JsonException("A Data field is not allowed for syringe property '" + text + "'");
}
Type dataType = syringePropertyBase.GetDataType();
syringePropertyData = (SyringePropertyData)JsonSerializer.Deserialize(ref reader, dataType, options);
if (syringePropertyData == null)
{
syringePropertyData = (SyringePropertyData)Activator.CreateInstance(dataType);
}
}
else
{
if (m_asMap)
{
ParseAsV1MapData(ref reader2, syringePropertyBase, options);
reader = reader2;
return syringePropertyBase;
}
L.Warn("Unsupport field for json syringe property '" + text2 + "'");
reader.Skip();
}
}
throw new JsonException("Unexpected end of input.");
}
public override void Write(Utf8JsonWriter writer, SyringePropertyBase value, JsonSerializerOptions options)
{
writer.WriteStartObject();
if (!m_asMap)
{
writer.WriteString("ID", m_fixedID);
}
writer.WritePropertyName("Timing");
JsonSerializer.Serialize(writer, value.Timing ?? new PropertySequenceTiming(), options);
writer.WriteBoolean("Enabled", value.Enabled);
Type dataType = value.GetDataType();
if (dataType != null)
{
writer.WritePropertyName("Data");
JsonSerializer.Serialize(writer, value.GetData(), dataType, options);
}
writer.WriteEndObject();
}
}
public class SyringePropertyListConverter : JsonConverter<SyringePropertyList>
{
private readonly bool m_writeAsMap;
public SyringePropertyListConverter()
: this(writeAsMap: false)
{
}
public SyringePropertyListConverter(bool writeAsMap)
{
m_writeAsMap = writeAsMap;
}
private static SyringePropertyList ReadAsArray(ref Utf8JsonReader reader, JsonSerializerOptions options)
{
SyringePropertyList syringePropertyList = new SyringePropertyList();
new JsonSerializerOptions(options).Converters.Add(new SyringePropertyConverter());
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndArray)
{
return syringePropertyList;
}
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException($"Unexpected token '{reader.TokenType}' (expected {1} or {4})");
}
SyringePropertyBase syringePropertyBase = JsonSerializer.Deserialize<SyringePropertyBase>(ref reader, options);
if (syringePropertyBase != null)
{
syringePropertyList.AddProperty(syringePropertyBase);
}
}
throw new JsonException("Unexpected end of input.");
}
private static SyringePropertyList ReadAsMap(ref Utf8JsonReader reader, JsonSerializerOptions options)
{
SyringePropertyList syringePropertyList = new SyringePropertyList();
SyringePropertyInfo syringePropertyInfo = default(SyringePropertyInfo);
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
return syringePropertyList;
}
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException($"Unexpected token '{reader.TokenType}' (expected {5})");
}
string @string = reader.GetString();
if (@string == null || !((RegistryBase<SyringePropertyInfo>)(object)SyringeRegistryHandler.Properties.Registry).TryGetEntry(@string, ref syringePropertyInfo))
{
throw new JsonException("Failed to resolve custom syringe property with id '" + @string + "'");
}
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(options);
jsonSerializerOptions.Converters.Add(new SyringePropertyConverter(@string));
SyringePropertyBase syringePropertyBase = (SyringePropertyBase)JsonSerializer.Deserialize(ref reader, syringePropertyInfo.PropertyType, jsonSerializerOptions);
if (syringePropertyBase == null)
{
syringePropertyBase = (SyringePropertyBase)Activator.CreateInstance(syringePropertyInfo.PropertyType);
syringePropertyBase.Enabled = false;
}
syringePropertyList.AddProperty(syringePropertyBase);
}
throw new JsonException("Unexpected end of input.");
}
public override SyringePropertyList Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
{
return new SyringePropertyList();
}
if (reader.TokenType == JsonTokenType.StartObject)
{
return ReadAsMap(ref reader, options);
}
if (reader.TokenType == JsonTokenType.StartArray)
{
return ReadAsArray(ref reader, options);
}
throw new JsonException($"Unexpected token '{reader.TokenType}' (expected {1} or {3})");
}
public override void Write(Utf8JsonWriter writer, SyringePropertyList value, JsonSerializerOptions options)
{
if (m_writeAsMap)
{
WriteAsMap(writer, value, options);
}
else
{
WriteAsArray(writer, value, options);
}
}
private static void WriteAsArray(Utf8JsonWriter writer, SyringePropertyList value, JsonSerializerOptions options)
{
writer.WriteStartArray();
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(options);
jsonSerializerOptions.Converters.Add(new SyringePropertyConverter());
SyringePropertyBase[] properties = value.GetProperties();
foreach (SyringePropertyBase value2 in properties)
{
JsonSerializer.Serialize(writer, value2, jsonSerializerOptions);
}
writer.WriteEndArray();
}
private static void WriteAsMap(Utf8JsonWriter writer, SyringePropertyList value, JsonSerializerOptions options)
{
writer.WriteStartObject();
foreach (KeyValuePair<string, SyringePropertyBase> entry in value.GetEntries())
{
writer.WritePropertyName(options.PropertyNamingPolicy?.ConvertName(entry.Key) ?? entry.Key);
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions(options);
jsonSerializerOptions.Converters.Add(new SyringePropertyConverter(entry.Key));
JsonSerializer.Serialize(writer, entry.Value, entry.Value.GetType(), jsonSerializerOptions);
}
writer.WriteEndObject();
}
}
}