Improvements and touchups to a more event-driven flow and fake physics
This commit is contained in:
@@ -34,28 +34,37 @@ namespace Minigames.DivingForPictures
|
||||
private static MonoBehaviour _coroutineRunner;
|
||||
private static Collider2D _sharedPlayerCollider;
|
||||
|
||||
// Events for damage state changes
|
||||
public static event Action OnDamageStart;
|
||||
public static event Action OnDamageEnd;
|
||||
// Events for immunity and damage state changes
|
||||
public static event Action OnImmunityStarted;
|
||||
public static event Action OnImmunityEnded;
|
||||
public static event Action OnDamageTaken;
|
||||
|
||||
// Instance tracking for shared state management
|
||||
private static readonly System.Collections.Generic.HashSet<PlayerCollisionBehavior> _allInstances =
|
||||
new System.Collections.Generic.HashSet<PlayerCollisionBehavior>();
|
||||
|
||||
/// <summary>
|
||||
/// Public static method to trigger damage start event from external classes
|
||||
/// Public static method to trigger immunity start event from external classes
|
||||
/// </summary>
|
||||
public static void TriggerDamageStart()
|
||||
public static void TriggerImmunityStarted()
|
||||
{
|
||||
OnDamageStart?.Invoke();
|
||||
OnImmunityStarted?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public static method to trigger damage end event from external classes
|
||||
/// Public static method to trigger immunity end event from external classes
|
||||
/// </summary>
|
||||
public static void TriggerDamageEnd()
|
||||
public static void TriggerImmunityEnded()
|
||||
{
|
||||
OnDamageEnd?.Invoke();
|
||||
OnImmunityEnded?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Public static method to trigger damage taken event from external classes
|
||||
/// </summary>
|
||||
public static void TriggerDamageTaken()
|
||||
{
|
||||
OnDamageTaken?.Invoke();
|
||||
}
|
||||
|
||||
protected bool wasInputBlocked;
|
||||
@@ -148,6 +157,9 @@ namespace Minigames.DivingForPictures
|
||||
{
|
||||
if (_isGloballyImmune) return;
|
||||
|
||||
// Trigger damage taken event first
|
||||
OnDamageTaken?.Invoke();
|
||||
|
||||
// Start shared immunity period
|
||||
StartGlobalImmunity();
|
||||
|
||||
@@ -191,8 +203,8 @@ namespace Minigames.DivingForPictures
|
||||
}
|
||||
}
|
||||
|
||||
// Broadcast damage start event
|
||||
OnDamageStart?.Invoke();
|
||||
// Broadcast immunity start event
|
||||
OnImmunityStarted?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -225,8 +237,8 @@ namespace Minigames.DivingForPictures
|
||||
}
|
||||
}
|
||||
|
||||
// Broadcast damage end event
|
||||
OnDamageEnd?.Invoke();
|
||||
// Broadcast immunity end event
|
||||
OnImmunityEnded?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -352,7 +364,7 @@ namespace Minigames.DivingForPictures
|
||||
}
|
||||
}
|
||||
|
||||
OnDamageEnd?.Invoke();
|
||||
OnImmunityEnded?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user