using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AK;
using Agents;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using GameData;
using HarmonyLib;
using Player;
using TargetTransforms;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("GlowStickOnBodyRestored")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GlowStickOnBodyRestored")]
[assembly: AssemblyTitle("GlowStickOnBodyRestored")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GlowStickOnBodyRestored;
[BepInPlugin("HawChow.GlowStickOnBodyRestored", "GlowStickOnBody Restored", "1.0.0")]
public class EntryPoint : BasePlugin
{
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("HawChow.GlowStickOnBodyRestored").PatchAll(typeof(EntryPoint).Assembly);
((BasePlugin)this).Log.LogInfo((object)"[GSOB-Restored] 加载成功,荧光棒随身挂载已就绪");
}
}
internal static class Patches
{
[HarmonyPatch(typeof(ThrowingWeapon), "Update")]
internal static class Patch_OnThrowingWeaponUpdate
{
public static void Postfix(ThrowingWeapon __instance)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (__instance.m_ready && !__instance.m_inThrowCharge && !__instance.m_inThrowRelease && !__instance.m_hasThrown && ((ItemEquippable)__instance).IsEnabled && !((Object)(object)((Item)__instance).Owner == (Object)null) && !((ItemEquippable)__instance).FireButtonPressed && ((ItemEquippable)__instance).CanWield && InputMapper.GetButtonDown.Invoke((InputAction)7, ((Item)__instance).Owner.InputFilter) && ((GameDataBlockBase<ItemDataBlock>)(object)((Item)__instance).ItemDataBlock).name.Contains("GlowStick"))
{
FakeThrow(__instance);
__instance.m_hasThrown = true;
}
}
private static void FakeThrow(ThrowingWeapon glowstick)
{
//IL_0011: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
((ItemEquippable)glowstick).Sound.Post(EVENTS.GLOWSTICKBOUNCE, ((Component)glowstick).transform.position);
PlayerBackpackManager.LocalBackpack.AmmoStorage.UpdateBulletsInPack((AmmoType)5, -1);
ItemReplicationManager.ThrowItem(new pItemData
{
itemID_gearCRC = ((GameDataBlockBase<ItemDataBlock>)(object)((Item)glowstick).ItemDataBlock).persistentID
}, (delItemCallback)null, (ItemMode)3, ZeroPos, ((Component)glowstick).transform.rotation, ((Item)glowstick).Owner.FPSCamera.CameraRayDir * 0f, ZeroPos, ((Agent)((Item)glowstick).Owner).CourseNode, ((Item)glowstick).Owner);
glowstick.m_ready = false;
glowstick.m_waitingForReady = true;
glowstick.m_gotoReadyTimer = Clock.Time + 0.5f;
((Item)glowstick).Owner.FPItemHolder.ItemHiddenTrigger = true;
((Item)glowstick).Owner.Sync.SendThrowStatus((StatusEnum)2, false);
}
}
[HarmonyPatch(typeof(ItemReplicationManager), "OnItemSpawn")]
internal static class Patch_OnItemSpawn
{
public static void Postfix(ItemReplicationManager __instance, pItemSpawnData spawnData, ItemReplicator replicator)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if (((Object)((Component)replicator.Item).gameObject).name.Contains("Consumable_GlowStick_Instance") && spawnData.position.x == 0f && spawnData.position.y == -2000f && spawnData.position.z == 0f)
{
StickManager.SetParent(replicator.Item);
}
}
}
[HarmonyPatch(typeof(GlowstickInstance), "Update")]
internal static class Patch_Update
{
public static void Postfix(GlowstickInstance __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Invalid comparison between Unknown and I4
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Invalid comparison between Unknown and I4
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Invalid comparison between Unknown and I4
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
int instanceID = ((Object)((Component)((Component)__instance).transform).gameObject).GetInstanceID();
if (!StickManager.IsLocalStick.ContainsKey(instanceID))
{
return;
}
PlayerAgent owner = ((Item)__instance).Owner;
GameObject gameObject = ((Component)((Component)__instance).transform).gameObject;
if ((int)__instance.m_state == 1 && __instance.m_progression == 0f)
{
__instance.s_lightLifeTime *= 0.5f;
((LightBase)__instance.m_light).Range = __instance.s_lightRange * (StickManager.IsLocalStick[instanceID] ? 4f : 2f);
}
if (!StickManager.IsValidStick[instanceID] && (int)__instance.m_state == 2)
{
__instance.m_progression = 1f;
__instance.m_progressionSpeed = 1f / 3f;
__instance.m_state = (eFadeState)3;
}
if ((int)__instance.m_state == 4)
{
gameObject.transform.parent = null;
((Component)__instance.m_light).transform.position = ZeroPos;
gameObject.transform.localPosition = ZeroPos;
}
else if (StickManager.IsLocalStick[instanceID] && ((Agent)owner).IsLocallyOwned)
{
Vector3 position = owner.FPSCamera.Position;
position.y -= 0.8f;
Vector3 val = position;
Vector3 val2 = ((LookCameraController)owner.FPSCamera).FlatForward;
position = val + ((Vector3)(ref val2)).normalized * -0.3f;
Vector3 val3 = position;
val2 = ((LookCameraController)owner.FPSCamera).FlatRight;
position = val3 + ((Vector3)(ref val2)).normalized * 0.4f;
if (position.y < ((Agent)owner).Position.y + 0.2f)
{
position.y = ((Agent)owner).Position.y + 0.2f;
}
((Component)__instance.m_light).transform.position = position;
}
}
}
[HarmonyPatch(typeof(GlowstickInstance), "OnDespawn")]
internal static class Patch_OnDespawn
{
public static void Postfix(GlowstickInstance __instance)
{
int instanceID = ((Object)((Component)((Component)__instance).transform).gameObject).GetInstanceID();
if (StickManager.IsLocalStick.ContainsKey(instanceID))
{
StickManager.IsLocalStick.Remove(instanceID);
StickManager.IsValidStick.Remove(instanceID);
}
}
}
[HarmonyPatch(typeof(GameStateManager), "DoChangeState")]
internal static class Patch_DoChangeState
{
public static void Postfix(GameStateManager __instance, eGameStateName nextState)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Expected I4, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
int num = (int)nextState;
if (num == 10 || num == 11)
{
StickManager.IsLocalStick.Clear();
StickManager.IsValidStick.Clear();
}
if (num == 7 || num == 10)
{
CellSound.Post(EVENTS.GLOWSTICKBOUNCE, Vector3.zero - Vector3.up * 100f);
}
}
}
private static readonly Vector3 ZeroPos = new Vector3(0f, -2000f, 0f);
}
internal static class StickManager
{
public static readonly Dictionary<int, bool> IsLocalStick = new Dictionary<int, bool>();
public static readonly Dictionary<int, bool> IsValidStick = new Dictionary<int, bool>();
private static readonly Vector3 Pos1 = new Vector3(0f, 3f, 0f);
private static readonly Vector3 Pos2 = new Vector3(0f, 1f, 0f);
private static readonly Vector3 PosLeg = new Vector3(-0.14f, 0f, 0.1f);
private static readonly Vector3 AngLeg = new Vector3(0f, 90f, 100f);
private static readonly Vector3 Scale = new Vector3(1E-05f, 1E-05f, 1E-05f);
public static void SetParent(Item item)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
PlayerAgent owner = item.Owner;
if ((Object)(object)owner == (Object)null)
{
return;
}
_ = ((Component)((Component)owner).transform).gameObject;
GameObject gameObject = ((Component)((Component)item).transform).gameObject;
BoxCollider component = gameObject.GetComponent<BoxCollider>();
if ((Object)(object)component != (Object)null)
{
((Collider)component).enabled = false;
}
Rigidbody component2 = gameObject.GetComponent<Rigidbody>();
if ((Object)(object)component2 != (Object)null)
{
component2.mass = 0f;
component2.velocity = Vector3.zero;
component2.detectCollisions = false;
component2.useGravity = false;
component2.freezeRotation = true;
}
foreach (GlowstickInstance componentsInChild in ((Component)owner).gameObject.GetComponentsInChildren<GlowstickInstance>())
{
int instanceID = ((Object)((Component)((Component)componentsInChild).transform).gameObject).GetInstanceID();
if (IsValidStick.ContainsKey(instanceID))
{
IsValidStick[instanceID] = false;
}
}
gameObject.transform.parent = ((Component)owner).transform;
IsValidStick[((Object)gameObject).GetInstanceID()] = true;
if (((Agent)owner).IsLocallyOwned)
{
gameObject.transform.localPosition = Pos1;
IsLocalStick[((Object)gameObject).GetInstanceID()] = true;
gameObject.transform.localScale = Scale;
return;
}
gameObject.transform.localPosition = Pos2;
IsLocalStick[((Object)gameObject).GetInstanceID()] = false;
foreach (TargetTransform componentsInChild2 in ((Component)owner).GetComponentsInChildren<TargetTransform>(true))
{
if (((Object)((Component)componentsInChild2).gameObject).name == "RightUpperLeg_Roll")
{
gameObject.transform.parent = ((Component)componentsInChild2).gameObject.transform;
gameObject.transform.localPosition = PosLeg;
gameObject.transform.localEulerAngles = AngLeg;
break;
}
}
}
}