Refactor NPC behavior and teleportation logic; enhance tile material properties

This commit is contained in:
2025-12-13 01:16:59 +01:00
parent 53de85a269
commit 189bbb7ae7
7 changed files with 66 additions and 22 deletions

View File

@@ -17,6 +17,12 @@ namespace Infrastructure.Unity
private Vector3 _currentDir;
private float _timer;
private Func<float> _timeDilationProvider;
public void Initialize(Func<float> timeDilationProvider)
{
_timeDilationProvider = timeDilationProvider;
}
private void Awake()
{
@@ -35,9 +41,11 @@ namespace Infrastructure.Unity
private void FixedUpdate()
{
if (IsGrounded()) rb.MovePosition(rb.position + _currentDir * (moveSpeed * Time.fixedDeltaTime));
var dilation = _timeDilationProvider?.Invoke() ?? 1f;
if (Physics.Raycast(transform.position, Vector3.down, out var hit, 1.5f, tileLayer))
if (IsGrounded()) rb.MovePosition(rb.position + _currentDir * (moveSpeed * dilation * Time.fixedDeltaTime));
if (Physics.Raycast(transform.position, Vector3.down, out var hit, 2.0f, tileLayer))
{
if (hit.collider.TryGetComponent<TileViewAdapter>(out var tile))
{
@@ -48,7 +56,7 @@ namespace Infrastructure.Unity
private bool IsGrounded()
{
return Physics.Raycast(transform.position, Vector3.down, out var hit, 1.15f, tileLayer);
return Physics.Raycast(transform.position, Vector3.down, out var hit, 2.0f, tileLayer);
}
private void PickNewDirection()