using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Redystum.TheKirby.NetcodePatcher;
using TheKirby.Configuration;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Redystum.TheKirby")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+e72b6851014a86534a4bc63a90fc2a718c9e43e9")]
[assembly: AssemblyProduct("TheKirby")]
[assembly: AssemblyTitle("Redystum.TheKirby")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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 TheKirby
{
internal class ExampleEnemyAI : EnemyAI
{
private enum State
{
IdellingState,
Patrolling,
FollowingPlayer,
StickingInFrontOfPlayer,
SwallowingInProgress
}
public Transform turnCompass;
public Transform attackArea;
public AudioClip attackSFX;
public AudioClip fullStateSFX;
public Collider SwallowCollider;
private float timeSinceNewRandPos;
private Vector3 positionRandomness;
private Vector3 StalkPos;
private Random enemyRandom;
[SerializeField]
private string startWalkTrigger = "startWalk";
[SerializeField]
private string stopWalkTrigger = "stopWalk";
[SerializeField]
private string startAttackTrigger = "startAttack";
[SerializeField]
private string fullStateTrigger = "full";
[SerializeField]
private string deathTrigger = "death";
private int detectionRange = 20;
private int maxSwallowedPlayers = 2;
private bool useItem;
private ulong[] swallowedPlayers = new ulong[99];
private int swallowedPlayersIndex;
private bool isFullPlayed;
private bool IsAttacking;
private Item kirbyItem;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)"===========");
Plugin.Logger.LogInfo((object)text);
Plugin.Logger.LogInfo((object)"===========");
}
public override void Start()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Start();
DoAnimationClientRpc(startWalkTrigger);
timeSinceNewRandPos = 0f;
positionRandomness = new Vector3(0f, 0f, 0f);
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
detectionRange = Plugin.BoundConfig.DetectionRange.Value;
maxSwallowedPlayers = Plugin.BoundConfig.MaxSwallowPlayers.Value;
useItem = Plugin.BoundConfig.UseItem.Value;
kirbyItem = StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => item.itemName.ToLower() == "kirby");
base.agent.speed = 3f;
base.currentBehaviourStateIndex = 1;
((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
}
public override void Update()
{
//IL_0050: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (!base.isEnemyDead)
{
timeSinceNewRandPos += Time.deltaTime;
int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
if ((Object)(object)base.targetPlayer != (Object)null && currentBehaviourStateIndex == 3)
{
turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 4f * Time.deltaTime);
}
if (base.stunNormalizedTimer > 0f)
{
base.agent.speed = 0f;
}
}
}
public override void DoAIInterval()
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).DoAIInterval();
if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
{
return;
}
if (swallowedPlayersIndex >= maxSwallowedPlayers && !isFullPlayed)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
((MonoBehaviour)this).StartCoroutine(StopWalking(-1f));
return;
}
switch (base.currentBehaviourStateIndex)
{
case 1:
if (FoundClosestPlayerInRange(detectionRange, 3f))
{
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
}
break;
case 2:
if ((Object)(object)base.targetPlayer != (Object)null && Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 2f)
{
((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
}
else if ((Object)(object)base.targetPlayer != (Object)null)
{
((MonoBehaviour)this).StartCoroutine(SwallowingAttack());
}
break;
case 3:
StickingInFrontOfPlayer();
break;
case 0:
case 4:
break;
}
}
private bool FoundClosestPlayerInRange(float range, float senseRange)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).TargetClosestPlayer(1.5f, true, 70f);
if ((Object)(object)base.targetPlayer == (Object)null)
{
((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f);
range = senseRange;
}
if ((Object)(object)base.targetPlayer != (Object)null)
{
return Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < range;
}
return false;
}
private void StickingInFrontOfPlayer()
{
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)base.targetPlayer == (Object)null) && ((NetworkBehaviour)this).IsOwner && timeSinceNewRandPos > 0.7f)
{
timeSinceNewRandPos = 0f;
if (enemyRandom.Next(0, 5) != 0)
{
positionRandomness = new Vector3((float)enemyRandom.Next(-2, 2), 0f, (float)enemyRandom.Next(-2, 2));
StalkPos = ((Component)base.targetPlayer).transform.position - Vector3.Scale(new Vector3(-5f, 0f, -5f), ((Component)base.targetPlayer).transform.forward) + positionRandomness;
}
((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
}
}
private IEnumerator SwallowingAttack()
{
((EnemyAI)this).SwitchToBehaviourClientRpc(4);
StalkPos = ((Component)base.targetPlayer).transform.position;
((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
yield return (object)new WaitForSeconds(0.5f);
if (base.isEnemyDead)
{
yield break;
}
if (swallowedPlayersIndex >= maxSwallowedPlayers)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
yield break;
}
SwallowingAttackHitClientRpc();
if (base.currentBehaviourStateIndex == 4)
{
if (swallowedPlayersIndex >= maxSwallowedPlayers && !isFullPlayed)
{
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
((MonoBehaviour)this).StartCoroutine(StopWalking(-1f));
}
else
{
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
}
}
}
[ClientRpc]
public void SwallowingAttackHitClientRpc()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4244286314u, val, (RpcDelivery)0);
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4244286314u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
{
return;
}
int num = 8;
Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
if (array.Length != 0 && !IsAttacking)
{
PlayerControllerB val3 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(array[0], false, false);
if ((Object)(object)val3 != (Object)null)
{
IsAttacking = true;
DoAnimationClientRpc(startAttackTrigger);
((MonoBehaviour)this).StartCoroutine(WaitToPlaySound(0.5f, attackSFX));
((MonoBehaviour)this).StartCoroutine(WaitToDamage(2f));
((MonoBehaviour)this).StartCoroutine(StopWalking(10f));
((EnemyAI)this).SwitchToBehaviourClientRpc(2);
}
}
}
private IEnumerator WaitToPlaySound(float time, AudioClip clip)
{
yield return (object)new WaitForSeconds(time);
base.creatureVoice.PlayOneShot(clip);
}
private IEnumerator WaitToDamage(float time)
{
yield return (object)new WaitForSeconds(time);
if ((Object)(object)SwallowCollider != (Object)null && SwallowCollider.enabled)
{
Bounds bounds = SwallowCollider.bounds;
Vector3 center = ((Bounds)(ref bounds)).center;
bounds = SwallowCollider.bounds;
Collider[] array = Physics.OverlapBox(center, ((Bounds)(ref bounds)).extents, ((Component)SwallowCollider).transform.rotation, 8);
if (array.Length != 0)
{
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(array[0], false, false);
swallowedPlayers[swallowedPlayersIndex] = val.playerClientId;
swallowedPlayersIndex++;
val.KillPlayer(Vector3.zero, false, (CauseOfDeath)5, 0, Vector3.zero);
}
}
}
public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
{
((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, -1);
if (base.isEnemyDead)
{
return;
}
base.enemyHP -= force;
if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0 && !base.isEnemyDead)
{
((MonoBehaviour)this).StopCoroutine(SwallowingAttack());
((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
base.creatureVoice.Stop();
DoAnimationClientRpc(deathTrigger);
((EnemyAI)this).KillEnemy(false);
if (useItem)
{
((MonoBehaviour)this).StartCoroutine(SpawnItem());
}
((MonoBehaviour)this).StartCoroutine(DespawnAfter(3f));
}
}
private IEnumerator SpawnItem()
{
yield return (object)new WaitForSeconds(3f);
Vector3 val = ((Component)this).transform.position + new Vector3(0f, 1f, 0f);
Quaternion rotation = ((Component)this).transform.rotation;
GameObject val2 = Object.Instantiate<GameObject>(kirbyItem.spawnPrefab, val, rotation, RoundManager.Instance.spawnedScrapContainer);
GrabbableObject component = val2.GetComponent<GrabbableObject>();
component.startFallingPosition = val;
component.targetFloorPosition = component.GetItemFloorPosition(((Component)this).transform.position);
component.SetScrapValue(Random.Range(Plugin.BoundConfig.MinValue.Value, Plugin.BoundConfig.MaxValue.Value));
KirbyItem component2 = val2.GetComponent<KirbyItem>();
component2.swallowedPlayersByEnemy = swallowedPlayers;
component2.swallowedPlayersByEnemyIndex = swallowedPlayersIndex;
((NetworkBehaviour)component).NetworkObject.Spawn(false);
}
[ClientRpc]
public void DoAnimationClientRpc(string animationName)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2796065679u, val, (RpcDelivery)0);
bool flag = animationName != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
}
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2796065679u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
base.creatureAnimator.SetTrigger(animationName);
}
}
private IEnumerator StopWalking(float time)
{
if (time == -1f && !isFullPlayed)
{
base.agent.isStopped = true;
DoAnimationClientRpc(fullStateTrigger);
base.creatureVoice.PlayOneShot(fullStateSFX);
((EnemyAI)this).StopSearch(base.currentSearch, true);
isFullPlayed = true;
yield break;
}
((EnemyAI)this).SwitchToBehaviourClientRpc(0);
base.agent.speed = 0f;
DoAnimationClientRpc(stopWalkTrigger);
yield return (object)new WaitForSeconds(time);
if (base.currentBehaviourStateIndex == 0 && !isFullPlayed)
{
((MonoBehaviour)this).StartCoroutine(StopWalking(-1f));
yield break;
}
DoAnimationClientRpc(startWalkTrigger);
base.agent.speed = 3f;
((EnemyAI)this).SwitchToBehaviourClientRpc(1);
IsAttacking = false;
}
private IEnumerator DespawnAfter(float time)
{
yield return (object)new WaitForSeconds(time);
base.thisNetworkObject.Despawn(true);
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_ExampleEnemyAI()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(4244286314u, new RpcReceiveHandler(__rpc_handler_4244286314));
NetworkManager.__rpc_func_table.Add(2796065679u, new RpcReceiveHandler(__rpc_handler_2796065679));
}
private static void __rpc_handler_4244286314(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
target.__rpc_exec_stage = (__RpcExecStage)2;
((ExampleEnemyAI)(object)target).SwallowingAttackHitClientRpc();
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2796065679(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string animationName = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
}
target.__rpc_exec_stage = (__RpcExecStage)2;
((ExampleEnemyAI)(object)target).DoAnimationClientRpc(animationName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "ExampleEnemyAI";
}
}
internal class SwallowedItens
{
public string name;
public int scrapValue;
public float weight;
}
internal class KirbyItem : PhysicsProp
{
public AudioClip MusicSFX;
public AudioClip NavEnterSFX;
public AudioClip SwallowSFX;
public AudioClip PukeSFX;
public Animator KirbyAnimator;
public AudioClip FullSFX;
public AudioSource AudioSourceComponent;
public Collider SwallowCollider;
[SerializeField]
private string startAttackTrigger = "startAttack";
[SerializeField]
private string fullStaterigger = "full";
[SerializeField]
private string stopWalkingTrigger = "stopWalking";
private bool IsPlayingMusic;
private bool IsSwallowing;
private SwallowedItens[] SwallowedItems = new SwallowedItens[99];
private int SwallowedItemsIndex;
private int MaxWeight = 100;
private float currentWeight;
private int currentValue;
private PlayerControllerB lastOwner;
public int defaultValue;
public ulong[] swallowedPlayersByEnemy = new ulong[99];
public int swallowedPlayersByEnemyIndex;
public override void Start()
{
((GrabbableObject)this).Start();
if ((Object)(object)AudioSourceComponent == (Object)null)
{
AudioSourceComponent = ((Component)this).gameObject.GetComponent<AudioSource>();
}
AudioSourceComponent.outputAudioMixerGroup = SoundManager.Instance.diageticMixer.FindMatchingGroups("SFX")[0];
MaxWeight = Plugin.BoundConfig.MaxWeight.Value;
if (defaultValue == 0)
{
defaultValue = Random.Range(Plugin.BoundConfig.MinValue.Value, Plugin.BoundConfig.MaxValue.Value);
}
currentValue = defaultValue;
((GrabbableObject)this).SetScrapValue(defaultValue);
}
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text, bool soround = false)
{
if (soround)
{
text = "\n========\n========\n" + text + "\n========\n========\n";
}
Plugin.Logger.LogInfo((object)text);
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (buttonDown)
{
IsSwallowing = true;
((MonoBehaviour)this).StartCoroutine(Swallow());
}
}
[ClientRpc]
public void DoAnimationClientRpc(string animationName)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager == null || !networkManager.IsListening)
{
return;
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
{
ClientRpcParams val = default(ClientRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(108381002u, val, (RpcDelivery)0);
bool flag = animationName != null;
((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
if (flag)
{
((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
}
((NetworkBehaviour)this).__endSendClientRpc(ref val2, 108381002u, val, (RpcDelivery)0);
}
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
{
KirbyAnimator.SetTrigger(animationName);
}
}
public void PlaySound(AudioClip clip)
{
AudioSourceComponent.PlayOneShot(clip);
}
private IEnumerator Swallow()
{
DoAnimationClientRpc(startAttackTrigger);
PlaySound(SwallowSFX);
yield return (object)new WaitForSeconds(1.5f);
IsSwallowing = false;
}
public override void OnBroughtToShip()
{
((GrabbableObject)this).OnBroughtToShip();
PlaySound(NavEnterSFX);
}
public override void ItemInteractLeftRight(bool right)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_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)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: 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_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).ItemInteractLeftRight(right);
if ((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null)
{
return;
}
if (!right)
{
PlaySound(PukeSFX);
Vector3 forward = ((Component)((GrabbableObject)this).playerHeldBy).transform.forward;
Vector3 val = ((Component)this).transform.position + forward;
for (int j = 0; j < swallowedPlayersByEnemyIndex; j++)
{
ulong num = swallowedPlayersByEnemy[j];
PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[num];
val2.SpawnDeadBody((int)num, val, 5, val2, 0, (Transform)null, default(Vector3));
}
swallowedPlayersByEnemyIndex = 0;
swallowedPlayersByEnemy = new ulong[99];
if (SwallowedItemsIndex > 0)
{
int i;
for (i = 0; i < SwallowedItemsIndex; i++)
{
Item val3 = StartOfRound.Instance.allItemsList.itemsList.Find((Item item) => item.itemName == SwallowedItems[i].name);
if ((Object)(object)val3 != (Object)null)
{
GameObject val4 = Object.Instantiate<GameObject>(val3.spawnPrefab, val, Quaternion.identity, RoundManager.Instance.spawnedScrapContainer);
GrabbableObject component = val4.GetComponent<GrabbableObject>();
component.startFallingPosition = val;
component.targetFloorPosition = component.GetItemFloorPosition(((Component)this).transform.position);
component.SetScrapValue(SwallowedItems[i].scrapValue);
component.itemProperties.weight = SwallowedItems[i].weight;
((NetworkBehaviour)component).NetworkObject.Spawn(false);
}
}
PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
playerHeldBy.carryWeight -= currentWeight;
SwallowedItemsIndex = 0;
currentWeight = 0f;
currentValue = defaultValue;
((GrabbableObject)this).SetScrapValue(defaultValue);
DoAnimationClientRpc(stopWalkingTrigger);
}
PlayerControllerB playerHeldBy2 = ((GrabbableObject)this).playerHeldBy;
playerHeldBy2.carryWeight -= currentWeight;
SwallowedItemsIndex = 0;
currentWeight = 0f;
}
else
{
if (IsPlayingMusic)
{
AudioSourceComponent.Stop();
}
else
{
PlaySound(MusicSFX);
}
IsPlayingMusic = !IsPlayingMusic;
string text = ((!IsPlayingMusic) ? "Play: [E]" : "Stop: [E]");
if (((NetworkBehaviour)this).IsOwner)
{
HUDManager.Instance.ChangeControlTip(2, text, false);
}
}
}
public override void EquipItem()
{
((PhysicsProp)this).EquipItem();
((GrabbableObject)this).playerHeldBy.equippedUsableItemQE = true;
if (((NetworkBehaviour)this).IsOwner)
{
HUDManager.Instance.DisplayTip("To use the Kirby:", "Press LMB to swallow scrap (max. 3), and Q to puke them on the ground.", false, true, "LCTip_UseManual");
HUDManager.Instance.ChangeControlTip(3, "Puke: [Q]", false);
}
}
public override void GrabItem()
{
//IL_0045: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).GrabItem();
string text = ((!IsPlayingMusic) ? "Play: [E]" : "Stop: [E]");
if (((NetworkBehaviour)this).IsOwner)
{
HUDManager.Instance.ChangeControlTip(2, text, false);
}
((GrabbableObject)this).itemProperties.positionOffset = new Vector3(-0.2f, -0.1f, -0.2f);
((GrabbableObject)this).itemProperties.rotationOffset = new Vector3(-90f, 180f, 100f);
lastOwner = ((GrabbableObject)this).playerHeldBy;
PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
playerHeldBy.carryWeight += currentWeight;
}
public override void PlayDropSFX()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).PlayDropSFX();
((GrabbableObject)this).itemProperties.positionOffset = new Vector3(0f, 0f, 0f);
((GrabbableObject)this).itemProperties.rotationOffset = new Vector3(0f, 0f, 0f);
}
public override void DiscardItem()
{
((GrabbableObject)this).DiscardItem();
PlayerControllerB obj = lastOwner;
obj.carryWeight -= currentWeight;
}
public override void Update()
{
//IL_0038: 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_0040: 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_0050: 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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
((GrabbableObject)this).Update();
if (!((Object)(object)SwallowCollider != (Object)null) || !SwallowCollider.enabled || !IsSwallowing)
{
return;
}
Bounds bounds = SwallowCollider.bounds;
Vector3 center = ((Bounds)(ref bounds)).center;
bounds = SwallowCollider.bounds;
Collider[] array = Physics.OverlapBox(center, ((Bounds)(ref bounds)).extents, ((Component)SwallowCollider).transform.rotation, LayerMask.GetMask(new string[1] { "Props" }));
if (array.Length == 0)
{
return;
}
Collider[] array2 = array;
foreach (Collider val in array2)
{
if (!((Object)(object)val == (Object)(object)SwallowCollider))
{
if (currentWeight > (float)MaxWeight)
{
PlaySound(FullSFX);
DoAnimationClientRpc(fullStaterigger);
break;
}
GrabbableObject component = ((Component)val).GetComponent<GrabbableObject>();
if ((Object)(object)component != (Object)null)
{
SwallowedItems[SwallowedItemsIndex] = new SwallowedItens
{
name = component.itemProperties.itemName,
scrapValue = component.scrapValue,
weight = component.itemProperties.weight
};
SwallowedItemsIndex++;
float num = Mathf.Clamp(component.itemProperties.weight - 1f, 0f, 10f);
currentWeight += num;
PlayerControllerB playerHeldBy = ((GrabbableObject)this).playerHeldBy;
playerHeldBy.carryWeight += num;
currentValue += component.scrapValue;
((GrabbableObject)this).SetScrapValue(currentValue);
DespawnItemServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)component));
}
}
}
}
[ServerRpc(RequireOwnership = false)]
public void DespawnItemServerRpc(NetworkBehaviourReference grabbableRef)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2105782352u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref grabbableRef, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2105782352u, val, (RpcDelivery)0);
}
GrabbableObject val3 = default(GrabbableObject);
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviourReference)(ref grabbableRef)).TryGet<GrabbableObject>(ref val3, (NetworkManager)null))
{
DespawnItem(((Component)val3).gameObject);
}
}
}
private void DespawnItem(GameObject item)
{
NetworkObject component = item.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
component.Despawn(true);
}
}
[ServerRpc(RequireOwnership = false)]
public void SpawnItemServerRpc(NetworkBehaviourReference grabbableRef)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Invalid comparison between Unknown and I4
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
{
ServerRpcParams val = default(ServerRpcParams);
FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2158219958u, val, (RpcDelivery)0);
((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref grabbableRef, default(ForNetworkSerializable));
((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2158219958u, val, (RpcDelivery)0);
}
GrabbableObject item = default(GrabbableObject);
if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && ((NetworkBehaviourReference)(ref grabbableRef)).TryGet<GrabbableObject>(ref item, (NetworkManager)null))
{
SpawnItem(item);
}
}
}
private void SpawnItem(GrabbableObject item)
{
NetworkObject component = ((Component)item).GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null)
{
component.Spawn(false);
}
}
protected override void __initializeVariables()
{
((PhysicsProp)this).__initializeVariables();
}
[RuntimeInitializeOnLoadMethod]
internal static void InitializeRPCS_KirbyItem()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
NetworkManager.__rpc_func_table.Add(108381002u, new RpcReceiveHandler(__rpc_handler_108381002));
NetworkManager.__rpc_func_table.Add(2105782352u, new RpcReceiveHandler(__rpc_handler_2105782352));
NetworkManager.__rpc_func_table.Add(2158219958u, new RpcReceiveHandler(__rpc_handler_2158219958));
}
private static void __rpc_handler_108381002(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
bool flag = default(bool);
((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
string animationName = null;
if (flag)
{
((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
}
target.__rpc_exec_stage = (__RpcExecStage)2;
((KirbyItem)(object)target).DoAnimationClientRpc(animationName);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2105782352(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkBehaviourReference grabbableRef = default(NetworkBehaviourReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref grabbableRef, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((KirbyItem)(object)target).DespawnItemServerRpc(grabbableRef);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
private static void __rpc_handler_2158219958(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = target.NetworkManager;
if (networkManager != null && networkManager.IsListening)
{
NetworkBehaviourReference grabbableRef = default(NetworkBehaviourReference);
((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref grabbableRef, default(ForNetworkSerializable));
target.__rpc_exec_stage = (__RpcExecStage)1;
((KirbyItem)(object)target).SpawnItemServerRpc(grabbableRef);
target.__rpc_exec_stage = (__RpcExecStage)0;
}
}
protected internal override string __getTypeName()
{
return "KirbyItem";
}
}
[BepInPlugin("Redystum.TheKirby", "TheKirby", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static AssetBundle? ModAssets;
internal static PluginConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
InitializeNetworkBehaviours();
string path = "modassetsthekirby";
ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
if ((Object)(object)ModAssets == (Object)null)
{
Logger.LogError((object)"Failed to load custom assets.");
return;
}
EnemyType val = ModAssets.LoadAsset<EnemyType>("ExampleEnemy");
TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("ExampleEnemyTN");
TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("ExampleEnemyTK");
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
int value = BoundConfig.ItemSpawnWeight.Value;
Item val4 = ModAssets.LoadAsset<Item>("KirbyItem");
NetworkPrefabs.RegisterNetworkPrefab(val4.spawnPrefab);
Utilities.FixMixerGroups(val4.spawnPrefab);
Items.RegisterScrap(val4, value, (LevelTypes)(-1));
TerminalNode val5 = ScriptableObject.CreateInstance<TerminalNode>();
val5.clearPreviousText = true;
val5.displayText = "The Kirby???";
Items.RegisterShopItem(val4, (TerminalNode)null, (TerminalNode)null, val5, 6969);
Logger.LogInfo((object)"Plugin Redystum.TheKirby is loaded!");
}
private static void InitializeNetworkBehaviours()
{
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 = "Redystum.TheKirby";
public const string PLUGIN_NAME = "TheKirby";
public const string PLUGIN_VERSION = "1.0.3";
}
}
namespace TheKirby.Configuration
{
public class PluginConfig
{
public ConfigEntry<int> SpawnWeight;
public ConfigEntry<int> DetectionRange;
public ConfigEntry<int> MaxSwallowPlayers;
public ConfigEntry<int> MaxWeight;
public ConfigEntry<int> ItemSpawnWeight;
public ConfigEntry<int> MinValue;
public ConfigEntry<int> MaxValue;
public ConfigEntry<bool> UseItem;
public PluginConfig(ConfigFile cfg)
{
UseItem = cfg.Bind<bool>("General", "Use item", false, "Whether or not TheKirby should spawn the kirby item on death. \nThe kirby item is bugged, using it will cause loss or multiplication of items. Use at your own risk. \ntrue = spawns kirby item, false = does not spawn any item.");
SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for TheKirby, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
DetectionRange = cfg.Bind<int>("General", "Detection range", 20, "The detection range of TheKirby, in meters.\nThis is the range at which TheKirby will detect the player and start following them.");
MaxSwallowPlayers = cfg.Bind<int>("General", "Max swallow players", 2, "The maximum amount of players TheKirby can swallow at once.");
MaxWeight = cfg.Bind<int>("General", "Max weight", 100, "The maximum weight of TheKirby.\nThis is the weight at which TheKirby will be unable to swallow.");
ItemSpawnWeight = cfg.Bind<int>("General", "Item spawn weight", -1, "The spawn chance weight for TheKirby, relative to other existing scrap.\nGoes up from 0, lower is more rare, 100 and up is very common. -1 only spawns on kirby kill");
MinValue = cfg.Bind<int>("General", "Min value", 50, "The minimum value of the item that TheKirby will spawn.\nThis is the minimum value of the item that TheKirby will spawn.");
MaxValue = cfg.Bind<int>("General", "Max value", 100, "The maximum value of the item that TheKirby will spawn.\nThis is the maximum value of the item that TheKirby will spawn.");
ClearUnusedEntries(cfg);
}
private void ClearUnusedEntries(ConfigFile cfg)
{
PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
dictionary.Clear();
cfg.Save();
}
}
}
namespace Redystum.TheKirby.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}