1
This commit is contained in:
@@ -7,6 +7,7 @@ using System.Timers;
|
||||
using BITFALL.Entities.Player.Movement.States;
|
||||
using BITFALL.Player.Equip;
|
||||
using BITFALL.Player.Movement;
|
||||
using BITFALL.Props;
|
||||
using BITFALL.Scene;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
@@ -29,7 +30,10 @@ namespace BITFALL.Entities.Player.Movement
|
||||
{
|
||||
[CustomType(typeof(IEntityMovement))]
|
||||
[CustomType(typeof(IPlayerMovement))]
|
||||
public class PlayerCharacterController : StateBasedPlayerBehavior<IEntityMovementState>,IEntityMovement,IPlayerMovement,IEntityBinaryComponent
|
||||
public class PlayerCharacterController : StateBasedPlayerBehavior<IEntityMovementState>
|
||||
,IEntityMovement
|
||||
,IPlayerMovement
|
||||
,IEntityBinaryComponent
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] internal Vector3 initialCameraPosition = new(0,0.11f,0.27f);
|
||||
@@ -77,7 +81,12 @@ namespace BITFALL.Entities.Player.Movement
|
||||
set => actor.Rotation = value;
|
||||
}
|
||||
|
||||
public float ReferenceSpeed { get; internal set; }
|
||||
public float ReferenceSpeed
|
||||
{
|
||||
get =>limitSpeed.Allow ? Mathf.Min(limitSpeed.Value,referenceSpeed):referenceSpeed;
|
||||
set=>referenceSpeed = value;
|
||||
}
|
||||
private float referenceSpeed = 2.5f;
|
||||
public Vector3 Forward => actor.Forward;
|
||||
public Vector3 ViewForward { get; set; }
|
||||
public Vector3 ViewCenter { get; private set; }
|
||||
@@ -109,8 +118,12 @@ namespace BITFALL.Entities.Player.Movement
|
||||
internal IOptional<float> limitSpeed =>new ReadOnlyOptional<float>(limitSpeedDictionary.Count is not 0,
|
||||
limitSpeedDictionary.Count is 0 ? 0 :
|
||||
limitSpeedDictionary.Values.Min());
|
||||
internal IOptional<float> limitSensitive => new ReadOnlyOptional<float>(limitSensitiveSpeedDictionary.Count is not 0,
|
||||
limitSensitiveSpeedDictionary.Count is 0 ? 0 :
|
||||
limitSensitiveSpeedDictionary.Values.Min() * 0.5f);
|
||||
|
||||
private readonly Dictionary<int,float> limitSpeedDictionary = new();
|
||||
private readonly Dictionary<int,float> limitSensitiveSpeedDictionary = new();
|
||||
|
||||
private bool isDead;
|
||||
internal bool topBlocked;
|
||||
@@ -286,6 +299,16 @@ namespace BITFALL.Entities.Player.Movement
|
||||
limitSpeedDictionary.TryRemove(limitMoveSpeedCommand.Id);
|
||||
}
|
||||
break;
|
||||
case PlayerLimitSensitivityCommand limitSensitivityCommand:
|
||||
if (limitSensitivityCommand.Limit)
|
||||
{
|
||||
limitSensitiveSpeedDictionary.Set(limitSensitivityCommand.Id,limitSensitivityCommand.Sensitivity);
|
||||
}
|
||||
else
|
||||
{
|
||||
limitSensitiveSpeedDictionary.TryRemove(limitSensitivityCommand.Id);
|
||||
}
|
||||
break;
|
||||
case PlayerDisableMovementCommand disableMovementCommand:
|
||||
allowMovement.SetDisableElements(disableMovementCommand.LockFile,disableMovementCommand.Disable);
|
||||
if (string.IsNullOrEmpty(disableMovementCommand.Source) is false && disableMovementCommand.Disable)
|
||||
@@ -312,7 +335,9 @@ namespace BITFALL.Entities.Player.Movement
|
||||
var playerConfig = PlayerConfig.Singleton;
|
||||
var ads = adsProvider.Get<float>();
|
||||
if (ads is 0) ads = 1;
|
||||
var raw = context.ReadValue<Vector2>() * playerConfig.Sensitivity * playerConfig.M_Yaw * ads;
|
||||
var raw = context.ReadValue<Vector2>() *
|
||||
(limitSensitive.Allow ? Mathf.Min( playerConfig.Sensitivity,limitSensitive.Value): playerConfig.Sensitivity)
|
||||
* playerConfig.M_Yaw * ads;
|
||||
LookInputDelta +=raw;
|
||||
var lookInput = LookInput;
|
||||
lookInput.x -= raw.y;
|
||||
@@ -527,6 +552,7 @@ namespace BITFALL.Entities.Player.Movement
|
||||
UpdateState(deltaTime);
|
||||
|
||||
CurrentState?.AfterUpdateMovement(deltaTime);
|
||||
|
||||
}
|
||||
|
||||
public override void OnFixedUpdate(float deltaTime)
|
||||
@@ -564,7 +590,7 @@ namespace BITFALL.Entities.Player.Movement
|
||||
actor.Velocity = default;
|
||||
}
|
||||
|
||||
var localVelocity = transform.InverseTransformDirection(Velocity) / initialSpeed;
|
||||
var localVelocity = transform.InverseTransformDirection(Velocity) / referenceSpeed;
|
||||
localVelocity.y = 0;
|
||||
LocomotionBasedVelocity = localVelocity;
|
||||
|
||||
@@ -760,12 +786,21 @@ namespace BITFALL.Entities.Player.Movement
|
||||
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
if (CurrentState is not (IPlayerRunState or IPlayerSprintState or IPlayerClimbState or IPlayerVaultState or IPlayerLinkState)) return;
|
||||
if (CurrentState is not (
|
||||
IPlayerRunState
|
||||
or IPlayerSprintState
|
||||
or IPlayerClimbState
|
||||
or IPlayerVaultState
|
||||
or IPlayerLinkState
|
||||
or IPlayerSlideState
|
||||
)) return;
|
||||
if (other.collider.TryGetComponent<IScenePlayerImpact>(out var impact))
|
||||
{
|
||||
impact.OnPlayerImpact(Entity, transform.localToWorldMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user