using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LCGoodies.MonoBehaviors;
using LethalLib.Extras;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LCGoodies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LCGoodies")]
[assembly: AssemblyTitle("LCGoodies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace LCGoodies
{
internal class Configuration
{
public static ConfigEntry<int> walletRarity;
public static ConfigEntry<int> sockRarity;
public static ConfigEntry<int> buttonRarity;
public static ConfigEntry<int> massagerRarity;
public static ConfigEntry<int> beerRarity;
public static ConfigEntry<int> whiskeyRarity;
public static ConfigEntry<bool> alcoholEffects;
public static ConfigEntry<float> beerDrunkess;
public static ConfigEntry<float> beerDrunkessDissipationSpeed;
public static ConfigEntry<float> whiskeyDrunkess;
public static ConfigEntry<float> whiskeyDrunkessDissipationSpeed;
public static ConfigEntry<float> shotgunTrapAmtMax;
public static ConfigEntry<float> gooTrapSpeedDecreaseMultiplier;
public static ConfigEntry<float> gooTrapJumpDecreaseMultiplier;
public static ConfigEntry<float> gooTrapEnemySpeed;
public static ConfigEntry<float> gooTrapAmtMax;
public static ConfigEntry<float> wOffX;
public static ConfigEntry<float> wOffY;
public static ConfigEntry<float> wOffZ;
public static void LoadConfig()
{
walletRarity = Plugin.config.Bind<int>("Scrap", "WalletRarity", 15, "Chance for wallet to spawn. Higher is more likely to spawn.");
sockRarity = Plugin.config.Bind<int>("Scrap", "SockRarity", 15, "Chance for sock to spawn. Higher is more likely to spawn.");
buttonRarity = Plugin.config.Bind<int>("Scrap", "ButtonRarity", 15, "Chance for button to spawn. Higher is more likely to spawn.");
massagerRarity = Plugin.config.Bind<int>("Scrap", "MassagerRarity", 5, "Chance for massager to spawn. Higher is more likely to spawn.");
beerRarity = Plugin.config.Bind<int>("Scrap.Alcohol.Beer", "BeerRarity", 15, "Chance for beer to spawn. Higher is more likely to spawn.");
whiskeyRarity = Plugin.config.Bind<int>("Scrap.Alcohol.Whiskey", "WhiskeyRarity", 3, "Chance for whiskey to spawn. Higher is more likely to spawn.");
shotgunTrapAmtMax = Plugin.config.Bind<float>("Traps.ShotgunTrap", "TrapRarity", 4f, "Higher adds more max traps to the level");
beerDrunkessDissipationSpeed = Plugin.config.Bind<float>("Scrap.Alcohol.Beer", "BeerDrunknessDissipation", 0.3f, "How quickly the drunk effect dissipates when drinking beer");
beerDrunkess = Plugin.config.Bind<float>("Scrap.Alcohol.Beer", "BeerDrunkness", 0.2f, "How drunk you get from beer");
whiskeyDrunkess = Plugin.config.Bind<float>("Scrap.Alcohol.Whiskey", "WhiskeyDrunkness", 2.5f, "How drunk you get from whiskey");
whiskeyDrunkessDissipationSpeed = Plugin.config.Bind<float>("Scrap.Alcohol.Whiskey", "WhiskeyDrunknessDissipation", 0.1f, "How quickly the drunk effect dissipates when drinking whiskey");
gooTrapSpeedDecreaseMultiplier = Plugin.config.Bind<float>("Traps.GooTrap", "SpeedDecreaseMultiplier", 0.15f, "How much your speed gets decreased when in the goo trap");
gooTrapAmtMax = Plugin.config.Bind<float>("Traps.GooTrap", "TrapRarity", 10f, "Higher adds more max traps to the level");
gooTrapJumpDecreaseMultiplier = Plugin.config.Bind<float>("Traps.GooTrap", "JumpDecreaseMultiplier", 0f, "How much your jump force gets decreased when in the trap.");
gooTrapEnemySpeed = Plugin.config.Bind<float>("Traps.GooTrap", "EnemySpeed", 0.65f, "What speed to set enemy acceleration to when they touch the goo trap.");
alcoholEffects = Plugin.config.Bind<bool>("Scrap.Alcohol", "Effects", true, "Alcohol effects on or off. True gets you drunk, false has no effect.");
wOffX = Plugin.config.Bind<float>("Scrap.Alcohol.Whiskey", "OffsetX", 0f, "X Offset of whiskey held in hand.");
wOffY = Plugin.config.Bind<float>("Scrap.Alcohol.Whiskey", "OffsetY", 0f, "Y Offset of whiskey held in hand.");
wOffZ = Plugin.config.Bind<float>("Scrap.Alcohol.Whiskey", "OffsetZ", 0f, "Z Offset of whiskey held in hand.");
}
}
internal class CustomScrap
{
public static void RegisterScrap()
{
LoadNewItem("Assets/Wallet/WalletItem.asset", Configuration.walletRarity.Value);
LoadNewItem("Assets/Dirty Sock/DirtySock.asset", Configuration.sockRarity.Value);
LoadNewItem("Assets/Button/ButtonItem.asset", Configuration.buttonRarity.Value);
string[] array = new string[5] { "Red", "Orange", "Blue", "Green", "Purple" };
string[] array2 = array;
foreach (string text in array2)
{
LoadNewItem("Assets/Massager/MassagerItem" + text + ".asset", Configuration.massagerRarity.Value);
}
LoadAlcoholItem("Assets/Alcohol/BeerItem.asset", Configuration.beerRarity.Value, Configuration.beerDrunkess.Value, Configuration.beerDrunkessDissipationSpeed.Value);
LoadAlcoholItem("Assets/Alcohol/WhiskeyItem.asset", Configuration.whiskeyRarity.Value, Configuration.whiskeyDrunkess.Value, Configuration.whiskeyDrunkessDissipationSpeed.Value);
}
private static void LoadNewItem(string assetPath, int rarity)
{
Item val = Plugin.ab.LoadAsset<Item>(assetPath);
Items.RegisterScrap(val, rarity, (LevelTypes)(-1));
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Plugin.ls.LogInfo((object)("Registered new item '" + ((Object)val).name + "'"));
}
private static void LoadAlcoholItem(string assetPath, int rarity, float drunkness, float drunkRemovalSpeed)
{
Item val = Plugin.ab.LoadAsset<Item>(assetPath);
Alcohol component = val.spawnPrefab.GetComponent<Alcohol>();
component.drunkenness = drunkness;
component.drunkRemovalSpeed = drunkRemovalSpeed;
if (assetPath == "Assets/Alcohol/WhiskeyItem.asset")
{
val.positionOffset.x = Configuration.wOffX.Value;
val.positionOffset.y = Configuration.wOffY.Value;
val.positionOffset.z = Configuration.wOffZ.Value;
}
Items.RegisterScrap(val, rarity, (LevelTypes)(-1));
NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
Plugin.ls.LogInfo((object)("Registered alcohol item " + assetPath));
}
}
internal class CustomTraps
{
public static void RegisterTraps()
{
LoadNewMapObject("Assets/ShotgunTrap/ShotgunTrap.asset", Configuration.shotgunTrapAmtMax.Value);
LoadNewMapObject("Assets/GooTrap/GooTrap.asset", Configuration.gooTrapAmtMax.Value);
}
private static void LoadNewMapObject(string assetPath, float trapAmountMax)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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)
//IL_0043: 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_0052: Expected O, but got Unknown
SpawnableMapObjectDef val = Plugin.ab.LoadAsset<SpawnableMapObjectDef>(assetPath);
Keyframe val2 = default(Keyframe);
((Keyframe)(ref val2))..ctor(0f, 0f);
Keyframe val3 = default(Keyframe);
((Keyframe)(ref val3))..ctor(1f, trapAmountMax);
AnimationCurve rarity = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { val2, val3 });
val.spawnableMapObject.numberToSpawn = rarity;
NetworkPrefabs.RegisterNetworkPrefab(val.spawnableMapObject.prefabToSpawn);
Func<SelectableLevel, AnimationCurve> func = (SelectableLevel level) => rarity;
MapObjects.RegisterMapObject(val, (LevelTypes)(-1), func);
Plugin.ls.LogInfo((object)("Registered trap " + assetPath));
}
}
[BepInPlugin("cloalkteorn.LCGoodies", "LCGoodies", "1.1.2.0")]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "cloalkteorn.LCGoodies";
private const string modName = "LCGoodies";
private const string modVersion = "1.1.2.0";
private readonly Harmony harmony = new Harmony("cloalkteorn.LCGoodies");
private static Plugin Instance;
public static ManualLogSource ls;
public static AssetBundle ab;
public static ConfigFile config;
public static ManualLogSource GetLogSource()
{
return ls;
}
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
ls = Logger.CreateLogSource("cloalkteorn.LCGoodies");
config = ((BaseUnityPlugin)this).Config;
PrepareNetworkPatching();
ab = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("LCGoodies.dll", "goodies"));
Configuration.LoadConfig();
CustomScrap.RegisterScrap();
CustomTraps.RegisterTraps();
ls.LogInfo((object)"Plugin cloalkteorn.LCGoodies is loaded!");
harmony.PatchAll(typeof(Plugin));
}
private void PrepareNetworkPatching()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LCGoodies";
public const string PLUGIN_NAME = "LCGoodies";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace LCGoodies.MonoBehaviors
{
internal class Alcohol : GrabbableObject
{
public float drunkenness;
public float drunkRemovalSpeed;
public AudioSource audioSource;
public AudioClip[] drinkNoises;
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
PlayDrinkNoiseServerRpc();
if (((NetworkBehaviour)this).IsOwner)
{
base.playerHeldBy.activatingItem = buttonDown;
base.playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", buttonDown);
}
((MonoBehaviour)this).StartCoroutine(FinishDrinkAnimation());
}
[ServerRpc(RequireOwnership = false)]
private void PlayDrinkNoiseServerRpc()
{
int random = Random.Range(0, drinkNoises.Length);
PlayDrinkNoiseClientRpc(random);
}
[ClientRpc]
private void PlayDrinkNoiseClientRpc(int random)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
audioSource.PlayOneShot(drinkNoises[random]);
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 1f, 0, false, 0);
WalkieTalkie.TransmitOneShotAudio(audioSource, drinkNoises[random], 1f);
}
private IEnumerator FinishDrinkAnimation()
{
yield return (object)new WaitForSeconds(1f);
if (Configuration.alcoholEffects.Value)
{
PlayerControllerB playerHeldBy = base.playerHeldBy;
playerHeldBy.drunkness += drunkenness;
base.playerHeldBy.drunknessSpeed = drunkRemovalSpeed;
}
base.playerHeldBy.activatingItem = false;
base.playerHeldBy.playerBodyAnimator.SetBool("useTZPItem", false);
base.playerHeldBy.DespawnHeldObject();
}
}
internal class GooTrap : NetworkBehaviour
{
private class LimitEnemySpeed : MonoBehaviour
{
public EnemyAI enemyToSlow;
public float speedLimit;
private void Update()
{
if ((Object)(object)enemyToSlow != (Object)null)
{
enemyToSlow.agent.speed = speedLimit;
}
}
}
private class LimitPlayerSpeed : MonoBehaviour
{
public PlayerControllerB player;
public float slowSpeed;
public float slowJump;
public float defaultSpeed;
public float defaultJump;
private void Update()
{
if ((Object)(object)player != (Object)null)
{
player.movementSpeed = slowSpeed;
player.jumpForce = slowJump;
}
if (player.isPlayerDead)
{
Object.Destroy((Object)(object)this);
}
}
private void OnDestroy()
{
if ((Object)(object)player != (Object)null)
{
player.movementSpeed = defaultSpeed;
player.jumpForce = defaultJump;
}
}
}
public float playerSpeedDecreaseMultiplier;
public float playerJumpDecreaseMultiplier;
public float enemySlowedSpeed;
public AudioSource stickySoundsAudio;
public AudioClip[] stuckSounds;
public AudioClip[] unstuckSounds;
private float playerDefaultMovementSpeed;
private float playerDefaultJumpForce;
private void Start()
{
Plugin.ls.LogInfo((object)"GooTrap starting!");
playerDefaultMovementSpeed = GameNetworkManager.Instance.localPlayerController.movementSpeed;
playerDefaultJumpForce = GameNetworkManager.Instance.localPlayerController.jumpForce;
playerSpeedDecreaseMultiplier = Configuration.gooTrapSpeedDecreaseMultiplier.Value;
playerJumpDecreaseMultiplier = Configuration.gooTrapJumpDecreaseMultiplier.Value;
enemySlowedSpeed = Configuration.gooTrapEnemySpeed.Value;
}
[ServerRpc(RequireOwnership = false)]
private void PlayStickySoundServerRpc(bool stuck)
{
PlayStickySoundClientRpc(stuck);
}
[ClientRpc]
private void PlayStickySoundClientRpc(bool stuck)
{
PlayStickySound(stuck);
}
private void PlayStickySound(bool stuck)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
AudioClip[] array = (stuck ? stuckSounds : unstuckSounds);
int num = Random.Range(0, array.Length);
stickySoundsAudio.PlayOneShot(array[num]);
RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 1f, 0, false, 0);
WalkieTalkie.TransmitOneShotAudio(stickySoundsAudio, array[num], 1f);
}
private void OnTriggerEnter(Collider collider)
{
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
if (((Component)collider).gameObject.CompareTag("Player"))
{
PlayerControllerB component = ((Component)collider).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
LimitPlayerSpeed limitPlayerSpeed = ((Component)component).gameObject.AddComponent<LimitPlayerSpeed>();
limitPlayerSpeed.slowJump = component.jumpForce * playerJumpDecreaseMultiplier;
limitPlayerSpeed.slowSpeed = component.movementSpeed * playerSpeedDecreaseMultiplier;
limitPlayerSpeed.defaultJump = playerDefaultJumpForce;
limitPlayerSpeed.defaultSpeed = playerDefaultMovementSpeed;
limitPlayerSpeed.player = component;
PlayStickySoundServerRpc(stuck: true);
}
}
else
{
if (!((Component)collider).CompareTag("Enemy"))
{
return;
}
EnemyAICollisionDetect component2 = ((Component)collider).gameObject.GetComponent<EnemyAICollisionDetect>();
if ((Object)(object)component2 != (Object)null)
{
EnemyAI mainScript = component2.mainScript;
if (!(mainScript is DressGirlAI) && !(mainScript is BlobAI))
{
NavMeshAgent agent = mainScript.agent;
agent.velocity *= enemySlowedSpeed;
LimitEnemySpeed limitEnemySpeed = ((Component)mainScript).gameObject.AddComponent<LimitEnemySpeed>();
limitEnemySpeed.speedLimit = enemySlowedSpeed;
limitEnemySpeed.enemyToSlow = mainScript;
PlayStickySoundServerRpc(stuck: true);
}
}
}
}
private void OnTriggerExit(Collider collider)
{
if (((Component)collider).gameObject.CompareTag("Player"))
{
PlayerControllerB component = ((Component)collider).gameObject.GetComponent<PlayerControllerB>();
if ((Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
LimitPlayerSpeed component2 = ((Component)component).gameObject.GetComponent<LimitPlayerSpeed>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
PlayStickySoundServerRpc(stuck: false);
}
}
}
else
{
if (!((Component)collider).CompareTag("Enemy"))
{
return;
}
EnemyAICollisionDetect component3 = ((Component)collider).gameObject.GetComponent<EnemyAICollisionDetect>();
if ((Object)(object)component3 != (Object)null)
{
EnemyAI mainScript = component3.mainScript;
LimitEnemySpeed component4 = ((Component)mainScript).gameObject.GetComponent<LimitEnemySpeed>();
if ((Object)(object)component4 != (Object)null)
{
Object.Destroy((Object)(object)component4);
PlayStickySoundServerRpc(stuck: false);
}
}
}
}
}
public class ShotgunTrap : NetworkBehaviour
{
private NetworkVariable<bool> hasTriggered = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private NetworkVariable<bool> shotgunHasFired = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private ManualLogSource mls;
private NetworkVariable<bool> touchingDoor = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);
private GameObject objectTouchingTrigger;
public Transform targetPosition;
public Transform aimLocation;
private LineRenderer lr;
private LineRenderer[] renderers;
public ShotgunItem shotgunObject;
private LayerMask lm;
private void Awake()
{
if (mls == null)
{
mls = Plugin.GetLogSource();
}
}
public override void OnNetworkSpawn()
{
((NetworkBehaviour)this).OnNetworkSpawn();
shotgunObject = null;
if (((NetworkBehaviour)this).IsServer)
{
hasTriggered.Value = false;
shotgunHasFired.Value = false;
return;
}
NetworkVariable<bool> obj = hasTriggered;
obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(TrapTriggered));
NetworkVariable<bool> obj2 = shotgunHasFired;
obj2.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(ShotgunFired));
}
public override void OnNetworkDespawn()
{
((NetworkBehaviour)this).OnNetworkDespawn();
NetworkVariable<bool> obj = hasTriggered;
obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(TrapTriggered));
NetworkVariable<bool> obj2 = shotgunHasFired;
obj2.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(ShotgunFired));
}
private void TrapTriggered(bool prev, bool current)
{
hasTriggered.Value = current;
if (current)
{
DisableLineRenderers();
}
}
private void DisableLineRenderers()
{
LineRenderer[] array = renderers;
foreach (LineRenderer val in array)
{
((Renderer)val).enabled = false;
}
}
private void ShotgunFired(bool prev, bool current)
{
shotgunHasFired.Value = current;
}
private void Start()
{
//IL_004e: 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)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
mls.LogInfo((object)"ShotgunTrap Starting!");
lm = LayerMask.op_Implicit(LayerMask.GetMask(new string[6] { "Player", "Props", "PhysicsObject", "Enemies", "PlayerRagdoll", "EnemiesNotRendered" }));
lr = ((Component)this).gameObject.GetComponent<LineRenderer>();
renderers = ((Component)this).gameObject.GetComponentsInChildren<LineRenderer>();
Transform transform = ((Component)((Component)this).gameObject.transform.Find("Tripwire Locations").Find("Wire Start")).transform;
lr.SetPosition(0, transform.position);
int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault;
int num = LayerMask.NameToLayer("InteractableObject");
collidersAndRoomMaskAndDefault |= 1 << num;
((MonoBehaviour)this).StartCoroutine(SetupTripwire(transform, collidersAndRoomMaskAndDefault));
targetPosition = ((Component)this).gameObject.transform.Find("Shotgun Position");
if (((NetworkBehaviour)this).IsHost)
{
((MonoBehaviour)this).StartCoroutine(FindAndSpawnShotgun());
}
}
private IEnumerator SetupTripwire(Transform wireStart, int layerToUse)
{
yield return (object)new WaitForSeconds(2f);
RaycastHit hit = default(RaycastHit);
if (Physics.Raycast(wireStart.position, wireStart.forward, ref hit, 5000f, layerToUse, (QueryTriggerInteraction)1))
{
if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).collider))
{
yield break;
}
lr.SetPosition(1, ((RaycastHit)(ref hit)).point);
objectTouchingTrigger = ((Component)((RaycastHit)(ref hit)).collider).gameObject;
if (!((Object)(object)objectTouchingTrigger.transform.parent != (Object)null))
{
yield break;
}
bool touchingNormalDoor = ((Object)((Component)objectTouchingTrigger.transform.parent).gameObject).name == "DoorMesh";
bool touchingBigDoor = ((Object)objectTouchingTrigger).name == "BigDoorRight" || ((Object)objectTouchingTrigger).name == "BigDoorLeft";
if (touchingNormalDoor || touchingBigDoor)
{
if (((NetworkBehaviour)this).IsHost)
{
touchingDoor.Value = true;
}
new AnimatedObjectTrigger();
if (touchingNormalDoor)
{
AnimatedObjectTrigger aot2 = ((Component)((RaycastHit)(ref hit)).collider).gameObject.GetComponent<AnimatedObjectTrigger>();
((UnityEvent<bool>)(object)aot2.onTriggerBool).AddListener((UnityAction<bool>)DoorInteract);
}
else if (touchingBigDoor)
{
AnimatedObjectTrigger aot2 = ((Component)((Component)((RaycastHit)(ref hit)).collider).gameObject.transform.parent).gameObject.GetComponent<AnimatedObjectTrigger>();
((UnityEvent<bool>)(object)aot2.onTriggerBool).AddListener((UnityAction<bool>)DoorInteract);
}
}
}
else
{
lr.SetPosition(1, wireStart.forward * 5000f);
}
}
private void DoorInteract(bool newBool)
{
if (touchingDoor.Value && !hasTriggered.Value)
{
TriggerTrap();
((UnityEvent<bool>)(object)objectTouchingTrigger.GetComponent<AnimatedObjectTrigger>().onTriggerBool).RemoveListener((UnityAction<bool>)DoorInteract);
if (((NetworkBehaviour)this).IsHost)
{
touchingDoor.Value = false;
}
}
}
private IEnumerator FindAndSpawnShotgun()
{
yield return (object)new WaitForSeconds(1f);
SelectableLevel level2 = StartOfRound.Instance.levels.First((SelectableLevel level) => level.PlanetName == "8 Titan");
SpawnableEnemyWithRarity nutcracker = level2.Enemies.Find((SpawnableEnemyWithRarity enemy) => enemy.enemyType.enemyName == "Nutcracker");
GameObject shotgun = nutcracker.enemyType.enemyPrefab.gameObject.GetComponent<NutcrackerEnemyAI>().gunPrefab;
if ((Object)(object)shotgun != (Object)null)
{
GameObject shotgunObject = Object.Instantiate<GameObject>(shotgun, targetPosition.position, targetPosition.rotation, targetPosition);
NetworkObject no = shotgunObject.GetComponent<NetworkObject>();
no.Spawn(false);
ShotgunItem sg = ((Component)no).gameObject.GetComponent<ShotgunItem>();
Item props = ((GrabbableObject)sg).itemProperties;
_ = props.rotationOffset;
_ = props.positionOffset;
SetShotgunServerRpc(NetworkObjectReference.op_Implicit(no));
}
}
[ServerRpc]
private void SetShotgunServerRpc(NetworkObjectReference gun)
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
NetworkObject val = default(NetworkObject);
if (((NetworkObjectReference)(ref gun)).TryGet(ref val, (NetworkManager)null))
{
ShotgunItem component = ((Component)val).gameObject.GetComponent<ShotgunItem>();
int num = 50;
((GrabbableObject)component).SetScrapValue(num);
int num2 = Random.Range(0, 100);
bool safety = (component.safetyOn = num2 >= 94);
((GrabbableObject)component).grabbable = true;
int numShells = 0;
int num3 = Random.Range(0, 100);
if (num3 < 84)
{
numShells = (component.shellsLoaded = Random.Range(1, 3));
}
else
{
component.shellsLoaded = 0;
}
((GrabbableObject)component).itemProperties.syncGrabFunction = true;
((GrabbableObject)component).itemProperties.syncDiscardFunction = true;
((GrabbableObject)component).itemProperties.syncInteractLRFunction = true;
((GrabbableObject)component).itemProperties.syncUseFunction = true;
shotgunObject = component;
SetShotgunClientRpc(NetworkObjectReference.op_Implicit(val), safety, numShells, syncGrab: true, num);
}
}
[ClientRpc]
public void SetShotgunClientRpc(NetworkObjectReference gun, bool safety, int numShells, bool syncGrab, int value)
{
NetworkObject val = default(NetworkObject);
if (((NetworkObjectReference)(ref gun)).TryGet(ref val, (NetworkManager)null))
{
shotgunObject = ((Component)val).gameObject.GetComponent<ShotgunItem>();
((GrabbableObject)shotgunObject).parentObject = targetPosition;
((Component)shotgunObject).transform.parent = targetPosition;
shotgunObject.safetyOn = safety;
shotgunObject.shellsLoaded = numShells;
((GrabbableObject)shotgunObject).itemProperties.syncGrabFunction = syncGrab;
((GrabbableObject)shotgunObject).SetScrapValue(value);
}
}
private void Update()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//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_003e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
if (!hasTriggered.Value)
{
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(lr.GetPosition(0), ((Component)lr).transform.TransformDirection(Vector3.forward), ref val, Vector3.Distance(lr.GetPosition(0), lr.GetPosition(1)), LayerMask.op_Implicit(lm)) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider))
{
TriggerTripped(((RaycastHit)(ref val)).collider);
}
}
else if (hasTriggered.Value && ((Renderer)renderers[0]).enabled)
{
DisableLineRenderers();
}
if ((Object)(object)shotgunObject != (Object)null && (((GrabbableObject)shotgunObject).heldByPlayerOnServer || ((GrabbableObject)shotgunObject).isHeld) && (Object)(object)((GrabbableObject)shotgunObject).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
GrabbedGunServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
public void GrabbedGunServerRpc()
{
if ((Object)(object)shotgunObject != (Object)null)
{
shotgunObject = null;
}
GrabbedGunClientRpc();
}
[ClientRpc]
public void GrabbedGunClientRpc()
{
if ((Object)(object)shotgunObject != (Object)null)
{
shotgunObject = null;
}
}
private void TriggerTripped(Collider other)
{
if (!hasTriggered.Value && (Object)(object)((Component)other).gameObject != (Object)(object)objectTouchingTrigger)
{
TriggerTrap();
}
}
private void TriggerTrap()
{
if (!hasTriggered.Value)
{
FireGunServerRpc();
DisableLineRenderers();
}
}
[ServerRpc(RequireOwnership = false)]
public void FireGunServerRpc()
{
hasTriggered.Value = true;
FireGunClientRpc();
}
[ClientRpc]
public void FireGunClientRpc()
{
FireGun();
}
private bool FireGun()
{
if ((Object)(object)shotgunObject == (Object)null)
{
return false;
}
if (((NetworkBehaviour)this).IsHost && hasTriggered.Value && !shotgunHasFired.Value)
{
shotgunHasFired.Value = true;
if (shotgunObject.safetyOn || shotgunObject.shellsLoaded == 0)
{
shotgunObject.gunAudio.PlayOneShot(shotgunObject.gunSafetySFX);
}
else
{
shotgunObject.ShootGunAndSync(false);
}
}
return (Object)(object)shotgunObject != (Object)null;
}
}
}