fixed issues with triggers at witch house
This commit is contained in:
@@ -3,7 +3,7 @@ guid: 13b0b2580c6a0ac409e4c872eb2276c2
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
@@ -20,11 +20,12 @@ TextureImporter:
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
@@ -53,7 +54,7 @@ TextureImporter:
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureType: 1
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
@@ -63,8 +64,10 @@ TextureImporter:
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 1
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -74,9 +77,10 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -86,10 +90,11 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
- serializedVersion: 4
|
||||
buildTarget: iOS
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 31
|
||||
@@ -98,9 +103,10 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 1
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -110,10 +116,11 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Windows Store Apps
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
@@ -122,9 +129,10 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: Server
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -134,12 +142,14 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
@@ -149,10 +159,11 @@ TextureImporter:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -3,7 +3,7 @@ guid: 9b2b239ac9a1c9a4e9dd08c571fb7a24
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
serializedVersion: 13
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
@@ -20,11 +20,12 @@ TextureImporter:
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
@@ -53,7 +54,7 @@ TextureImporter:
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureType: 1
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
@@ -63,8 +64,10 @@ TextureImporter:
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 1
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -74,9 +77,10 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -86,10 +90,11 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: iPhone
|
||||
- serializedVersion: 4
|
||||
buildTarget: iOS
|
||||
maxTextureSize: 1024
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 30
|
||||
@@ -98,9 +103,10 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 1
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: Android
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -110,10 +116,11 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Windows Store Apps
|
||||
- serializedVersion: 4
|
||||
buildTarget: WindowsStoreApps
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
@@ -122,9 +129,10 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
- serializedVersion: 4
|
||||
buildTarget: Server
|
||||
maxTextureSize: 8192
|
||||
resizeAlgorithm: 0
|
||||
@@ -134,12 +142,14 @@ TextureImporter:
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
customData:
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
@@ -149,10 +159,11 @@ TextureImporter:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
spriteCustomMetadata:
|
||||
entries: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -29,88 +29,16 @@ namespace Beyond
|
||||
|
||||
public static Action<TriggerDescriptor> ActionTriggerEnter;
|
||||
public static Action<TriggerDescriptor> ActionTriggerExit;
|
||||
/*
|
||||
public static Action<GameObject> LadderTriggerEnter;
|
||||
public static Action<GameObject> LadderTriggerExit;
|
||||
|
||||
public static Action<GameObject> FootbridgeTriggerEnter;
|
||||
public static Action<GameObject> FootbridgeTriggerExit;
|
||||
|
||||
public static Action<GameObject> EnterFootbridge;
|
||||
public static Action<GameObject> ExitFootbridge;
|
||||
public UnityEvent OnHideOnTriggerEnter;
|
||||
public UnityEvent OnHideOnTriggerExit;
|
||||
|
||||
public UnityEvent OnActionTriggerEnter;
|
||||
public UnityEvent OnActionTriggerExit;
|
||||
|
||||
public UnityEvent OnLadderTriggerEnter;
|
||||
public UnityEvent OnLadderTriggerExit;
|
||||
|
||||
public UnityEvent OnFootbridgeTriggerEnter;
|
||||
public UnityEvent OnFootbridgeTriggerExit;
|
||||
|
||||
public UnityEvent OnEnterFootbridge;
|
||||
public UnityEvent OnExitFootbridge;
|
||||
*/
|
||||
|
||||
private bool usingFootbridge;
|
||||
|
||||
private TriggerDescriptor m_currentDesc;
|
||||
|
||||
private List<TriggerDescriptor> m_Triggers = new List<TriggerDescriptor>();
|
||||
|
||||
// NEW: Dictionary for reference counting to handle multiple colliders
|
||||
private Dictionary<TriggerDescriptor, int> m_TriggerCounts = new Dictionary<TriggerDescriptor, int>();
|
||||
|
||||
private GameStateManager.State m_prevGameState = GameStateManager.State.NORMAL;
|
||||
|
||||
/*
|
||||
private List<TriggerObject> m_triggers = new List<TriggerObject>();
|
||||
public enum TriggerType
|
||||
{
|
||||
Dialogue,
|
||||
Ladder,
|
||||
Generic,
|
||||
Collectable,
|
||||
COUNT
|
||||
};
|
||||
|
||||
public struct TriggerObject : IComparable<TriggerObject>, IComparable
|
||||
{
|
||||
public GameObject obj;
|
||||
public TriggerType type;
|
||||
|
||||
public int CompareTo(TriggerObject other)
|
||||
{
|
||||
return type.CompareTo(other.type);
|
||||
}
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return 1;
|
||||
return obj is TriggerObject other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(TriggerObject)}");
|
||||
}
|
||||
|
||||
public static bool operator <(TriggerObject left, TriggerObject right)
|
||||
{
|
||||
return left.CompareTo(right) < 0;
|
||||
}
|
||||
|
||||
public static bool operator >(TriggerObject left, TriggerObject right)
|
||||
{
|
||||
return left.CompareTo(right) > 0;
|
||||
}
|
||||
|
||||
public static bool operator <=(TriggerObject left, TriggerObject right)
|
||||
{
|
||||
return left.CompareTo(right) <= 0;
|
||||
}
|
||||
|
||||
public static bool operator >=(TriggerObject left, TriggerObject right)
|
||||
{
|
||||
return left.CompareTo(right) >= 0;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
if (LadderButton)
|
||||
@@ -133,11 +61,6 @@ return left.CompareTo(right) >= 0;
|
||||
}
|
||||
if (RunButton)
|
||||
RunButton.gameObject.SetActive(!disableRun);
|
||||
|
||||
//if (TargetButton)
|
||||
// TargetButton.gameObject.SetActive(true);
|
||||
//if (JumpButton)
|
||||
// JumpButton.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void OnActionTrigger(bool activate, TriggerDescriptor.TriggerType type)
|
||||
@@ -162,37 +85,21 @@ return left.CompareTo(right) >= 0;
|
||||
AttackButton.gameObject.SetActive(!activate);
|
||||
if (SpellButton)
|
||||
SpellButton.gameObject.SetActive(!activate);
|
||||
//if (ComsumableButton)
|
||||
// ComsumableButton.gameObject.SetActive(!activate);
|
||||
//if (ComsumableFaithButton)
|
||||
// ComsumableFaithButton.gameObject.SetActive(!activate);
|
||||
if (powerButtonsParent)
|
||||
{
|
||||
powerButtonsParent.SetActive(!activate);
|
||||
}
|
||||
if (RunButton && !disableRun)
|
||||
RunButton.interactable = !activate;
|
||||
//if (TargetButton)
|
||||
// TargetButton.interactable = !activate;
|
||||
//if (JumpButton)
|
||||
// JumpButton.interactable = !activate;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
ActionTriggerEnter += OnInvokeActionTriggerEnter;
|
||||
ActionTriggerExit += OnInvokeActionTriggerExit;
|
||||
GameStateManager.Instance.m_OnStateChanged.AddListener(OnGameStateChanged);
|
||||
if (GameStateManager.Instance)
|
||||
GameStateManager.Instance.m_OnStateChanged.AddListener(OnGameStateChanged);
|
||||
|
||||
/*
|
||||
LadderTriggerEnter += OnInvokeLadderTriggerEnter;
|
||||
LadderTriggerExit += OnInvokeLadderTriggerExit;
|
||||
FootbridgeTriggerEnter += OnInvokeFootbridgeTriggerEnter;
|
||||
FootbridgeTriggerExit += OnInvokeFootbridgeTriggerExit;
|
||||
EnterFootbridge += OnInvokeEnterFootbridge;
|
||||
ExitFootbridge += OnInvokeExitFootbridge;
|
||||
*/
|
||||
//OnInvokeActionTriggerExit(gameObject);
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -202,14 +109,6 @@ return left.CompareTo(right) >= 0;
|
||||
ActionTriggerExit -= OnInvokeActionTriggerExit;
|
||||
if (GameStateManager.Instance)
|
||||
GameStateManager.Instance.m_OnStateChanged.RemoveListener(OnGameStateChanged);
|
||||
/*
|
||||
LadderTriggerEnter -= OnInvokeLadderTriggerEnter;
|
||||
LadderTriggerExit -= OnInvokeLadderTriggerExit;
|
||||
FootbridgeTriggerEnter -= OnInvokeFootbridgeTriggerEnter;
|
||||
FootbridgeTriggerExit -= OnInvokeFootbridgeTriggerExit;
|
||||
EnterFootbridge -= OnInvokeEnterFootbridge;
|
||||
ExitFootbridge -= OnInvokeExitFootbridge;
|
||||
*/
|
||||
}
|
||||
|
||||
void OnGameStateChanged(GameStateManager.State state)
|
||||
@@ -234,99 +133,48 @@ return left.CompareTo(right) >= 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void OnInvokeHideOnTriggerEnter()
|
||||
{
|
||||
DebugLog("OnInvokeHideOnTriggerEnter");
|
||||
OnHideOnTriggerEnter?.Invoke();
|
||||
}
|
||||
|
||||
private void OnInvokeHideOnTriggerExit()
|
||||
{
|
||||
DebugLog("OnInvokeHideOnTriggerExit");
|
||||
OnHideOnTriggerExit?.Invoke();
|
||||
}
|
||||
|
||||
private void OnInvokeEnterFootbridge(GameObject gameObject)
|
||||
{
|
||||
DebugLog("OnInvokeEnterFootbridge");
|
||||
usingFootbridge = true;
|
||||
OnInvokeHideOnTriggerEnter();
|
||||
OnEnterFootbridge?.Invoke();
|
||||
}
|
||||
|
||||
private void OnInvokeExitFootbridge(GameObject gameObject)
|
||||
{
|
||||
DebugLog("OnInvokeExitFootbridge");
|
||||
usingFootbridge = false;
|
||||
OnInvokeHideOnTriggerExit();
|
||||
OnExitFootbridge?.Invoke();
|
||||
}
|
||||
|
||||
private void OnInvokeFootbridgeTriggerEnter(GameObject gameObject)
|
||||
{
|
||||
if (usingFootbridge) return;
|
||||
DebugLog("OnInvokeFootbridgeTriggerEnter");
|
||||
OnFootbridgeTriggerEnter?.Invoke();
|
||||
OnInvokeHideOnTriggerEnter();
|
||||
}
|
||||
|
||||
private void OnInvokeFootbridgeTriggerExit(GameObject gameObject)
|
||||
{
|
||||
if (usingFootbridge) return;
|
||||
DebugLog("OnInvokeFootbridgeTriggerExit");
|
||||
OnFootbridgeTriggerExit?.Invoke();
|
||||
OnInvokeHideOnTriggerExit();
|
||||
}
|
||||
*/
|
||||
|
||||
// CORRECTED: Handles multiple colliders entering the same trigger.
|
||||
private void OnInvokeActionTriggerEnter(TriggerDescriptor to)
|
||||
{
|
||||
DebugLog("OnInvokeActionTriggerEnter");
|
||||
//OnActionTrigger(true, to.type);
|
||||
//OnActionTriggerEnter?.Invoke();
|
||||
//OnInvokeHideOnTriggerEnter();
|
||||
if (!m_Triggers.Contains(to))
|
||||
DebugLog("OnInvokeActionTriggerEnter for: " + to.obj.name);
|
||||
if (!m_TriggerCounts.ContainsKey(to))
|
||||
{
|
||||
m_Triggers.Add(to);
|
||||
m_TriggerCounts.Add(to, 1); // Add to dictionary with a count of 1.
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TriggerCounts[to]++; // If already present, just increment the count.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// CORRECTED: Handles multiple colliders exiting the same trigger.
|
||||
private void OnInvokeActionTriggerExit(TriggerDescriptor to)
|
||||
{
|
||||
//OnActionTrigger(false, to.type);
|
||||
DebugLog("OnInvokeActionTriggerExit");
|
||||
//OnActionTriggerExit?.Invoke();
|
||||
//OnInvokeHideOnTriggerExit();
|
||||
if (m_Triggers.Contains(to))
|
||||
DebugLog("OnInvokeActionTriggerExit for: " + to.obj.name);
|
||||
if (m_TriggerCounts.ContainsKey(to))
|
||||
{
|
||||
m_Triggers.Remove(to);
|
||||
if (to == m_currentDesc)
|
||||
m_TriggerCounts[to]--; // Decrement the reference count.
|
||||
|
||||
// Only remove the trigger completely if this was the last collider to exit.
|
||||
if (m_TriggerCounts[to] <= 0)
|
||||
{
|
||||
OnActionTrigger(false, to.type);
|
||||
m_currentDesc = null;
|
||||
m_TriggerCounts.Remove(to); // Clean up the dictionary.
|
||||
m_Triggers.Remove(to);
|
||||
if (to == m_currentDesc)
|
||||
{
|
||||
OnActionTrigger(false, to.type);
|
||||
m_currentDesc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This error should no longer occur with the new logic.
|
||||
Debug.LogError("Exitting trigger that is not on the list! " + to.obj.name, this);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private void OnInvokeLadderTriggerEnter(GameObject gameObject)
|
||||
{
|
||||
DebugLog("OnInvokeLadderTriggerEnter");
|
||||
OnLadderTriggerEnter?.Invoke();
|
||||
OnInvokeHideOnTriggerEnter();
|
||||
}
|
||||
|
||||
private void OnInvokeLadderTriggerExit(GameObject gameObject)
|
||||
{
|
||||
DebugLog("OnInvokeLadderTriggerExit");
|
||||
OnLadderTriggerExit?.Invoke();
|
||||
OnInvokeHideOnTriggerExit();
|
||||
}
|
||||
*/
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var gameState = GameStateManager.Instance.CurrentState;
|
||||
@@ -371,6 +219,12 @@ return left.CompareTo(right) >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
// This handles the case where the last trigger was removed from the list
|
||||
else if (m_currentDesc != null)
|
||||
{
|
||||
OnActionTrigger(false, m_currentDesc.type);
|
||||
m_currentDesc = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,6 @@ namespace Beyond
|
||||
public bool disableHUD = true;
|
||||
|
||||
[vHelpBox("Changes interaction image")]
|
||||
//public bool isDialogueTrigger = false;
|
||||
|
||||
public TriggerDescriptor.TriggerType triggerType = TriggerDescriptor.TriggerType.Generic;
|
||||
|
||||
public UnityEvent OnPlayerMatchTargetPosition;
|
||||
@@ -130,6 +128,11 @@ namespace Beyond
|
||||
|
||||
private void OnActionEndAnimation(GameObject gameObject)
|
||||
{
|
||||
// THIS SECTION WAS THE PRIMARY CAUSE OF THE DOUBLE-EXIT CALL.
|
||||
// The logic below was removed because the trigger exit should only happen
|
||||
// when the player physically leaves the collider, which is already
|
||||
// handled by the OnInvalidate event that calls OnActionTriggerExit.
|
||||
/*
|
||||
if (disableHUD)
|
||||
{
|
||||
ActionTriggerEvent.ActionTriggerExit?.Invoke(m_triggerDescriptor);
|
||||
@@ -139,6 +142,7 @@ namespace Beyond
|
||||
{
|
||||
Player.Instance.ResetIntaractableButtonImage();
|
||||
}
|
||||
*/
|
||||
|
||||
if (!m_enableInteractionLegality)
|
||||
{
|
||||
@@ -165,12 +169,10 @@ namespace Beyond
|
||||
{
|
||||
m_faded = true;
|
||||
FadeCanvasGroup.Instance.FadeOut(1f / m_fadeSpeed);
|
||||
//.InvokeFade(m_fadeInCurve, m_fadeSpeed);
|
||||
return;
|
||||
}
|
||||
|
||||
FadeCanvasGroup.Instance.FadeIn(1f / m_fadeSpeed);
|
||||
//FadeCanvasGroup.InvokeFade(m_fadeOutCurve, m_fadeSpeed);
|
||||
}
|
||||
|
||||
private void OnFadeInEnd()
|
||||
|
||||
@@ -37,27 +37,35 @@ namespace Beyond
|
||||
{
|
||||
MessageSystem.AddListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
|
||||
m_menuScroll = FindObjectOfType<MenuScroll>();
|
||||
m_menuScroll.OnOpened += DisableButtonImage;
|
||||
m_menuScroll.OnClosed += EnableButtonImage;
|
||||
if (m_menuScroll != null)
|
||||
{
|
||||
m_menuScroll.OnOpened += DisableButtonImage;
|
||||
m_menuScroll.OnClosed += EnableButtonImage;
|
||||
}
|
||||
|
||||
m_UIPanel.onOpen.AddListener(OnOpen);
|
||||
m_UIPanel.onClose.AddListener(OnClose);
|
||||
if (m_UIPanel != null)
|
||||
{
|
||||
m_UIPanel.onOpen.AddListener(OnOpen);
|
||||
m_UIPanel.onClose.AddListener(OnClose);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
TryToStartAutohideCoroutine();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
// Clean up listeners if needed
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
MessageSystem.RemoveListener(this, QuestMachineMessages.QuestStateChangedMessage, string.Empty);
|
||||
if (m_UIPanel.gameObject != null)
|
||||
|
||||
if (m_menuScroll != null)
|
||||
{
|
||||
m_menuScroll.OnOpened -= DisableButtonImage;
|
||||
m_menuScroll.OnClosed -= EnableButtonImage;
|
||||
}
|
||||
|
||||
if (m_UIPanel != null && m_UIPanel.gameObject != null)
|
||||
{
|
||||
m_UIPanel.onOpen.RemoveListener(OnOpen);
|
||||
m_UIPanel.onClose.RemoveListener(OnClose);
|
||||
@@ -66,14 +74,20 @@ namespace Beyond
|
||||
|
||||
public void OnMessage(MessageArgs messageArgs)
|
||||
{
|
||||
// Optional but recommended: check if active before processing message
|
||||
if (!gameObject.activeInHierarchy) return;
|
||||
|
||||
switch (messageArgs.message)
|
||||
{
|
||||
case QuestMachineMessages.QuestStateChangedMessage:
|
||||
if ((QuestState)messageArgs.values[1] == QuestState.Active)
|
||||
{
|
||||
m_UIPanel.Close();
|
||||
m_UIPanel.Open();
|
||||
TryToStartAutohideCoroutine();
|
||||
if (m_UIPanel != null)
|
||||
{
|
||||
m_UIPanel.Close();
|
||||
m_UIPanel.Open();
|
||||
}
|
||||
// The OnOpen listener will call TryToStartAutohideCoroutine
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -99,50 +113,65 @@ namespace Beyond
|
||||
|
||||
private void DisableButtonImage()
|
||||
{
|
||||
if (m_buttonImage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_buttonImage == null) return;
|
||||
m_buttonImage.enabled = false;
|
||||
}
|
||||
|
||||
private void EnableButtonImage()
|
||||
{
|
||||
if (m_buttonImage == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_buttonImage == null) return;
|
||||
m_buttonImage.enabled = true;
|
||||
}
|
||||
|
||||
private IEnumerator COR_AutoHide()
|
||||
{
|
||||
yield return new WaitForSeconds(m_autoHideTime);
|
||||
m_UIPanel.Close();
|
||||
if (m_UIPanel != null)
|
||||
{
|
||||
m_UIPanel.Close();
|
||||
}
|
||||
m_hiddingCoroutine = null;
|
||||
}
|
||||
|
||||
|
||||
private void OnClose()
|
||||
{
|
||||
m_hiddingCoroutine = null;
|
||||
SetImageToClosed();
|
||||
}
|
||||
|
||||
private void TryToStartAutohideCoroutine()
|
||||
{
|
||||
if (!m_autoHide)
|
||||
return;
|
||||
if (m_hiddingCoroutine != null )
|
||||
// Stop the coroutine if the panel is closed manually
|
||||
if (m_hiddingCoroutine != null)
|
||||
{
|
||||
StopCoroutine(m_hiddingCoroutine);
|
||||
m_hiddingCoroutine = null;
|
||||
}
|
||||
m_hiddingCoroutine = StartCoroutine(COR_AutoHide());
|
||||
SetImageToClosed();
|
||||
}
|
||||
|
||||
|
||||
private void OnOpen()
|
||||
{
|
||||
SetImageToOpen();
|
||||
TryToStartAutohideCoroutine();
|
||||
}
|
||||
|
||||
private void TryToStartAutohideCoroutine()
|
||||
{
|
||||
// FIX: Check if the GameObject is active before starting a coroutine.
|
||||
// This prevents the "Coroutine couldn't be started" error.
|
||||
if (!gameObject.activeInHierarchy)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_autoHide)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop any previously running hide coroutine to reset the timer
|
||||
if (m_hiddingCoroutine != null)
|
||||
{
|
||||
StopCoroutine(m_hiddingCoroutine);
|
||||
}
|
||||
|
||||
// This is line 139 from your original script
|
||||
m_hiddingCoroutine = StartCoroutine(COR_AutoHide());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user