Decompiled source of WhatTheSize v1.0.0

WhatsTheSize.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BoplFixedMath;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("What's the size")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("What's the size")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("045f6145-2603-4f48-94a5-8ebcb25fb27f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace burmaldamod;

internal sealed class PlayerScaleController
{
	private sealed class PlayerScaleState
	{
		public float PhaseOffset;

		public float CycleSpeed;

		public float SecondPhase;

		public float ThirdPhase;

		public float SecondFrequency;

		public float ThirdFrequency;

		public float NoiseOffsetX;

		public float NoiseOffsetY;

		public float NoiseSpeedX;

		public float NoiseSpeedY;
	}

	private const float MinScale = 0.3f;

	private const float MaxScale = 3f;

	private const float FullCycleSeconds = 6f;

	private float elapsedTime;

	private readonly Dictionary<int, PlayerScaleState> states = new Dictionary<int, PlayerScaleState>();

	public void Update(float deltaTime)
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		elapsedTime += deltaTime;
		PlayerHandler val = PlayerHandler.Get();
		if (val == null)
		{
			return;
		}
		List<Player> list = val.PlayerList();
		if (list == null)
		{
			return;
		}
		PruneMissingPlayers(list);
		for (int i = 0; i < list.Count; i++)
		{
			Player val2 = list[i];
			if (val2 != null && val2.IsAlive)
			{
				float num = SampleScaleT01(GetOrCreateState(val2.Id), elapsedTime);
				val2.Scale = (Fix)Mathf.Lerp(0.3f, 3f, num);
			}
		}
	}

	private static float SampleScaleT01(PlayerScaleState state, float time)
	{
		float num = time * state.CycleSpeed + state.PhaseOffset;
		float num2 = Mathf.Sin(num / 6f * (float)Math.PI * 2f);
		float num3 = Mathf.Sin(num * state.SecondFrequency + state.SecondPhase);
		float num4 = Mathf.Sin(num * state.ThirdFrequency + state.ThirdPhase);
		float num5 = Mathf.PerlinNoise(state.NoiseOffsetX + num * state.NoiseSpeedX, state.NoiseOffsetY + num * state.NoiseSpeedY);
		return Mathf.Clamp01((num2 * 0.5f + num3 * 0.22f + num4 * 0.13f + (num5 * 2f - 1f) * 0.15f + 1f) * 0.5f);
	}

	private PlayerScaleState GetOrCreateState(int playerId)
	{
		if (states.TryGetValue(playerId, out var value))
		{
			return value;
		}
		Random random = new Random(playerId * 7919 + 104729);
		value = new PlayerScaleState
		{
			PhaseOffset = (float)random.NextDouble() * 6f * 2f,
			CycleSpeed = 0.7f + (float)random.NextDouble() * 0.8f,
			SecondPhase = (float)random.NextDouble() * (float)Math.PI * 2f,
			ThirdPhase = (float)random.NextDouble() * (float)Math.PI * 2f,
			SecondFrequency = 0.9f + (float)random.NextDouble() * 1.6f,
			ThirdFrequency = 0.4f + (float)random.NextDouble() * 0.9f,
			NoiseOffsetX = (float)random.NextDouble() * 500f,
			NoiseOffsetY = (float)random.NextDouble() * 500f,
			NoiseSpeedX = 0.15f + (float)random.NextDouble() * 0.35f,
			NoiseSpeedY = 0.12f + (float)random.NextDouble() * 0.4f
		};
		states[playerId] = value;
		return value;
	}

	private void PruneMissingPlayers(List<Player> activePlayers)
	{
		if (states.Count == 0)
		{
			return;
		}
		HashSet<int> hashSet = new HashSet<int>();
		for (int i = 0; i < activePlayers.Count; i++)
		{
			if (activePlayers[i] != null)
			{
				hashSet.Add(activePlayers[i].Id);
			}
		}
		List<int> list = new List<int>();
		foreach (KeyValuePair<int, PlayerScaleState> state in states)
		{
			if (!hashSet.Contains(state.Key))
			{
				list.Add(state.Key);
			}
		}
		for (int j = 0; j < list.Count; j++)
		{
			states.Remove(list[j]);
		}
	}
}
[BepInPlugin("com.kriperovich.whatsthesize", "What's the size", "1.1.2")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	private readonly PlayerScaleController scaleController = new PlayerScaleController();

	private void Awake()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"What's the size loaded — smooth per-player scale cycle.");
		new Harmony("com.kriperovich.whatsthesize").PatchAll();
	}

	private void Update()
	{
		scaleController.Update(Time.deltaTime);
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "com.kriperovich.whatsthesize";

	public const string PLUGIN_NAME = "What's the size";

	public const string PLUGIN_VERSION = "1.1.2";
}