移除ECM2

This commit is contained in:
2025-05-11 21:42:51 +08:00
parent aadd564c38
commit a7bf033ca9
726 changed files with 0 additions and 138648 deletions

View File

@@ -1,115 +0,0 @@
using UnityEngine;
namespace ECM2.Examples.Glide
{
/// <summary>
/// This example shows how to extend a Character (through composition) implementing a Glide mechanic.
/// </summary>
public class GlideAbility : MonoBehaviour
{
public bool canEverGlide = true;
public float maxFallSpeedGliding = 1.0f;
private Character _character;
protected bool _glideInputPressed;
protected bool _isGliding;
public bool glideInputPressed => _glideInputPressed;
/// <summary>
/// Is the Character gliding?
/// </summary>
public virtual bool IsGliding()
{
return _isGliding;
}
/// <summary>
/// Request to start a glide.
/// </summary>
public virtual void Glide()
{
_glideInputPressed = true;
}
/// <summary>
/// Request to stop gliding.
/// </summary>
public virtual void StopGliding()
{
_glideInputPressed = false;
}
/// <summary>
/// Determines if the character is able to perform a glide in its current state.
/// </summary>
protected virtual bool IsGlideAllowed()
{
return canEverGlide && _character.IsFalling();
}
/// <summary>
/// Determines if the character can perform a requested glide.
/// </summary>
protected virtual bool CanGlide()
{
bool isGlideAllowed = IsGlideAllowed();
if (isGlideAllowed)
{
Vector3 worldUp = -_character.GetGravityDirection();
float verticalSpeed = Vector3.Dot(_character.GetVelocity(), worldUp);
isGlideAllowed = verticalSpeed < 0.0f;
}
return isGlideAllowed;
}
/// <summary>
/// Start / Stop a requested glide.
/// </summary>
protected virtual void CheckGlideInput()
{
if (!_isGliding && _glideInputPressed && CanGlide())
{
_isGliding = true;
_character.maxFallSpeed = maxFallSpeedGliding;
}
else if (_isGliding && (!_glideInputPressed || !CanGlide()))
{
_isGliding = false;
_character.maxFallSpeed = 40.0f;
}
}
private void OnBeforeCharacterSimulationUpdated(float deltaTime)
{
CheckGlideInput();
}
private void Awake()
{
_character = GetComponent<Character>();
}
private void OnEnable()
{
_character.BeforeSimulationUpdated += OnBeforeCharacterSimulationUpdated;
}
private void OnDisable()
{
_character.BeforeSimulationUpdated -= OnBeforeCharacterSimulationUpdated;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: d97f3b8906b7417e88698c51eb7e04c8
timeCreated: 1700291875

View File

@@ -1,38 +0,0 @@
using UnityEngine.InputSystem;
namespace ECM2.Examples.Glide
{
/// <summary>
/// Extends default Character Input to handle GlideAbility Input.
/// </summary>
public class GlideInput : CharacterInput
{
private GlideAbility _glideAbility;
/// <summary>
/// Extend OnJump handler to add GlideAbility input support.
/// </summary>
public override void OnJump(InputAction.CallbackContext context)
{
// Call base method implementation (handle jump)
base.OnJump(context);
if (context.started)
_glideAbility.Glide();
else if (context.canceled)
_glideAbility.StopGliding();
}
protected override void Awake()
{
base.Awake();
// Cache Glide Ability
_glideAbility = GetComponent<GlideAbility>();
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 49ae0493228344b5b3bdfc1bf5545e57
timeCreated: 1700292768