Decompiled source of Aquatis Beta v2.2.0

NightSky.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

[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("NightSky")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Test")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NightSky")]
[assembly: AssemblyTitle("NightSky")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("NightSkyPlugin", "Night Sky Plugin", "1.0.0")]
public class NightSkyPlugin : BaseUnityPlugin
{
	private NightSkyController nightSkyController;

	private void Awake()
	{
		Debug.Log((object)"Nightsky loaded");
	}
}
public class NightSkyController : MonoBehaviour
{
	[Header("On Planet Settings")]
	public float starBrightness = 6f;

	[Header("In Space Settings")]
	public bool movePlanetOnly;

	public bool inSpace;

	public Vector3 sunRotateVector = new Vector3(0.002f, 0f, 0f);

	public Vector3 moonRotateVector = new Vector3(0.002f, 0f, 0f);

	public Vector3 planetRotateVector = new Vector3(0f, 0f, -0.002f);

	[Space]
	public float orbitHeight = 80000f;

	public float planetRadius = 6378100f;

	public Cubemap planetTexture;

	[Header("References")]
	public GameObject sun;

	public GameObject moon;

	[Space]
	public Volume stormySkyVolume;

	public Volume eclipsedSkyVolume;

	public Volume clearSkyVolume;

	private PhysicallyBasedSky sky;

	public void Awake()
	{
		SetSettings();
	}

	private void OnValidate()
	{
		SetSettings();
	}

	private void FixedUpdate()
	{
		if (inSpace)
		{
			SpaceSimulation();
		}
		else if (!inSpace)
		{
			((VolumeParameter<float>)(object)sky.spaceEmissionMultiplier).value = starBrightness;
		}
	}

	public void Update()
	{
	}

	public void SetSettings()
	{
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)clearSkyVolume != (Object)null)
		{
			clearSkyVolume.profile.TryGet<PhysicallyBasedSky>(ref sky);
		}
		else if ((Object)(object)stormySkyVolume != (Object)null)
		{
			stormySkyVolume.profile.TryGet<PhysicallyBasedSky>(ref sky);
		}
		else if ((Object)(object)stormySkyVolume != (Object)null)
		{
			eclipsedSkyVolume.profile.TryGet<PhysicallyBasedSky>(ref sky);
		}
		else
		{
			Debug.LogError((object)"[Night Sky] No Volumes where found");
		}
		if (inSpace)
		{
			((VolumeParameter<Texture>)(object)sky.groundColorTexture).value = (Texture)(object)planetTexture;
			((VolumeParameter<Texture>)(object)sky.groundEmissionTexture).value = (Texture)(object)planetTexture;
			((VolumeParameter<float>)(object)sky.planetaryRadius).value = planetRadius;
			((VolumeParameter<Vector3>)(object)sky.planetCenterPosition).value = new Vector3(0f, 0f - (((VolumeParameter<float>)(object)sky.planetaryRadius).value + orbitHeight), 0f);
		}
	}

	private void SpaceSimulation()
	{
		//IL_000c: 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_0017: 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)
		//IL_006f: 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)
		//IL_007a: 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)
		Vector3Parameter planetRotation = sky.planetRotation;
		((VolumeParameter<Vector3>)(object)planetRotation).value = ((VolumeParameter<Vector3>)(object)planetRotation).value + planetRotateVector;
		if (!movePlanetOnly)
		{
			if ((Object)(object)moon != (Object)null)
			{
				moon.transform.Rotate(moonRotateVector);
			}
			sun.transform.Rotate(sunRotateVector);
			Vector3Parameter spaceRotation = sky.spaceRotation;
			((VolumeParameter<Vector3>)(object)spaceRotation).value = ((VolumeParameter<Vector3>)(object)spaceRotation).value + planetRotateVector;
		}
	}
}

WanderingCreature.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AI;

