Decompiled source of Realistic Liquid Transfer v0.1.0
RealisticLiquidTransfer.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RealisticLiquidTransfer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ba9bd970ba5b60e99cf87672890ba60cfec8b506")] [assembly: AssemblyProduct("RealisticLiquidTransfer")] [assembly: AssemblyTitle("RealisticLiquidTransfer")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 RealisticLiquidTransfer { [BepInPlugin("com.liquidtransfer.mod", "Realistic Liquid Transfer", "0.1.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.liquidtransfer.mod"; public const string PluginName = "Realistic Liquid Transfer"; public const string PluginVersion = "0.1.0"; private Harmony _harmony; private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown ModSprites.Load(); try { LiquidShaderAssets.Load(); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Could not load the liquid shader bundle: {arg}"); } _harmony = new Harmony("com.liquidtransfer.mod"); _harmony.PatchAll(); } private void OnDestroy() { if (Object.op_Implicit((Object)(object)MinigameBase.main) && MinigameBase.main.currentMinigame is LiquidTransferMinigame) { MinigameBase.main.EndMinigame(); } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } LiquidShaderAssets.Unload(); ModSprites.Unload(); } [Conditional("LIQUID_TRANSFER_DEBUG_LOGGING")] internal static void LogInfo(string message) { } [Conditional("LIQUID_TRANSFER_DEBUG_LOGGING")] internal static void LogWarning(string message) { } [Conditional("LIQUID_TRANSFER_DEBUG_LOGGING")] internal static void LogError(string message) { } } internal sealed class LiquidTransferMinigame : Minigame { private readonly struct LiquidPortion { internal string LiquidId { get; } internal float Amount { get; } internal LiquidPortion(string liquidId, float amount) { LiquidId = liquidId; Amount = amount; } } private sealed class ContainerVisual { internal RectTransform Transform { get; } internal Vector2 OpeningCenterPoint { get; } internal Vector2 LeftOpeningPoint { get; } internal Vector2 RightOpeningPoint { get; } internal bool HasOpening { get; } internal Vector2[] OutlinePoints { get; } internal Vector2[][] InteriorWalls { get; } internal Vector2[] CollisionOutlinePoints { get; } internal bool IsSyringe { get; } internal SyringeGeometry Geometry { get; } internal bool HasRotationPivot { get; set; } internal bool PivotIsRight { get; set; } internal ContainerVisual(RectTransform transform, Vector2 openingCenterPoint, Vector2 leftOpeningPoint, Vector2 rightOpeningPoint, bool hasOpening, Vector2[] outlinePoints, Vector2[][] interiorWalls, Vector2[] collisionOutlinePoints, bool isSyringe, SyringeGeometry geometry) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) Transform = transform; OpeningCenterPoint = openingCenterPoint; LeftOpeningPoint = leftOpeningPoint; RightOpeningPoint = rightOpeningPoint; HasOpening = hasOpening; OutlinePoints = outlinePoints; InteriorWalls = interiorWalls; CollisionOutlinePoints = collisionOutlinePoints; IsSyringe = isSyringe; Geometry = geometry; } } private sealed class SyringeVisual { internal ContainerVisual Container { get; } internal int ContainerIndex { get; } internal float Capacity { get; } internal RectTransform HandleTransform { get; } internal float HandleVelocity { get; set; } internal float EjectionVolumeCredit { get; set; } internal SyringeVisual(ContainerVisual container, int containerIndex, float capacity, RectTransform handleTransform) { Container = container; ContainerIndex = containerIndex; Capacity = capacity; HandleTransform = handleTransform; } } private readonly struct SyringeGeometry { internal Vector2[] FluidOutline { get; } internal Vector2[] CollisionOutline { get; } internal Vector2 OpeningCenter { get; } internal Vector2 OpeningLeft { get; } internal Vector2 OpeningRight { get; } internal Vector2 FluidBottom { get; } internal Vector2 FluidTop { get; } internal Rect BodyHitbox { get; } internal Vector2 NeedlePoint { get; } internal SyringeGeometry(Vector2[] fluidOutline, Vector2[] collisionOutline, Vector2 openingCenter, Vector2 openingLeft, Vector2 openingRight, float fluidBottomY, float fluidTopY, Rect bodyHitbox, Vector2 needlePoint) { //IL_000f: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_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_003f: 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_004a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) FluidOutline = fluidOutline; CollisionOutline = collisionOutline; OpeningCenter = openingCenter; OpeningLeft = openingLeft; OpeningRight = openingRight; FluidBottom = new Vector2(0f, fluidBottomY); FluidTop = new Vector2(0f, fluidTopY); BodyHitbox = bodyHitbox; NeedlePoint = needlePoint; } } private const float HandScale = 0.85f; private const float ContainerScale = 4f; private const float ContainerGap = 40f; private const float ScreenPadding = 40f; private const float CollisionStep = 2f; private const float PivotSwitchHysteresis = 2f; private const float RotationMovementInfluence = 1f; private const float TranslationHorizontalInfluence = 1f; private const float TranslationVerticalInfluence = 1f; private const float SyringeHandleSmoothTime = 0.04f; private const float SyringeFreePistonSpeed = 420f; private const float SyringeEjectionRate = 24f; private const float SyringeEjectionSpeed = 1000f; private const string ReferenceSpriteName = "coffee"; private const float ReferenceCapacity = 250f; private static float referenceCapacity = 250f; private const bool SimulationFrozen = false; private readonly WaterContainerItem receivingGameContainer; private readonly WaterContainerItem sourceGameContainer; private readonly string firstOriginalContainerSpriteName; private readonly string secondOriginalContainerSpriteName; private readonly float firstOriginalContainerCapacity; private readonly float secondOriginalContainerCapacity; private readonly float firstOriginalContainerAmount; private readonly float secondOriginalContainerAmount; private readonly LiquidProfileEntry[] firstOriginalLiquidComposition; private readonly LiquidProfileEntry[] secondOriginalLiquidComposition; private readonly List<float> receivingDrainPlan; private readonly List<float> sourceDrainPlan; private readonly bool drainOnly; private Image handImage; private Text controlsText; private RectTransform screenRoot; private RectTransform overlayRoot; private LiquidSimulation liquidSimulation; private HandAlphaGradient handAlphaGradient; private Vector2 originalHandSize; private bool originalPreserveAspect; private ContainerVisual receivingContainer; private ContainerVisual sourceContainer; private RectTransform heldContainer; private ContainerVisual heldVisual; private Vector2 heldOffset; private SyringeVisual receivingSyringe; private SyringeVisual sourceSyringe; private SyringeVisual activeSyringe; private float syringeHandlePointerOffset; private ContainerVisual activeRotationContainer; private bool rotatingWithRightMouse; private float rotationAngle; private Vector2 rotationStartPointer; private Vector2 rotationStartCenter; private Vector2 rotationPivotPosition; private float rotationLastPointerAngle; private int rotationVerticalSector; private bool rotationTrackingStarted; private bool transferCommitted; private float fitScale; private float[] initialSimulatedLiquidAmounts; private float[] finalSimulatedLiquidAmounts; private float[] targetLiquidAmounts; private float[] unreturnedLiquidByType; internal LiquidTransferMinigame(WaterContainerItem receivingGameContainer, string firstOriginalContainerSpriteName, float firstOriginalContainerCapacity, float firstOriginalContainerAmount, LiquidProfileEntry[] firstOriginalLiquidComposition, WaterContainerItem sourceGameContainer, string secondOriginalContainerSpriteName, float secondOriginalContainerCapacity, float secondOriginalContainerAmount, LiquidProfileEntry[] secondOriginalLiquidComposition) { this.receivingGameContainer = receivingGameContainer; this.sourceGameContainer = sourceGameContainer; receivingDrainPlan = CreateDrainPlan(receivingGameContainer); sourceDrainPlan = CreateDrainPlan(sourceGameContainer); this.firstOriginalContainerSpriteName = firstOriginalContainerSpriteName; this.firstOriginalContainerCapacity = firstOriginalContainerCapacity; this.firstOriginalContainerAmount = firstOriginalContainerAmount; this.firstOriginalLiquidComposition = firstOriginalLiquidComposition ?? Array.Empty<LiquidProfileEntry>(); this.secondOriginalContainerSpriteName = secondOriginalContainerSpriteName; this.secondOriginalContainerCapacity = secondOriginalContainerCapacity; this.secondOriginalContainerAmount = secondOriginalContainerAmount; this.secondOriginalLiquidComposition = secondOriginalLiquidComposition ?? Array.Empty<LiquidProfileEntry>(); if (string.Equals(firstOriginalContainerSpriteName, "coffee", StringComparison.OrdinalIgnoreCase) && firstOriginalContainerCapacity > 0f) { referenceCapacity = firstOriginalContainerCapacity; } if (string.Equals(secondOriginalContainerSpriteName, "coffee", StringComparison.OrdinalIgnoreCase) && secondOriginalContainerCapacity > 0f) { referenceCapacity = secondOriginalContainerCapacity; } } internal LiquidTransferMinigame(WaterContainerItem container, string originalContainerSpriteName, float originalContainerCapacity, float originalContainerAmount, LiquidProfileEntry[] originalLiquidComposition) { receivingGameContainer = container; sourceGameContainer = null; receivingDrainPlan = CreateDrainPlan(container); sourceDrainPlan = CreateDrainPlan(null); firstOriginalContainerSpriteName = originalContainerSpriteName; secondOriginalContainerSpriteName = originalContainerSpriteName; firstOriginalContainerCapacity = originalContainerCapacity; secondOriginalContainerCapacity = originalContainerCapacity; firstOriginalContainerAmount = originalContainerAmount; secondOriginalContainerAmount = 0f; firstOriginalLiquidComposition = originalLiquidComposition ?? Array.Empty<LiquidProfileEntry>(); secondOriginalLiquidComposition = Array.Empty<LiquidProfileEntry>(); drainOnly = true; if (string.Equals(originalContainerSpriteName, "coffee", StringComparison.OrdinalIgnoreCase) && originalContainerCapacity > 0f) { referenceCapacity = originalContainerCapacity; } } public override HandSpriteType HandType() { return (HandSpriteType)0; } public override float HandRotOffset() { return Minigame.game.handPos.x * 0.02f; } public override string GuideLocaleString() { return string.Empty; } public override bool NeedsItem() { return false; } public override bool CanExit() { return false; } public override void Start() { //IL_001f: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) MinigameBase game = Minigame.game; screenRoot = new GameObject("RealisticLiquidTransferScreen", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)screenRoot).SetParent((Transform)(object)game.minigameScreen, false); screenRoot.anchorMin = new Vector2(0.5f, 0.5f); screenRoot.anchorMax = new Vector2(0.5f, 0.5f); screenRoot.pivot = new Vector2(0.5f, 0.5f); RectTransform obj = screenRoot; Rect rect = game.minigameScreen.rect; obj.sizeDelta = ((Rect)(ref rect)).size; ((Transform)screenRoot).SetSiblingIndex(0); game.spawnedMiniGame = (Transform)(object)screenRoot; overlayRoot = CreateOverlayRoot(game.minigameScreen); controlsText = CreateControlsText(overlayRoot); receivingContainer = CreateContainer(screenRoot, "ReceivingContainer", ModSprites.GetContainer(firstOriginalContainerSpriteName, firstOriginalContainerCapacity), Vector2.zero, 0f, IsSyringeSprite(firstOriginalContainerSpriteName)); sourceContainer = CreateContainer(screenRoot, "SourceContainer", ModSprites.GetContainer(secondOriginalContainerSpriteName, secondOriginalContainerCapacity), Vector2.zero, 0f, IsSyringeSprite(secondOriginalContainerSpriteName)); double referenceArea = EstimateSpriteArea(ModSprites.GetContainer("coffee")); if (!receivingContainer.IsSyringe) { ApplyAreaScale(receivingContainer, firstOriginalContainerCapacity, referenceArea, firstOriginalContainerSpriteName); } if (!sourceContainer.IsSyringe) { ApplyAreaScale(sourceContainer, secondOriginalContainerCapacity, referenceArea, secondOriginalContainerSpriteName); } if (drainOnly) { receivingContainer.Transform.anchoredPosition = -TransformOpeningPoint(receivingContainer.Transform, receivingContainer.OpeningCenterPoint); sourceContainer.Transform.anchoredPosition = Vector2.one * 100000f; ((Component)sourceContainer.Transform).gameObject.SetActive(false); } else { PositionContainersSideBySide(receivingContainer, sourceContainer); } handImage = ((Component)game.handTransform).GetComponent<Image>(); originalHandSize = ((Graphic)handImage).rectTransform.sizeDelta; originalPreserveAspect = handImage.preserveAspect; fitScale = (drainOnly ? GetFitScale(game.minigameScreen, screenRoot, receivingContainer) : GetFitScale(game.minigameScreen, screenRoot, receivingContainer, sourceContainer)); ((Transform)screenRoot).localScale = Vector3.one * fitScale; liquidSimulation = new LiquidSimulation(screenRoot, receivingContainer.Transform, receivingContainer.OutlinePoints, receivingContainer.InteriorWalls, firstOriginalContainerCapacity, sourceContainer.Transform, sourceContainer.OutlinePoints, sourceContainer.InteriorWalls, secondOriginalContainerCapacity, firstOriginalContainerAmount, secondOriginalContainerAmount, firstOriginalLiquidComposition, secondOriginalLiquidComposition, 1.85f); int num = liquidSimulation.LiquidTypeBufferLength * 2; initialSimulatedLiquidAmounts = new float[num]; finalSimulatedLiquidAmounts = new float[num]; targetLiquidAmounts = new float[num]; if (receivingContainer.IsSyringe) { receivingSyringe = CreateSyringeVisual(receivingContainer, 0, firstOriginalContainerCapacity); } if (sourceContainer.IsSyringe) { sourceSyringe = CreateSyringeVisual(sourceContainer, 1, secondOriginalContainerCapacity); } UpdateSyringeHandlePositions(); liquidSimulation.SetSurfaceShaderEnabled(enabled: true); liquidSimulation.SetColorTransitionSharpness(0f); liquidSimulation.SetSimulationFrozen(frozen: false); liquidSimulation.SetDropCollisionPasses(6); liquidSimulation.SetCollisionCorrectionPercent(100); liquidSimulation.SetVelocityContactMarginTenths(5); handImage.preserveAspect = true; ((Graphic)handImage).rectTransform.sizeDelta = originalHandSize * (0.85f * fitScale); handAlphaGradient = ((Component)handImage).gameObject.AddComponent<HandAlphaGradient>(); } private static RectTransform CreateOverlayRoot(RectTransform parent) { //IL_0018: 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_0036: 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_0056: 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) RectTransform component = new GameObject("RealisticLiquidTransferOverlay", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)parent, false); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = Vector2.zero; ((Transform)component).SetAsLastSibling(); return component; } private static Text CreateControlsText(RectTransform parent) { //IL_0032: 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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) Text component = new GameObject("LiquidTransferControls", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Text) }).GetComponent<Text>(); RectTransform rectTransform = ((Graphic)component).rectTransform; ((Transform)rectTransform).SetParent((Transform)(object)parent, false); rectTransform.anchorMin = new Vector2(0.5f, 0f); rectTransform.anchorMax = new Vector2(0.5f, 0f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = new Vector2(0f, 20f); Rect rect = parent.rect; rectTransform.sizeDelta = new Vector2(((Rect)(ref rect)).width - 80f, 32f); component.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); component.fontSize = 16; component.alignment = (TextAnchor)4; component.text = "LMB to hold | RMB to rotate | ESC to finish"; ((Graphic)component).color = Color.white; ((Graphic)component).raycastTarget = false; return component; } public override void Update(List<RaycastResult> uiCasts) { //IL_0007: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) MinigameBase game = Minigame.game; Vector2 val = game.handPos / fitScale; if (game.handStartedClicking) { heldContainer = null; heldVisual = null; activeSyringe = null; activeRotationContainer = null; rotatingWithRightMouse = false; ContainerVisual containerVisual = GetSyringeBodyUnderPointer(val); if (containerVisual != null) { StartDragging(containerVisual, game.handPos); } else { activeSyringe = GetSyringeHandleUnderPointer(val); if (activeSyringe != null) { Vector2 val2 = ToContainerLocalPoint(activeSyringe.Container, val); syringeHandlePointerOffset = activeSyringe.HandleTransform.anchoredPosition.y - val2.y; activeSyringe.HandleVelocity = 0f; } else { containerVisual = GetContainerUnderPointer(uiCasts); } if (containerVisual != null) { StartDragging(containerVisual, game.handPos); } } } if (Input.GetMouseButtonDown(1)) { ContainerVisual containerVisual2 = GetSyringeBodyUnderPointer(val) ?? GetContainerUnderPointer(uiCasts); if (containerVisual2 != null) { heldContainer = null; heldVisual = null; StartRotating(containerVisual2, game.handPos); rotatingWithRightMouse = true; } } if (Input.GetMouseButtonUp(1) && rotatingWithRightMouse) { activeRotationContainer = null; rotatingWithRightMouse = false; } if (game.handStoppedClicking && !rotatingWithRightMouse) { heldContainer = null; heldVisual = null; if (activeSyringe != null) { activeSyringe.HandleVelocity = 0f; activeSyringe.EjectionVolumeCredit = 0f; } activeSyringe = null; activeRotationContainer = null; } if (activeRotationContainer != null && rotatingWithRightMouse && Input.GetMouseButton(1)) { RotateContainer(game.handPos); } else if (activeSyringe != null && game.handClicking) { UpdateSyringePlunger(activeSyringe, val); } else if (Object.op_Implicit((Object)(object)heldContainer) && game.handClicking) { Vector2 anchoredPosition = heldContainer.anchoredPosition; heldContainer.anchoredPosition = game.handPos / fitScale + heldOffset; Vector2 anchoredPosition2 = heldContainer.anchoredPosition; heldContainer.anchoredPosition = anchoredPosition; MoveContainer(heldVisual, anchoredPosition2); } liquidSimulation.Tick(Time.unscaledDeltaTime, spawn: false, val); } private SyringeVisual CreateSyringeVisual(ContainerVisual container, int containerIndex, float capacity) { //IL_003d: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) Sprite container2 = ModSprites.GetContainer("syringehandle"); Image component = new GameObject("SyringeHandle", new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }).GetComponent<Image>(); RectTransform rectTransform = ((Graphic)component).rectTransform; ((Transform)rectTransform).SetParent((Transform)(object)container.Transform, false); rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0f); rectTransform.anchoredPosition = new Vector2(0f, container.Geometry.FluidBottom.y); Rect rect = container2.rect; rectTransform.sizeDelta = ((Rect)(ref rect)).size; component.sprite = container2; component.preserveAspect = false; ((Graphic)component).raycastTarget = false; ((Transform)rectTransform).SetAsLastSibling(); return new SyringeVisual(container, containerIndex, capacity, rectTransform); } private void UpdateSyringeHandlePositions() { UpdateSyringeHandlePosition(receivingSyringe); UpdateSyringeHandlePosition(sourceSyringe); } private void UpdateSyringeHandlePosition(SyringeVisual syringe) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00b6: Unknown result type (might be due to invalid IL or missing references) if (syringe != null && (syringe != activeSyringe || !Minigame.game.handClicking)) { float containerLiquidAmount = liquidSimulation.GetContainerLiquidAmount(syringe.ContainerIndex); float num = ((syringe.Capacity > 0f) ? Mathf.Clamp01(containerLiquidAmount / syringe.Capacity) : 0f); syringe.HandleTransform.anchoredPosition = new Vector2(0f, Mathf.Lerp(syringe.Container.Geometry.FluidBottom.y, syringe.Container.Geometry.FluidTop.y, num)); syringe.HandleVelocity = 0f; liquidSimulation.SetSyringePistonPosition(syringe.ContainerIndex, syringe.HandleTransform.anchoredPosition.y); } } private SyringeVisual GetSyringeHandleUnderPointer(Vector2 pointerPosition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (IsPointerOnSyringeHandle(receivingSyringe, pointerPosition)) { return receivingSyringe; } if (!IsPointerOnSyringeHandle(sourceSyringe, pointerPosition)) { return null; } return sourceSyringe; } private bool IsPointerOnSyringeHandle(SyringeVisual syringe, Vector2 pointerPosition) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) if (syringe == null) { return false; } Vector2 val = ToContainerLocalPoint(syringe.Container, pointerPosition) - syringe.HandleTransform.anchoredPosition; Rect rect = syringe.HandleTransform.rect; ((Rect)(ref rect)).xMin = ((Rect)(ref rect)).xMin - 8f; ((Rect)(ref rect)).xMax = ((Rect)(ref rect)).xMax + 8f; ((Rect)(ref rect)).yMin = ((Rect)(ref rect)).yMin - 8f; ((Rect)(ref rect)).yMax = ((Rect)(ref rect)).yMax + 8f; return ((Rect)(ref rect)).Contains(val); } private Vector2 ToContainerLocalPoint(ContainerVisual container, Vector2 rootPoint) { //IL_0006: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0045: 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_0052: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Quaternion.Inverse(((Transform)container.Transform).localRotation) * Vector2.op_Implicit(rootPoint - container.Transform.anchoredPosition); Vector3 localScale = ((Transform)container.Transform).localScale; return new Vector2(val.x / localScale.x, val.y / localScale.y); } private Vector2 ToRootPoint(ContainerVisual container, Vector2 localPoint) { //IL_0006: 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_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //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_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Transform)container.Transform).localRotation * Vector3.Scale(Vector2.op_Implicit(localPoint), ((Transform)container.Transform).localScale); return container.Transform.anchoredPosition + new Vector2(val.x, val.y); } private void UpdateSyringePlunger(SyringeVisual syringe, Vector2 pointerPosition) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0071: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) SyringeGeometry geometry = syringe.Container.Geometry; float num = Mathf.Clamp(ToContainerLocalPoint(syringe.Container, pointerPosition).y + syringeHandlePointerOffset, geometry.FluidBottom.y, geometry.FluidTop.y); float y = syringe.HandleTransform.anchoredPosition.y; int num2 = (drainOnly ? (-1) : (1 - syringe.ContainerIndex)); Vector2 val = ToRootPoint(syringe.Container, geometry.NeedlePoint); float num3 = 8.841675f / Mathf.Max(Mathf.Abs(((Transform)syringe.Container.Transform).localScale.y), 0.0001f); Vector2 val2 = ToRootPoint(syringe.Container, new Vector2(0f, geometry.FluidBottom.y + num3)); bool flag = liquidSimulation.HasContainerDropNear(syringe.ContainerIndex, val2, 17.68335f); float num4 = Mathf.Clamp(Time.unscaledDeltaTime, 0f, 0.1f); float num9; if (num < y) { float num5 = Mathf.Min(num4, 1f / 30f); float num6 = 420f; if (flag && syringe.Capacity > 0f) { float num7 = geometry.FluidTop.y - geometry.FluidBottom.y; num6 = Mathf.Min(num6, num7 * 24f / syringe.Capacity); } float num8 = num6 * num5; num9 = Mathf.Max(num, y - num8); syringe.HandleVelocity = 0f; } else { float handleVelocity = syringe.HandleVelocity; num9 = Mathf.SmoothDamp(y, num, ref handleVelocity, 0.04f, float.PositiveInfinity, num4); syringe.HandleVelocity = handleVelocity; } syringe.HandleTransform.anchoredPosition = new Vector2(0f, num9); liquidSimulation.SetSyringePistonPosition(syringe.ContainerIndex, num9); float num10 = Mathf.InverseLerp(geometry.FluidBottom.y, geometry.FluidTop.y, num9) * syringe.Capacity; float containerLiquidAmount = liquidSimulation.GetContainerLiquidAmount(syringe.ContainerIndex); float num11 = num10 - containerLiquidAmount; int num12 = Mathf.FloorToInt(Mathf.Abs(num11) + 0.001f); Vector3 val3 = ((Transform)syringe.Container.Transform).localRotation * Vector3.Scale(Vector2.op_Implicit(Vector2.down), ((Transform)syringe.Container.Transform).localScale); Vector2 val4 = new Vector2(val3.x, val3.y); Vector2 normalized = ((Vector2)(ref val4)).normalized; if (num9 <= geometry.FluidBottom.y + 0.01f) { syringe.EjectionVolumeCredit = 0f; int num13 = ((num2 >= 0 && liquidSimulation.ContainsContainer(num2, val)) ? num2 : (-1)); int num14 = liquidSimulation.GetContainerDropCount(syringe.ContainerIndex); while (num14 > 0) { int num15 = liquidSimulation.TryTransferNearestDrop(syringe.ContainerIndex, num13, val2, float.PositiveInfinity, val, int.MaxValue, normalized * 1000f, num13 >= 0); if (num15 > 0) { num14 -= num15; continue; } break; } return; } if (num11 < 0f) { if (flag) { syringe.EjectionVolumeCredit = Mathf.Min(syringe.EjectionVolumeCredit + 24f * num4, syringe.Capacity); } int num16 = Mathf.Min(num12, Mathf.FloorToInt(syringe.EjectionVolumeCredit + 0.001f)); int num17 = ((num2 >= 0 && liquidSimulation.ContainsContainer(num2, val)) ? num2 : (-1)); while (num16 > 0) { int num18 = liquidSimulation.TryTransferNearestDrop(syringe.ContainerIndex, num17, val2, 17.68335f, val, num16, normalized * 1000f, num17 >= 0); if (num18 > 0) { num16 -= num18; syringe.EjectionVolumeCredit = Mathf.Max(0f, syringe.EjectionVolumeCredit - (float)num18); continue; } break; } return; } syringe.EjectionVolumeCredit = 0f; if (num12 <= 0) { return; } int sourceContainerIndex = num2; Vector2 destinationPoint = ToRootPoint(syringe.Container, new Vector2(0f, geometry.FluidBottom.y + num3)); float maximumSourceDistance = 26.525024f; int num19 = num12; while (num19 > 0) { int num20 = liquidSimulation.TryTransferNearestDrop(sourceContainerIndex, syringe.ContainerIndex, val, maximumSourceDistance, destinationPoint, num19, Vector2.zero); if (num20 > 0) { num19 -= num20; continue; } break; } } private static bool IsSyringeSprite(string spriteName) { return string.Equals(spriteName, "syringe", StringComparison.OrdinalIgnoreCase); } private static SyringeGeometry CreateSyringeGeometry(Sprite sprite) { //IL_0014: 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_0026: 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_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_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0062: 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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007b: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) Vector2 val = FromTop(6f, 12f); Vector2 val2 = FromTop(24f, 12f); Vector2 val3 = FromTop(24f, 83f); Vector2 val4 = FromTop(6f, 83f); Vector2[] fluidOutline = (Vector2[])(object)new Vector2[5] { val, val2, val3, val4, val }; Vector2 val5 = FromTop(2f, 8f); Vector2 val6 = FromTop(28f, 8f); Vector2 val7 = FromTop(26f, 87f); Vector2 val8 = FromTop(4f, 87f); Vector2[] collisionOutline = (Vector2[])(object)new Vector2[5] { val5, val6, val7, val8, val5 }; Rect bodyHitbox = Rect.MinMaxRect(val5.x, val8.y, val6.x, val6.y); return new SyringeGeometry(fluidOutline, collisionOutline, FromTop(15f, 9f), FromTop(3f, 9f), FromTop(27f, 9f), val4.y, val.y, bodyHitbox, FromTop(15f, 140f)); Vector2 FromTop(float x, float y) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) float num = x - sprite.pivot.x; Rect rect = sprite.rect; return new Vector2(num, ((Rect)(ref rect)).height - y - sprite.pivot.y); } } private static void ApplyAreaScale(ContainerVisual container, float targetCapacity, double referenceArea, string originalSpriteName) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) double num = EstimateContainerArea(container.OutlinePoints, container.InteriorWalls); if (!(targetCapacity <= 0f) && !(referenceArea <= 0.0) && !(num <= 0.0)) { double num2 = (double)(targetCapacity / referenceCapacity) * (referenceArea / num); if (!(num2 <= 0.0) && !double.IsNaN(num2) && !double.IsInfinity(num2)) { float num3 = (float)Math.Sqrt(num2); ((Transform)container.Transform).localScale = Vector3.one * (4f * num3); } } } private static double EstimateSpriteArea(Sprite sprite) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)sprite) || !ModSprites.TryFindOpening(sprite, out var position, out var width) || !ModSprites.TryFindOutline(sprite, position, width, out var points)) { return 0.0; } return EstimateContainerArea(points, ModSprites.FindInteriorWalls(sprite, position, width)); } private static double EstimateContainerArea(Vector2[] outline, Vector2[][] interiorWalls) { double num = EstimateOutlineArea(outline); foreach (Vector2[] outline2 in interiorWalls) { num -= EstimateOutlineArea(outline2); } return Math.Max(0.0, num); } private static double EstimateOutlineArea(Vector2[] outline) { //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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_003c: 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_004b: Unknown result type (might be due to invalid IL or missing references) if (outline.Length < 3) { return 0.0; } double num = 0.0; for (int i = 0; i < outline.Length; i++) { Vector2 val = outline[i]; Vector2 val2 = outline[(i + 1) % outline.Length]; num += (double)val.x * (double)val2.y - (double)val2.x * (double)val.y; } return Math.Abs(num) * 0.5; } private ContainerVisual GetContainerUnderPointer(List<RaycastResult> uiCasts) { //IL_0005: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) Vector2 point = Minigame.game.handPos / fitScale; foreach (RaycastResult uiCast in uiCasts) { RaycastResult current = uiCast; if ((Object)(object)((RaycastResult)(ref current)).gameObject == (Object)(object)((Component)receivingContainer.Transform).gameObject && !receivingContainer.IsSyringe && liquidSimulation.ContainsContainer(0, point)) { return receivingContainer; } if ((Object)(object)((RaycastResult)(ref current)).gameObject == (Object)(object)((Component)sourceContainer.Transform).gameObject && !sourceContainer.IsSyringe && liquidSimulation.ContainsContainer(1, point)) { return sourceContainer; } } return null; } private ContainerVisual GetSyringeBodyUnderPointer(Vector2 pointerPosition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (IsPointerOnSyringeBody(receivingContainer, pointerPosition)) { return receivingContainer; } if (!IsPointerOnSyringeBody(sourceContainer, pointerPosition)) { return null; } return sourceContainer; } private bool IsPointerOnSyringeBody(ContainerVisual container, Vector2 pointerPosition) { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (container.IsSyringe) { Rect bodyHitbox = container.Geometry.BodyHitbox; return ((Rect)(ref bodyHitbox)).Contains(ToContainerLocalPoint(container, pointerPosition)); } return false; } internal void RestoreHand() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)overlayRoot)) { GameObject gameObject = ((Component)overlayRoot).gameObject; gameObject.SetActive(false); Object.Destroy((Object)(object)gameObject); overlayRoot = null; } if (Object.op_Implicit((Object)(object)handImage)) { if (Object.op_Implicit((Object)(object)handAlphaGradient)) { ((Behaviour)handAlphaGradient).enabled = false; ((Graphic)handImage).SetVerticesDirty(); Object.Destroy((Object)(object)handAlphaGradient); handAlphaGradient = null; } ((Graphic)handImage).rectTransform.sizeDelta = originalHandSize; handImage.preserveAspect = originalPreserveAspect; ((Graphic)handImage).SetVerticesDirty(); Minigame.game.UpdateHandSprite(true); } } internal void CommitTransfer() { if (transferCommitted) { return; } if (!Object.op_Implicit((Object)(object)receivingGameContainer) || (!drainOnly && !Object.op_Implicit((Object)(object)sourceGameContainer))) { throw new InvalidOperationException("Cannot commit liquid simulation because a required game container is unavailable."); } liquidSimulation.GetInitialSimulatedLiquidAmounts(initialSimulatedLiquidAmounts); liquidSimulation.GetFinalSimulatedLiquidAmounts(finalSimulatedLiquidAmounts); int liquidTypeCount = liquidSimulation.LiquidTypeCount; int liquidTypeBufferLength = liquidSimulation.LiquidTypeBufferLength; BuildTargetLiquidAmounts(receivingGameContainer, 0, liquidTypeCount, liquidTypeBufferLength); if (!drainOnly) { BuildTargetLiquidAmounts(sourceGameContainer, 1, liquidTypeCount, liquidTypeBufferLength); } int num; if (!drainOnly) { num = (NoLiquidLossSetting.IsEnabled ? 1 : 0); if (num != 0) { CaptureUnreturnedLiquid(liquidTypeCount, liquidTypeBufferLength); } } else { num = 0; } float capacity = receivingGameContainer.Capacity; ValidateCapacity(capacity, "receiver capacity"); float num2 = 0f; float num3 = 0f; if (drainOnly) { num2 = ClampLiquidAmountsToCapacity(targetLiquidAmounts, 0, liquidTypeCount, capacity); } else { num3 = sourceGameContainer.Capacity; ValidateCapacity(num3, "source capacity"); num2 = RouteLiquidCapacityOverflow(targetLiquidAmounts, liquidTypeCount, liquidTypeBufferLength, capacity, num3); } if (num != 0) { num2 += RedistributeUnreturnedLiquid(liquidTypeCount, liquidTypeBufferLength, capacity, num3); } ApplyLiquidTargets(receivingGameContainer, 0, liquidTypeCount, liquidTypeBufferLength, receivingDrainPlan); if (!drainOnly) { ApplyLiquidTargets(sourceGameContainer, 1, liquidTypeCount, liquidTypeBufferLength, sourceDrainPlan); } transferCommitted = true; } private void CaptureUnreturnedLiquid(int typeCount, int stride) { unreturnedLiquidByType = new float[typeCount]; for (int i = 0; i < typeCount; i++) { float num = initialSimulatedLiquidAmounts[i] + initialSimulatedLiquidAmounts[stride + i]; float num2 = targetLiquidAmounts[i] + (drainOnly ? 0f : targetLiquidAmounts[stride + i]); float num3 = Mathf.Max(0f, num - num2); unreturnedLiquidByType[i] = ((num3 > 0.001f) ? num3 : 0f); } } private float RedistributeUnreturnedLiquid(int typeCount, int stride, float receiverCapacity, float sourceCapacity) { float num = Mathf.Max(0f, receiverCapacity - SumLiquidAmounts(targetLiquidAmounts, 0, typeCount)); float num2 = (drainOnly ? 0f : Mathf.Max(0f, sourceCapacity - SumLiquidAmounts(targetLiquidAmounts, stride, typeCount))); float num3 = SumLiquidAmounts(unreturnedLiquidByType, 0, typeCount); float num4 = Mathf.Min(num3, num2); if (num4 > 0f && num3 > 0f) { float num5 = num4 / num3; for (int i = 0; i < typeCount; i++) { float num6 = unreturnedLiquidByType[i] * num5; targetLiquidAmounts[stride + i] += num6; unreturnedLiquidByType[i] -= num6; } } num3 = SumLiquidAmounts(unreturnedLiquidByType, 0, typeCount); float num7 = Mathf.Min(num3, num); if (num7 > 0f && num3 > 0f) { float num8 = num7 / num3; for (int j = 0; j < typeCount; j++) { float num9 = unreturnedLiquidByType[j] * num8; targetLiquidAmounts[j] += num9; unreturnedLiquidByType[j] -= num9; } } return SumLiquidAmounts(unreturnedLiquidByType, 0, typeCount); } private void BuildTargetLiquidAmounts(WaterContainerItem container, int containerIndex, int typeCount, int stride) { float currentTotal = container.CurrentTotal; ValidateAmount(currentTotal, $"container {containerIndex + 1} amount"); int num = containerIndex * stride; float num2 = 0f; for (int i = 0; i < typeCount; i++) { string liquidId = liquidSimulation.GetLiquidId(i); float liquidAmount = GetLiquidAmount(container, liquidId); num2 += liquidAmount; float num3 = finalSimulatedLiquidAmounts[num + i] - initialSimulatedLiquidAmounts[num + i]; float num4 = liquidAmount + num3; if (num4 < -0.001f) { throw new InvalidOperationException("The simulation tried to remove more liquid '" + liquidId + "' than container " + $"{containerIndex + 1} holds."); } targetLiquidAmounts[num + i] = Mathf.Max(0f, num4); } if (Mathf.Abs(num2 - currentTotal) > 0.01f) { throw new InvalidOperationException($"Container {containerIndex + 1} liquid stacks total {num2:F3} ml, " + $"but the game reports {currentTotal:F3} ml."); } } private float GetLiquidAmount(WaterContainerItem container, string liquidId) { float num = 0f; foreach (LiquidStack item in container.stack) { if (item != null && string.Equals(item.liquidId, liquidId, StringComparison.Ordinal)) { num += item.amount; } } return num; } private float ClampLiquidAmountsToCapacity(float[] amounts, int offset, int typeCount, float capacity) { float num = SumLiquidAmounts(amounts, offset, typeCount); float num2 = Mathf.Max(0f, num - capacity); RemoveLiquidProportionally(amounts, offset, typeCount, num2, num); return num2; } private float RouteLiquidCapacityOverflow(float[] amounts, int typeCount, int stride, float receiverCapacity, float sourceCapacity) { float num = 0f; float num2 = SumLiquidAmounts(amounts, 0, typeCount); float num3 = Mathf.Max(0f, num2 - receiverCapacity); if (num3 > 0f) { float num4 = SumLiquidAmounts(amounts, stride, typeCount); float num5 = Mathf.Min(num3, Mathf.Max(0f, sourceCapacity - num4)); MoveLiquidProportionally(amounts, 0, stride, typeCount, num5, num2); RemoveLiquidProportionally(amounts, 0, typeCount, num3 - num5, num2 - num5); num += num3 - num5; } float num6 = SumLiquidAmounts(amounts, stride, typeCount); float num7 = Mathf.Max(0f, num6 - sourceCapacity); if (num7 > 0f) { float num8 = SumLiquidAmounts(amounts, 0, typeCount); float num9 = Mathf.Min(num7, Mathf.Max(0f, receiverCapacity - num8)); MoveLiquidProportionally(amounts, stride, 0, typeCount, num9, num6); RemoveLiquidProportionally(amounts, stride, typeCount, num7 - num9, num6 - num9); num += num7 - num9; } return num; } private static float SumLiquidAmounts(float[] amounts, int offset, int typeCount) { float num = 0f; for (int i = 0; i < typeCount; i++) { num += amounts[offset + i]; } return num; } private static void MoveLiquidProportionally(float[] amounts, int sourceOffset, int destinationOffset, int typeCount, float moved, float sourceTotal) { if (!(moved <= 0f) && !(sourceTotal <= 0f)) { float num = Mathf.Min(1f, moved / sourceTotal); for (int i = 0; i < typeCount; i++) { float num2 = amounts[sourceOffset + i] * num; amounts[sourceOffset + i] -= num2; amounts[destinationOffset + i] += num2; } } } private static void RemoveLiquidProportionally(float[] amounts, int offset, int typeCount, float removed, float total) { if (!(removed <= 0f) && !(total <= 0f)) { float num = Mathf.Clamp01(1f - removed / total); for (int i = 0; i < typeCount; i++) { amounts[offset + i] *= num; } } } private void ApplyLiquidTargets(WaterContainerItem container, int containerIndex, int typeCount, int stride, List<float> drainPlan) { int num = containerIndex * stride; if (drainPlan.Count != container.stack.Count) { throw new InvalidOperationException($"Container {containerIndex + 1} stack changed while the minigame was active."); } for (int i = 0; i < drainPlan.Count; i++) { drainPlan[i] = 0f; } for (int j = 0; j < typeCount; j++) { string liquidId = liquidSimulation.GetLiquidId(j); float num2 = GetLiquidAmount(container, liquidId) - targetLiquidAmounts[num + j]; if (num2 <= 0.001f) { continue; } float num3 = num2; for (int k = 0; k < container.stack.Count; k++) { if (!(num3 > 0.001f)) { break; } LiquidStack val = container.stack[k]; if (val != null && string.Equals(val.liquidId, liquidId, StringComparison.Ordinal)) { float num4 = Mathf.Min(Mathf.Max(0f, val.amount - drainPlan[k]), num3); drainPlan[k] += num4; num3 -= num4; } } if (num3 > 0.001f) { throw new InvalidOperationException($"The container could not drain {num2:F3} ml of liquid '{liquidId}'."); } } if (Sum(drainPlan) > 0.001f) { container.Drain(drainPlan); } for (int l = 0; l < typeCount; l++) { string liquidId2 = liquidSimulation.GetLiquidId(l); float liquidAmount = GetLiquidAmount(container, liquidId2); float num5 = targetLiquidAmounts[num + l] - liquidAmount; if (!(num5 <= 0.001f)) { float num6 = container.AddLiquid(liquidId2, num5); if (Mathf.Abs(num6 - num5) > 0.001f) { throw new InvalidOperationException($"The container accepted {num6:F3} of {num5:F3} ml of liquid '{liquidId2}'."); } } } } private static List<float> CreateDrainPlan(WaterContainerItem container) { List<float> list = new List<float>((Object.op_Implicit((Object)(object)container) && container.stack != null) ? container.stack.Count : 0); if (Object.op_Implicit((Object)(object)container) && container.stack != null) { for (int i = 0; i < container.stack.Count; i++) { list.Add(0f); } } return list; } private static void ApplySingleContainerAmount(WaterContainerItem container, float targetAmount) { float currentTotal = container.CurrentTotal; float num = targetAmount - currentTotal; if (num < -0.001f) { DrainLiquid(container, 0f - num); } else if (num > 0.001f) { AddLiquid(container, GetLiquidComposition(container), num); } } private static void ApplyLiquidAmounts(WaterContainerItem receiver, WaterContainerItem source, float targetReceiverAmount, float targetSourceAmount) { float currentTotal = receiver.CurrentTotal; float currentTotal2 = source.CurrentTotal; float num = targetReceiverAmount - currentTotal; float num2 = targetSourceAmount - currentTotal2; float num3 = ((num > 0f && num2 < 0f) ? Mathf.Min(num, 0f - num2) : 0f); float num4 = ((num2 > 0f && num < 0f) ? Mathf.Min(num2, 0f - num) : 0f); float num5 = Mathf.Max(0f, num - num3); float num6 = Mathf.Max(0f, num2 - num4); List<LiquidPortion> liquidComposition = GetLiquidComposition(source); List<LiquidPortion> liquidComposition2 = GetLiquidComposition(receiver); List<LiquidPortion> list = ((liquidComposition.Count > 0) ? liquidComposition : liquidComposition2); if (list.Count == 0 && (num5 > 0.001f || num6 > 0.001f)) { throw new InvalidOperationException("Cannot add simulated liquid because neither game container has a liquid type to use."); } if (num3 > 0.001f) { TransferLiquid(source, receiver, num3); } if (num4 > 0.001f) { TransferLiquid(receiver, source, num4); } float num7 = receiver.CurrentTotal - targetReceiverAmount; if (num7 > 0.001f) { DrainLiquid(receiver, num7); } float num8 = source.CurrentTotal - targetSourceAmount; if (num8 > 0.001f) { DrainLiquid(source, num8); } float num9 = targetReceiverAmount - receiver.CurrentTotal; if (num9 > 0.001f) { AddLiquid(receiver, list, num9); } float num10 = targetSourceAmount - source.CurrentTotal; if (num10 > 0.001f) { AddLiquid(source, list, num10); } } private static List<LiquidPortion> GetLiquidComposition(WaterContainerItem container) { List<LiquidPortion> list = new List<LiquidPortion>(container.stack.Count); foreach (LiquidStack item in container.stack) { if (item != null && !string.IsNullOrEmpty(item.liquidId) && item.amount > 0f && !float.IsNaN(item.amount) && !float.IsInfinity(item.amount)) { list.Add(new LiquidPortion(item.liquidId, item.amount)); } } return list; } private static void TransferLiquid(WaterContainerItem donor, WaterContainerItem receiver, float amount) { List<string> list = new List<string>(donor.stack.Count); foreach (LiquidStack item in donor.stack) { list.Add(item?.liquidId); } List<float> list2 = donor.CalculateDrain(amount); if (list2.Count != list.Count) { throw new InvalidOperationException("The game's liquid stack changed while calculating the transfer."); } float num = Sum(list2); donor.Drain(list2); for (int i = 0; i < list2.Count; i++) { float num2 = list2[i]; if (!(num2 <= 0f)) { float num3 = receiver.AddLiquid(list[i], num2); if (Mathf.Abs(num3 - num2) > 0.001f) { throw new InvalidOperationException($"The receiver accepted {num3:F3} of {num2:F3} ml of liquid '{list[i]}'."); } } } if (Mathf.Abs(num - amount) > 0.001f) { throw new InvalidOperationException($"The donor could provide {num:F3} of {amount:F3} ml for transfer."); } } private static void DrainLiquid(WaterContainerItem container, float amount) { List<float> list = container.CalculateDrain(amount); float num = Sum(list); container.Drain(list); if (Mathf.Abs(num - amount) > 0.001f) { throw new InvalidOperationException($"The container could drain {num:F3} of {amount:F3} ml."); } } private static void AddLiquid(WaterContainerItem container, List<LiquidPortion> composition, float amount) { float num = 0f; foreach (LiquidPortion item in composition) { num += item.Amount; } if (num <= 0f) { throw new InvalidOperationException("The selected liquid composition is empty."); } float num2 = amount; for (int i = 0; i < composition.Count; i++) { if (!(num2 > 0.001f)) { break; } float num3 = ((i == composition.Count - 1) ? num2 : (amount * (composition[i].Amount / num))); num3 = Mathf.Min(num3, num2); float num4 = container.AddLiquid(composition[i].LiquidId, num3); num2 -= num4; } if (num2 > 0.001f) { throw new InvalidOperationException($"The container could not accept {num2:F3} ml of simulated liquid."); } } private static float RouteCapacityOverflow(ref float receiverAmount, float receiverCapacity, ref float sourceAmount, float sourceCapacity) { receiverAmount = Mathf.Max(0f, receiverAmount); sourceAmount = Mathf.Max(0f, sourceAmount); float num = 0f; if (receiverAmount > receiverCapacity) { float num2 = receiverAmount - receiverCapacity; receiverAmount = receiverCapacity; float num3 = Mathf.Min(num2, Mathf.Max(0f, sourceCapacity - sourceAmount)); sourceAmount += num3; num += num2 - num3; } if (sourceAmount > sourceCapacity) { float num4 = sourceAmount - sourceCapacity; sourceAmount = sourceCapacity; float num5 = Mathf.Min(num4, Mathf.Max(0f, receiverCapacity - receiverAmount)); receiverAmount += num5; num += num4 - num5; } return num; } private static float Sum(List<float> amounts) { float num = 0f; foreach (float amount in amounts) { num += amount; } return num; } private static void ValidateAmount(float amount, string label) { if (amount < 0f || float.IsNaN(amount) || float.IsInfinity(amount)) { throw new InvalidOperationException($"The game reported an invalid {label}: {amount}."); } } private static void ValidateCapacity(float capacity, string label) { if (capacity < 0f || float.IsNaN(capacity) || float.IsInfinity(capacity)) { throw new InvalidOperationException($"The game reported an invalid {label}: {capacity}."); } } private static ContainerVisual CreateContainer(RectTransform parent, string name, Sprite sprite, Vector2 position, float rotation, bool isSyringe) { //IL_002e: 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_0067: 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_0087: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) Image component = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(CanvasRenderer), typeof(Image) }).GetComponent<Image>(); RectTransform rectTransform = ((Graphic)component).rectTransform; ((Transform)rectTransform).SetParent((Transform)(object)parent, false); rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = position; Rect rect = sprite.rect; float width = ((Rect)(ref rect)).width; rect = sprite.rect; rectTransform.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height); ((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, rotation); ((Transform)rectTransform).localScale = Vector3.one * 4f; component.sprite = sprite; component.preserveAspect = false; ((Graphic)component).raycastTarget = true; Vector2 position2; float width2; bool flag = ModSprites.TryFindOpening(sprite, out position2, out width2); Vector2 val = Vector2.zero; Vector2 val2 = Vector2.zero; Vector2[] points = Array.Empty<Vector2>(); Vector2[][] interiorWalls = Array.Empty<Vector2[]>(); Vector2[] collisionOutlinePoints = points; SyringeGeometry geometry = (isSyringe ? CreateSyringeGeometry(sprite) : default(SyringeGeometry)); if (isSyringe) { position2 = geometry.OpeningCenter; val = geometry.OpeningLeft; val2 = geometry.OpeningRight; width2 = Vector2.Distance(val, val2); flag = true; points = geometry.FluidOutline; collisionOutlinePoints = geometry.CollisionOutline; } else if (flag) { val = position2 - new Vector2(width2 * 0.5f, 0f); val2 = position2 + new Vector2(width2 * 0.5f, 0f); if (ModSprites.TryFindOutline(sprite, position2, width2, out points)) { interiorWalls = ModSprites.FindInteriorWalls(sprite, position2, width2); } } if (!isSyringe) { collisionOutlinePoints = points; } return new ContainerVisual(rectTransform, position2, val, val2, flag, points, interiorWalls, collisionOutlinePoints, isSyringe, geometry); } private void StartDragging(ContainerVisual container, Vector2 handPosition) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) heldVisual = container; heldContainer = container.Transform; heldOffset = container.Transform.anchoredPosition - handPosition / fitScale; } private void StartRotating(ContainerVisual container, Vector2 handPosition) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0036: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) activeRotationContainer = container; rotationAngle = ((Transform)container.Transform).localEulerAngles.z; rotationStartPointer = handPosition / fitScale; rotationStartCenter = container.Transform.anchoredPosition; rotationTrackingStarted = false; rotationVerticalSector = Mathf.FloorToInt(rotationAngle / 180f); if (container.IsSyringe) { rotationPivotPosition = container.Transform.anchoredPosition + TransformOpeningPoint(container.Transform, container.Geometry.NeedlePoint); Vector2 val = rotationStartPointer - rotationPivotPosition; rotationLastPointerAngle = Mathf.Atan2(val.y, val.x) * 57.29578f; rotationTrackingStarted = true; } else if (container.HasRotationPivot && !IsAtVerticalPosition(rotationAngle)) { StartPivotTracking(rotationStartPointer); } } private void RotateContainer(Vector2 handPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) //IL_00be: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) Vector2 val = handPosition / fitScale; if (!rotationTrackingStarted) { Vector2 val2 = rotationStartPointer - rotationStartCenter; Vector2 val3 = val - rotationStartCenter; float num = Vector2.SignedAngle(val2, val3); if (Mathf.Abs(num) < 0.1f) { return; } activeRotationContainer.PivotIsRight = num < 0f; activeRotationContainer.HasRotationPivot = true; if (IsAtVerticalPosition(rotationAngle)) { int num2 = Mathf.RoundToInt(rotationAngle / 180f); rotationVerticalSector = ((num < 0f) ? (num2 - 1) : num2); } StartPivotTracking(rotationStartPointer); } Vector2 val4 = val - rotationPivotPosition; if (((Vector2)(ref val4)).sqrMagnitude < 0.01f) { return; } float num3 = Mathf.Atan2(val4.y, val4.x) * 57.29578f; float num4 = Mathf.DeltaAngle(rotationLastPointerAngle, num3); rotationLastPointerAngle = num3; if (Mathf.Abs(num4) < 0.01f) { return; } ContainerVisual containerVisual = activeRotationContainer; Vector2 rotationPivotPoint = GetRotationPivotPoint(containerVisual); float num5 = 0f; Vector2[] array = (containerVisual.IsSyringe ? containerVisual.CollisionOutlinePoints : containerVisual.OutlinePoints); foreach (Vector2 val5 in array) { num5 = Mathf.Max(num5, Vector2.Distance(val5, rotationPivotPoint) * ((Transform)containerVisual.Transform).localScale.x); } float num6 = num5 * Mathf.Abs(num4) * ((float)Math.PI / 180f); int num7 = Mathf.Max(Mathf.CeilToInt(Mathf.Abs(num4) / 2f), Mathf.CeilToInt(num6 / 2f)); float num8 = num4 / (float)Mathf.Max(1, num7); Vector2 anchoredPosition = containerVisual.Transform.anchoredPosition; float z = ((Transform)containerVisual.Transform).localEulerAngles.z; for (int j = 0; j < num7; j++) { float num9 = rotationAngle; float angle = num9 + num8; ApplyRotationPose(containerVisual, angle); if (WouldOverlap(containerVisual)) { ApplyRotationPose(containerVisual, num9); break; } rotationAngle = angle; if (TrySwitchRotationPivot(containerVisual, num9, rotationAngle, val)) { break; } } liquidSimulation.ApplyContainerPoseChange(containerVisual.Transform, anchoredPosition, z, containerVisual.Transform.anchoredPosition, ((Transform)containerVisual.Transform).localEulerAngles.z, Vector2.one * 1f); } private void MoveContainer(ContainerVisual visual, Vector2 targetPosition) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0050: 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) RectTransform transform = visual.Transform; Vector2 anchoredPosition = transform.anchoredPosition; float num = Vector2.Distance(anchoredPosition, targetPosition); int num2 = Mathf.Max(1, Mathf.CeilToInt(num / 2f)); for (int i = 1; i <= num2; i++) { Vector2 anchoredPosition2 = Vector2.Lerp(anchoredPosition, targetPosition, (float)i / (float)num2); transform.anchoredPosition = anchoredPosition2; if (WouldOverlap(visual)) { transform.anchoredPosition = Vector2.Lerp(anchoredPosition, targetPosition, (float)(i - 1) / (float)num2); break; } } liquidSimulation.TranslateContainerDrops(transform, transform.anchoredPosition - anchoredPosition, new Vector2(1f, 1f)); } private void ApplyRotationPose(ContainerVisual visual, float angle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003a: Unknown result type (might be due to invalid IL or missing references) Vector2 rotationPivotPoint = GetRotationPivotPoint(visual); ((Transform)visual.Transform).localRotation = Quaternion.Euler(0f, 0f, angle); visual.Transform.anchoredPosition = rotationPivotPosition - TransformOpeningPoint(visual.Transform, rotationPivotPoint); } private static Vector2 GetRotationPivotPoint(ContainerVisual visual) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) if (!visual.IsSyringe) { if (!visual.PivotIsRight) { return visual.LeftOpeningPoint; } return visual.RightOpeningPoint; } return visual.Geometry.NeedlePoint; } private bool WouldOverlap(ContainerVisual moving) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_004f: 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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) ContainerVisual containerVisual = ((moving == receivingContainer) ? sourceContainer : receivingContainer); RectTransform transform = moving.Transform; RectTransform transform2 = containerVisual.Transform; return ContainerShapeCollision.Overlaps(moving.CollisionOutlinePoints, transform.anchoredPosition, ((Transform)transform).localScale.x, ((Transform)transform).localEulerAngles.z, containerVisual.CollisionOutlinePoints, transform2.anchoredPosition, ((Transform)transform2).localScale.x, ((Transform)transform2).localEulerAngles.z); } private void StartPivotTracking(Vector2 pointer) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0044: Unknown result type (might be due to invalid IL or missing references) ContainerVisual containerVisual = activeRotationContainer; Vector2 rotationPivotPoint = GetRotationPivotPoint(containerVisual); rotationPivotPosition = containerVisual.Transform.anchoredPosition + TransformOpeningPoint(containerVisual.Transform, rotationPivotPoint); Vector2 val = pointer - rotationPivotPosition; rotationLastPointerAngle = Mathf.Atan2(val.y, val.x) * 57.29578f; rotationTrackingStarted = true; } private bool TrySwitchRotationPivot(ContainerVisual visual, float previousAngle, float currentAngle, Vector2 pointer) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) //IL_00a8: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (visual.IsSyringe) { return false; } bool flag = false; if (currentAngle > previousAngle) { float num = (float)(rotationVerticalSector + 1) * 180f; if (currentAngle >= num + 2f) { rotationVerticalSector++; flag = true; } } else if (currentAngle < previousAngle) { float num2 = (float)rotationVerticalSector * 180f; if (currentAngle <= num2 - 2f) { rotationVerticalSector--; flag = true; } } if (!flag) { return false; } visual.PivotIsRight = !visual.PivotIsRight; Vector2 point = (visual.PivotIsRight ? visual.RightOpeningPoint : visual.LeftOpeningPoint); rotationPivotPosition = visual.Transform.anchoredPosition + TransformOpeningPoint(visual.Transform, point); Vector2 val = pointer - rotationPivotPosition; rotationLastPointerAngle = Mathf.Atan2(val.y, val.x) * 57.29578f; return true; } private static bool IsAtVerticalPosition(float angle) { float num = Mathf.Round(angle / 180f) * 180f; return Mathf.Abs(Mathf.DeltaAngle(angle, num)) <= 2f; } private static void PositionContainersSideBySide(ContainerVisual receiver, ContainerVisual source) { //IL_0006: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0084: 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_008e: 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) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00cb: Unknown result type (might be due to invalid IL or missing references) Rect rect = receiver.Transform.rect; float num = ((Rect)(ref rect)).width * ((Transform)receiver.Transform).localScale.x; rect = source.Transform.rect; float num2 = ((Rect)(ref rect)).width * ((Transform)source.Transform).localScale.x; float num3 = (0f - (num + 40f + num2)) * 0.5f + num * 0.5f; float num4 = num3 + num * 0.5f + 40f + num2 * 0.5f; Vector2 val = TransformOpeningPoint(receiver.Transform, receiver.OpeningCenterPoint); Vector2 val2 = TransformOpeningPoint(source.Transform, source.OpeningCenterPoint); receiver.Transform.anchoredPosition = new Vector2(num3, 0f - val.y); source.Transform.anchoredPosition = new Vector2(num4, 0f - val2.y); } private static float GetFitScale(RectTransform screen, RectTransform layoutRoot, params ContainerVisual[] containers) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) Rect rect = screen.rect; Vector2 val = ((Rect)(ref rect)).size * 0.5f - Vector2.one * 40f; float maxX = 0f; float maxY = 0f; foreach (ContainerVisual containerVisual in containers) { IncludeExtent(layoutRoot, containerVisual.Transform, ref maxX, ref maxY); } float num = ((maxX > 0f) ? (val.x / maxX) : 1f); float num2 = ((maxY > 0f) ? (val.y / maxY) : 1f); return Mathf.Clamp(Mathf.Min(num, num2), 0.01f, 1f); } private static void IncludeExtent(RectTransform reference, RectTransform target, ref float maxX, ref float maxY) { float minX = float.PositiveInfinity; float maxX2 = float.NegativeInfinity; float minY = float.PositiveInfinity; float maxY2 = float.NegativeInfinity; IncludeBounds(reference, target, ref minX, ref maxX2, ref minY, ref maxY2); maxX = Mathf.Max(new float[3] { maxX, Mathf.Abs(minX), Mathf.Abs(maxX2) }); maxY = Mathf.Max(new float[3] { maxY, Mathf.Abs(minY), Mathf.Abs(maxY2) }); } private static void IncludeBounds(RectTransform reference, RectTransform target, ref float minX, ref float maxX, ref float minY, ref float maxY) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_005c: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; target.GetWorldCorners(array); Vector3[] array2 = array; foreach (Vector3 val in array2) { Vector3 val2 = ((Transform)reference).InverseTransformPoint(val); minX = Mathf.Min(minX, val2.x); maxX = Mathf.Max(maxX, val2.x); minY = Mathf.Min(minY, val2.y); maxY = Mathf.Max(maxY, val2.y); } } private static Vector2 TransformOpeningPoint(RectTransform container, Vector2 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Transform)container).localRotation * Vector3.Scale(Vector2.op_Implicit(point), ((Transform)container).localScale); return new Vector2(val.x, val.y); } } internal sealed class HandAlphaGradient : BaseMeshEffect { private const int FadeSteps = 16; private const float TransparentHeight = 0.45f; private const float FadeHeight = 0.3f; private readonly List<UIVertex> sourceVertices = new List<UIVertex>(); private readonly List<UIVertex> lowerClip = new List<UIVertex>(6); private readonly List<UIVertex> clippedPolygon = new List<UIVertex>(6); public override void ModifyMesh(VertexHelper vertexHelper) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid