Decompiled source of Wesleys Weathers v1.2.10

WesleysWeatherStuff.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WesleysWeatherStuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WesleysWeatherStuff")]
[assembly: AssemblyTitle("WesleysWeatherStuff")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace WesleysWeatherStuff.Stuff
{
	public class ObjectRemover : MonoBehaviour
	{
		public void ObjectSuicide(GameObject o)
		{
			Object.Destroy((Object)(object)o, 15f);
		}
	}
	public class WeatherObject : MonoBehaviour
	{
		public string weatherName;
	}
	internal class WeatherObjectContainer : NetworkBehaviour
	{
		[CompilerGenerated]
		private sealed class <ObjectsFindDelay>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public WeatherObjectContainer <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ObjectsFindDelay>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.FindObjectsInScene();
					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 List<WeatherObject> weatherObjects;

		public string weatherName;

		private void OnEnable()
		{
			StartSearch();
		}

		public void StartSearch()
		{
			((MonoBehaviour)this).StartCoroutine(ObjectsFindDelay());
		}

		public void FindObjectsInScene()
		{
			WeatherObject[] array = Object.FindObjectsByType<WeatherObject>((FindObjectsSortMode)0);
			WeatherObject[] array2 = array;
			foreach (WeatherObject weatherObject in array2)
			{
				if (weatherName == weatherObject.weatherName)
				{
					weatherObjects.Add(weatherObject);
				}
			}
		}

		[IteratorStateMachine(typeof(<ObjectsFindDelay>d__5))]
		private IEnumerator ObjectsFindDelay()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ObjectsFindDelay>d__5(0)
			{
				<>4__this = this
			};
		}

		private void OnDisable()
		{
			if (weatherObjects != null && weatherObjects.Count != 0)
			{
				DestroyObjects();
			}
		}

		private void DestroyObjects()
		{
			foreach (WeatherObject weatherObject in weatherObjects)
			{
				NetworkObject val = null;
				if (!((Object)(object)((Component)weatherObject).gameObject == (Object)null))
				{
					if ((Object)(object)((Component)weatherObject).GetComponent<NetworkObject>() != (Object)null)
					{
						val = ((Component)weatherObject).GetComponent<NetworkObject>();
					}
					if ((Object)(object)NetworkManager.Singleton != (Object)null && (Object)(object)val != (Object)null && val.IsSpawned)
					{
						DisableNetworkObjectRPC(val.NetworkObjectId);
					}
					else
					{
						Object.Destroy((Object)(object)((Component)weatherObject).gameObject);
					}
				}
			}
			weatherObjects.Clear();
		}

		[ServerRpc]
		private void DisableNetworkObjectRPC(ulong nObjectId)
		{
			if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(nObjectId, out var value))
			{
				value.Despawn(true);
			}
		}
	}
}