[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("WanderingCreature")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Test")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("WanderingCreature")]
[assembly: AssemblyTitle("WanderingCreature")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("WanderingCreature", "Wandering Creature", "1.1.0")]
public class WanderingCreature : BaseUnityPlugin
{
	private void Awake()
	{
		Debug.Log((object)"WanderingCreaturePlugin loaded");
	}
}
public class WanderingCreatureController : MonoBehaviour
{
	[Header("Movement")]
	[Tooltip("The maximum distance from the creature's current position within which it can wander.")]
	public float wanderRadius = 10f;

	[Tooltip("The duration the creature waits at its destination before selecting a new destination to wander towards.")]
	public float waitTime = 3f;

	[Tooltip("If enabled, the wait time becomes random within the range [0, Wait Time].")]
	public bool randomTime;

	[Tooltip("Toggle whether the creature is allowed to wander or not.")]
	public bool wanderEnabled = true;

	[Tooltip("When enabled, the creature will only wander around its spawn point within a radius defined by the Wander Radius. If disabled, the creature can wander from any point within the Wander Radius.")]
	public bool anchoredWandering = true;

	[Header("Audio")]
	[Tooltip("An array of audio clips that can be played randomly at intervals while the creature is wandering.")]
	public AudioClip[] ambientAudioClips;

	[Tooltip("The minimum interval between playing ambient audio clips.")]
	public float minAmbientAudioInterval = 3f;

	[Tooltip("The maximum interval between playing ambient audio clips.")]
	public float maxAmbientAudioInterval = 7f;

	[Space]
	[Tooltip("An array of audio clips that can be played randomly at intervals while the creature is moving.")]
	public AudioClip[] walkingAudioClips;

	[Tooltip("The interval between playing walking audio clips.")]
	public float walkingAudioInterval = 0.5f;

	[Header("Rotation")]
	[Tooltip("If enabled, the creature will follow the surface normal underneath it.")]
	public bool followSurface;

	[Tooltip("The distance to cast the ray to detect the surface normal.")]
	public float surfaceNormalRaycastDistance = 1f;

	private NavMeshAgent agent;

	private bool isMoving;

	private float waitTimer;

	private float ambientAudioTimer;

	private float walkingAudioTimer;

	private void Start()
	{
		agent = ((Component)this).GetComponent<NavMeshAgent>();
		SetNewDestination();
	}

	private void Update()
	{
		//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)
		if (!wanderEnabled)
		{
			return;
		}
		if (isMoving)
		{
			if (!agent.pathPending && agent.remainingDistance <= agent.stoppingDistance)
			{
				if (agent.hasPath)
				{
					Vector3 velocity = agent.velocity;
					if (((Vector3)(ref velocity)).sqrMagnitude != 0f)
					{
						goto IL_00c2;
					}
				}
				isMoving = false;
				if (randomTime)
				{
					waitTimer = Random.Range(0f, waitTime);
				}
				else
				{
					waitTimer = waitTime;
				}
			}
		}
		else if (waitTimer > 0f)
		{
			waitTimer -= Time.deltaTime;
		}
		else
		{
			SetNewDestination();
		}
		goto IL_00c2;
		IL_00c2:
		if (ambientAudioClips != null && ambientAudioClips.Length != 0)
		{
			ambientAudioTimer -= Time.deltaTime;
			if (ambientAudioTimer <= 0f)
			{
				PlayRandomAmbientAudioClip();
				ambientAudioTimer = Random.Range(minAmbientAudioInterval, maxAmbientAudioInterval);
			}
		}
		if (isMoving && walkingAudioClips != null && walkingAudioClips.Length != 0)
		{
			walkingAudioTimer -= Time.deltaTime;
			if (walkingAudioTimer <= 0f)
			{
				PlayRandomWalkingAudioClip();
				walkingAudioTimer = walkingAudioInterval;
			}
		}
		if (followSurface)
		{
			RotateToFollowSurfaceNormal();
		}
	}

	private void SetNewDestination()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_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)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Random.insideUnitSphere * wanderRadius;
		if (anchoredWandering)
		{
			val += ((Component)this).transform.position;
		}
		NavMeshHit val2 = default(NavMeshHit);
		NavMesh.SamplePosition(val, ref val2, wanderRadius, 1);
		Vector3 position = ((NavMeshHit)(ref val2)).position;
		agent.SetDestination(position);
		isMoving = true;
	}

	private void PlayRandomAmbientAudioClip()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		int num = Random.Range(0, ambientAudioClips.Length);
		AudioSource.PlayClipAtPoint(ambientAudioClips[num], ((Component)this).transform.position);
	}

	private void PlayRandomWalkingAudioClip()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		int num = Random.Range(0, walkingAudioClips.Length);
		AudioSource.PlayClipAtPoint(walkingAudioClips[num], ((Component)this).transform.position);
	}

	private void RotateToFollowSurfaceNormal()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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)
		RaycastHit val = default(RaycastHit);
		if (Physics.Raycast(((Component)this).transform.position, -((Component)this).transform.up, ref val, surfaceNormalRaycastDistance))
		{
			((Component)this).transform.up = ((RaycastHit)(ref val)).normal;
		}
	}

	private void OnDrawGizmosSelected()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		Gizmos.color = Color.blue;
		Gizmos.DrawWireSphere(((Component)this).transform.position, wanderRadius);
	}
}