mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-27 18:08:09 +08:00
Code refactoring
This commit is contained in:
1 parent
a18eae05ec
commit
c587ffe433
3 files changed
+17
-9
No files matched your search
@@ -24,5 +24,14 @@ namespace Engine.Core.Abstraction
|
||||
/// Destroys the native object associated with this managed object.
|
||||
/// </summary>
|
||||
public void Destroy();
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified managed object is equal to the current managed object.
|
||||
/// </summary>
|
||||
public bool Equals(IManagedObject other)
|
||||
{
|
||||
if (other == null) return false;
|
||||
else return NativeObject == other.NativeObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
namespace Engine.Navigation
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Pal3.Core.Contract.Enums;
|
||||
|
||||
using Vector3 = UnityEngine.Vector3;
|
||||
@@ -24,7 +25,7 @@ namespace Engine.Navigation
|
||||
|
||||
public bool IgnoreObstacle { get; private set; }
|
||||
|
||||
private Vector3[] _wayPoints = {};
|
||||
private readonly List<Vector3> _wayPoints = new ();
|
||||
|
||||
private int _currentWayPointIndex;
|
||||
|
||||
@@ -35,7 +36,7 @@ namespace Engine.Navigation
|
||||
{
|
||||
Clear();
|
||||
|
||||
_wayPoints = wayPoints;
|
||||
_wayPoints.AddRange(wayPoints);
|
||||
_currentWayPointIndex = 0;
|
||||
|
||||
MovementMode = movementMode;
|
||||
@@ -47,23 +48,23 @@ namespace Engine.Navigation
|
||||
{
|
||||
MovementMode = 0;
|
||||
EndOfPathAction = EndOfPathActionType.Idle;
|
||||
_wayPoints = new Vector3[] {};
|
||||
_wayPoints.Clear();
|
||||
_currentWayPointIndex = 0;
|
||||
}
|
||||
|
||||
public bool MoveToNextWayPoint()
|
||||
{
|
||||
return ++_currentWayPointIndex < _wayPoints.Length;
|
||||
return ++_currentWayPointIndex < _wayPoints.Count;
|
||||
}
|
||||
|
||||
public bool IsEndOfPath()
|
||||
{
|
||||
return !(_wayPoints.Length > 0 && _currentWayPointIndex < _wayPoints.Length);
|
||||
return !(_wayPoints.Count > 0 && _currentWayPointIndex < _wayPoints.Count);
|
||||
}
|
||||
|
||||
public Vector3[] GetAllWayPoints()
|
||||
{
|
||||
return _wayPoints;
|
||||
return _wayPoints.ToArray();
|
||||
}
|
||||
|
||||
public Vector3 GetCurrentWayPoint()
|
||||
|
||||
@@ -360,9 +360,7 @@ namespace Pal3.Game.Actor.Controllers
|
||||
|
||||
protected override void OnCollisionExitGameEntity(IGameEntity otherGameEntity)
|
||||
{
|
||||
// We have to compare the native object pointer instead of the game entity
|
||||
// to make sure we are removing the correct collider.
|
||||
_activeColliders.RemoveWhere(_ => _.ColliderGameEntity.NativeObject == otherGameEntity.NativeObject);
|
||||
_activeColliders.RemoveWhere(_ => _.ColliderGameEntity.Equals(otherGameEntity));
|
||||
|
||||
if (_actionController.GetRigidBody() is { isKinematic: false } actorRigidbody)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user