refactor interact system

interact only after PopupItemMenu button clicked
This commit is contained in:
Vova
2023-11-16 16:11:39 +02:00
parent c2bb35a46d
commit 1774ab5b18
12 changed files with 100 additions and 61 deletions
+24 -21
View File
@@ -24,7 +24,7 @@ public class Player : MonoBehaviour
public Dictionary<StatsId, Stat> Stats;
public JobPositions JobPosition { get; set; }
public EducationSkill Education { get; set; }
public EducationSkill Education { get; set; }
private readonly Queue<PlayerTasks> _tasks = new Queue<PlayerTasks>();
private PlayerTasks _currentTask;
@@ -56,10 +56,10 @@ public class Player : MonoBehaviour
TimeManager.Instance.OnMinuteChanged += UpdateStatsByClock;
_animator.applyRootMotion = true;
_navAgent.updatePosition = false;
_currentActing = PlayerStates.Awake;
}
private void OnDestroy()
@@ -105,18 +105,21 @@ public class Player : MonoBehaviour
_currentTask.UpdateStatus(MoveToPoint());
break;
case Tasks.Interact:
// Show interaction menu
_currentTask.TagretObject.SpawnMenu();
_currentTask = null;
//if (IsPathComplete(_currentTask.TagretObject._interactionPoint.position))
// _currentTask.UpdateStatus(InteractWithObject(_currentTask.TagretObject));
//else
//{
// AddTask(new PlayerTasks(Tasks.Move, _currentTask.TagretObject));
// AddTask(new PlayerTasks(Tasks.Rotate, _currentTask.TagretObject));
// AddTask(_currentTask);
// _currentTask = null;
//}
var result = _currentTask.TagretObject.Interact(this);
switch (result)
{
case InteractionStatus.FarFromPlayer:
AddTask(new PlayerTasks(Tasks.Move, _currentTask.TagretObject));
AddTask(new PlayerTasks(Tasks.Rotate, _currentTask.TagretObject));
AddTask(_currentTask);
_currentTask = null;
break;
case InteractionStatus.Complete:
_currentTask.UpdateStatus(TaskStatus.Complete);
break;
default:
break;
}
break;
}
}
@@ -137,7 +140,7 @@ public class Player : MonoBehaviour
return IsPathComplete(_navAgent.destination) ? TaskStatus.Complete : TaskStatus.InProgress;
}
private bool IsPathComplete(Vector3 destination)
public bool IsPathComplete(Vector3 destination)
{
var dest = new Vector3(destination.x, 0, destination.z);
var pos = new Vector3(_navAgent.transform.position.x, 0, _navAgent.transform.position.z);
@@ -174,11 +177,11 @@ public class Player : MonoBehaviour
return Mathf.Abs(Quaternion.Dot(q1, q2)) >= 1 - precision;
}
private TaskStatus InteractWithObject(BaseInteractableObject interactableObject)
{
interactableObject.Interact(this);
return TaskStatus.Complete;
}
//private TaskStatus InteractWithObject(BaseInteractableObject interactableObject)
//{
// interactableObject.Interact(this);
// return TaskStatus.Complete;
//}
public void SetPlayerAnimation(AnimationStates newState, Action onAnimationFinish)
{