From a22c505984697881f5f911a165ee022087b69e09 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 20 May 2024 22:36:58 +0800 Subject: *rename --- Thronefall_1_0/Decompile/BuildingInteractor.cs | 437 ------------------------- 1 file changed, 437 deletions(-) delete mode 100644 Thronefall_1_0/Decompile/BuildingInteractor.cs (limited to 'Thronefall_1_0/Decompile/BuildingInteractor.cs') diff --git a/Thronefall_1_0/Decompile/BuildingInteractor.cs b/Thronefall_1_0/Decompile/BuildingInteractor.cs deleted file mode 100644 index 4648471..0000000 --- a/Thronefall_1_0/Decompile/BuildingInteractor.cs +++ /dev/null @@ -1,437 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -public class BuildingInteractor : InteractorBase, DayNightCycle.IDaytimeSensitive -{ - public enum InteractionState - { - None, - Harvest, - Upgrade - } - - public static bool displayAllBuildPreviews; - - public BuildSlot targetBuilding; - - public Hp buildingHP; - - public CoinSpawner coinSpawner; - - public GameObject harvestCue; - - public GameObject harvestDeniedCue; - - public GameObject upgradeCue; - - public CostDisplay costDisplay; - - public Material previewMaterial; - - private List incomeModifiers = new List(); - - private InteractionState currentState; - - private bool knockedOutTonight; - - private bool harvestedToday; - - private bool focussed; - - private Mesh upgradePreviewMesh; - - private bool interactionComplete; - - private bool interactionStarted; - - private bool isWaitingForChoice; - - private PlayerInteraction bufferedPlayer; - - public bool buildingIsCurrentlyBusyAndCantBeUpgraded; - - public List IncomeModifiers => incomeModifiers; - - public bool KnockedOutTonight => knockedOutTonight; - - public bool canBeHarvested - { - get - { - if (targetBuilding.State == BuildSlot.BuildingState.Built && !harvestedToday && targetBuilding.GoldIncome > 0) - { - return !knockedOutTonight; - } - return false; - } - } - - public bool harvestIsDenied - { - get - { - if (targetBuilding.State == BuildSlot.BuildingState.Built && targetBuilding.GoldIncome > 0) - { - return knockedOutTonight; - } - return false; - } - } - - public int GoldIncome => targetBuilding.GoldIncome; - - public bool HarvestCueVisible => harvestCue.activeSelf; - - public bool UpgradeCueVisible => upgradeCue.activeSelf; - - public override bool CanBeInteractedWith => currentState != InteractionState.None; - - public bool IsWaitingForChoice => isWaitingForChoice; - - public Mesh UpgradePreviewMesh - { - get - { - if (targetBuilding.State == BuildSlot.BuildingState.Built) - { - if (!targetBuilding.CanBeUpgraded) - { - return null; - } - BuildSlot.Upgrade upgrade = targetBuilding.Upgrades[targetBuilding.Level]; - int num = Mathf.RoundToInt(Time.time * 2f); - return upgrade.upgradeBranches[num % upgrade.upgradeBranches.Count].replacementMesh; - } - return targetBuilding.MainMesh.mesh; - } - } - - public void MarkAsHarvested() - { - harvestedToday = true; - } - - public override string ReturnTooltip() - { - return targetBuilding.ReturnTooltip(); - } - - private void Start() - { - targetBuilding.buildingInteractor = this; - if ((bool)buildingHP) - { - buildingHP.OnKillOrKnockout.AddListener(OnKnockOut); - } - targetBuilding.OnUpgrade.AddListener(OnTargetUpgrade); - targetBuilding.OnUpgradeCancel.AddListener(OnTargetUpgradeCanceled); - DayNightCycle.Instance.RegisterDaytimeSensitiveObject(this); - UpdateInteractionState(); - if ((bool)TagManager.instance) - { - TagManager.instance.playerBuildingInteractors.Add(this); - } - } - - public override void InteractionBegin(PlayerInteraction player) - { - if (!isWaitingForChoice) - { - interactionStarted = true; - interactionComplete = false; - bufferedPlayer = player; - if (currentState == InteractionState.Upgrade) - { - ThronefallAudioManager.Oneshot(ThronefallAudioManager.AudioOneShot.CoinslotInteractionStart); - } - } - } - - public override void InteractionHold(PlayerInteraction player) - { - if (currentState != InteractionState.Upgrade || interactionComplete || !interactionStarted || isWaitingForChoice) - { - return; - } - if (costDisplay.CompletelyFilled) - { - isWaitingForChoice = targetBuilding.NextUpgradeIsChoice; - targetBuilding.TryToBuildOrUpgradeAndPay(player); - if (!isWaitingForChoice) - { - BuildComplete(); - } - else - { - costDisplay.gameObject.SetActive(value: false); - } - } - else if (player.Balance > 0) - { - if (costDisplay.FillUp()) - { - player.SpendCoins(1); - } - } - else - { - costDisplay.Deny(); - } - } - - public override void InteractionEnd(PlayerInteraction player) - { - if (!isWaitingForChoice && interactionStarted) - { - interactionStarted = false; - if (currentState == InteractionState.Upgrade) - { - costDisplay.CancelFill(player); - ThronefallAudioManager.Instance.MakeSureCoinFillSoundIsNotPlayingAnymore(); - } - } - } - - private void BuildComplete() - { - harvestedToday = true; - interactionComplete = true; - costDisplay.OnCompletion(); - UpdateInteractionState(); - } - - private void CancelBuild() - { - costDisplay.CancelFill(bufferedPlayer); - } - - private void OnTargetUpgrade() - { - if (isWaitingForChoice) - { - isWaitingForChoice = false; - costDisplay.gameObject.SetActive(value: true); - interactionStarted = false; - BuildComplete(); - } - } - - private void OnTargetUpgradeCanceled() - { - if (isWaitingForChoice) - { - isWaitingForChoice = false; - costDisplay.gameObject.SetActive(value: true); - interactionStarted = false; - CancelBuild(); - } - } - - public void OnDusk() - { - knockedOutTonight = false; - UpdateInteractionState(forceState: true); - } - - public void OnDawn_BeforeSunrise() - { - harvestedToday = false; - } - - public void OnDawn_AfterSunrise() - { - PlayerInteraction component = TagManager.instance.Players[0].GetComponent(); - Harvest(component); - foreach (IncomeModifyer incomeModifier in incomeModifiers) - { - incomeModifier.OnDawn(); - } - UpdateInteractionState(); - } - - public void UpdateInteractionState(bool forceState = false, InteractionState forcedState = InteractionState.None) - { - if (isWaitingForChoice) - { - return; - } - base.gameObject.SetActive(value: true); - if (canBeHarvested) - { - currentState = InteractionState.Harvest; - } - else if (targetBuilding.CanBeUpgraded) - { - currentState = InteractionState.Upgrade; - } - else - { - currentState = InteractionState.None; - } - if (forceState) - { - currentState = forcedState; - } - if (harvestIsDenied) - { - harvestDeniedCue.SetActive(value: true); - } - else - { - harvestDeniedCue.SetActive(value: false); - } - if (buildingIsCurrentlyBusyAndCantBeUpgraded) - { - currentState = InteractionState.None; - } - switch (currentState) - { - case InteractionState.None: - harvestCue.SetActive(value: false); - upgradeCue.SetActive(value: false); - DisableCostDisplay(); - break; - case InteractionState.Harvest: - harvestCue.SetActive(value: true); - upgradeCue.SetActive(targetBuilding.CanBeUpgraded); - DisableCostDisplay(); - break; - case InteractionState.Upgrade: - harvestCue.SetActive(value: false); - if (focussed) - { - ActivateCostDisplay(); - upgradeCue.SetActive(value: false); - break; - } - DisableCostDisplay(); - if (targetBuilding.State == BuildSlot.BuildingState.Built) - { - upgradeCue.SetActive(value: true); - } - else - { - upgradeCue.SetActive(value: false); - } - break; - } - } - - public override void Focus(PlayerInteraction player) - { - focussed = true; - UpdateInteractionState(); - if (currentState == InteractionState.Harvest) - { - Harvest(player); - } - } - - public void Harvest(PlayerInteraction player) - { - if (canBeHarvested) - { - coinSpawner.TriggerCoinSpawn(targetBuilding.GoldIncome, player); - harvestedToday = true; - UpdateInteractionState(); - } - } - - public override void Unfocus(PlayerInteraction player) - { - focussed = false; - if (!costDisplay.CompletelyEmpty) - { - costDisplay.CancelFill(player); - } - UpdateInteractionState(); - ThronefallAudioManager.Instance.MakeSureCoinFillSoundIsNotPlayingAnymore(); - } - - private void ActivateCostDisplay() - { - costDisplay.UpdateDisplay(targetBuilding.NextUpgradeOrBuildCost); - } - - private void DisableCostDisplay() - { - costDisplay.Hide(); - } - - public void OnKnockOut() - { - knockedOutTonight = true; - } - - private void Update() - { - if ((focussed || displayAllBuildPreviews) && currentState == InteractionState.Upgrade) - { - if (!targetBuilding.ActivatorUpgradesThis) - { - PreviewSelf(); - } - else - { - targetBuilding.ActivatorBuilding.buildingInteractor.PreviewSelf(); - } - } - } - - public void PreviewSelf() - { - MeshFilter mainMesh = targetBuilding.MainMesh; - if ((bool)UpgradePreviewMesh) - { - Graphics.DrawMesh(UpgradePreviewMesh, targetBuilding.MainMesh.transform.localToWorldMatrix, previewMaterial, 0); - } - else if (!mainMesh.gameObject.activeInHierarchy) - { - Graphics.DrawMesh(mainMesh.mesh, mainMesh.transform.localToWorldMatrix, previewMaterial, 0); - } - int upgradeBranch = Mathf.RoundToInt(Time.time * 2f); - List gameObjectsThatWillUnlockWhenUpgraded = targetBuilding.GetGameObjectsThatWillUnlockWhenUpgraded(upgradeBranch); - for (int i = 0; i < gameObjectsThatWillUnlockWhenUpgraded.Count; i++) - { - if (gameObjectsThatWillUnlockWhenUpgraded[i].transform.parent == null) - { - PreviewGameObject(gameObjectsThatWillUnlockWhenUpgraded[i]); - } - else if (gameObjectsThatWillUnlockWhenUpgraded[i].transform.parent.gameObject.activeSelf || gameObjectsThatWillUnlockWhenUpgraded.Contains(gameObjectsThatWillUnlockWhenUpgraded[i].transform.parent.gameObject)) - { - PreviewGameObject(gameObjectsThatWillUnlockWhenUpgraded[i]); - } - } - for (int j = 0; j < targetBuilding.BuiltSlotsThatRelyOnThisBuilding.Count; j++) - { - BuildSlot buildSlot = targetBuilding.BuiltSlotsThatRelyOnThisBuilding[j]; - if (buildSlot.ActivatorUpgradesThis && buildSlot.ActivatorBuilding == targetBuilding && (bool)buildSlot.buildingInteractor) - { - buildSlot.buildingInteractor.PreviewSelf(); - } - } - List blueprintPreviewsThatWillUnlockWhenUpgraded = targetBuilding.GetBlueprintPreviewsThatWillUnlockWhenUpgraded(); - for (int k = 0; k < blueprintPreviewsThatWillUnlockWhenUpgraded.Count; k++) - { - mainMesh = blueprintPreviewsThatWillUnlockWhenUpgraded[k]; - Graphics.DrawMesh(mainMesh.mesh, mainMesh.transform.localToWorldMatrix, previewMaterial, 0); - } - } - - private void PreviewGameObject(GameObject _go) - { - MeshFilter[] componentsInChildren = _go.GetComponentsInChildren(); - foreach (MeshFilter meshFilter in componentsInChildren) - { - Graphics.DrawMesh(meshFilter.mesh, meshFilter.transform.localToWorldMatrix, previewMaterial, 0); - } - } - - private void OnDestroy() - { - if ((bool)TagManager.instance) - { - TagManager.instance.playerBuildingInteractors.Remove(this); - } - } -} -- cgit v1.1-26-g67d0