private void SetAnimationState(LumberjackFSMState.StateEnum currentState)
        {
            StopCurrentAnimation();
            switch (currentState)
            {
            case LumberjackFSMState.StateEnum.STOCKPILING:
                anim.SetBool("Dropping", true);
                break;

            case LumberjackFSMState.StateEnum.HARVESTING:
                anim.SetBool("Chopping", true);
                Axe.SetActive(true);
                HandSocket.GetComponent <FixedJoint>().connectedBody = Axe.GetComponent <Rigidbody>();
                break;

            case LumberjackFSMState.StateEnum.MOVING_TO_TARGET:
                var isCarryingLog = cachedResourcesCount > 0;

                anim.SetBool("Carrying", isCarryingLog);
                anim.SetBool("Walking", !isCarryingLog);
                Log.SetActive(isCarryingLog);

                HandSocket.GetComponent <FixedJoint>().connectedBody = Log.GetComponent <Rigidbody>();
                break;
            }
        }
        private void OnChangeState(LumberjackFSMState.StateEnum newState, EntityId targetEntityId)
        {
            StopAllCoroutines();

            switch (newState)
            {
            case LumberjackFSMState.StateEnum.IDLE:
                navigation.StopNavigation();
                DecideWhereToMove();
                break;

            case LumberjackFSMState.StateEnum.MOVING_TO_TREE:
                break;

            case LumberjackFSMState.StateEnum.HARVESTING:
                StartCoroutine(BufferHarvestingAnimation(SimulationSettings.NPCChoppingAnimationBuffer, targetEntityId));
                break;

            case LumberjackFSMState.StateEnum.MOVING_TO_STOCKPILE:
                break;

            case LumberjackFSMState.StateEnum.STOCKPILING:
                StartCoroutine(BufferDroppingAnimation(SimulationSettings.NPCStockpilingAnimationBuffer, targetEntityId));
                break;

            case LumberjackFSMState.StateEnum.ON_FIRE:
                navigation.StopNavigation();
                StartMovingTowardsPosition(transform.position + (Random.insideUnitSphere * SimulationSettings.OnFireWaypointDistance).FlattenVector());
                break;
            }
        }
 private void ChangeStateTo(LumberjackFSMState.StateEnum newState, EntityId targetEntityId)
 {
     if (lumberjack != null)
     {
         lumberjack.Send(new NPCLumberjack.Update().SetCurrentState(newState).SetTargetEntity(targetEntityId));
     }
 }
 private void OnNpcLumberjackComponentUpdate(NPCLumberjack.Update newState)
 {
     if (newState.currentState.HasValue)
     {
         if (cachedFsmState != newState.currentState.Value)
         {
             cachedFsmState = newState.currentState.Value;
             SetAnimationState(cachedFsmState);
         }
     }
 }
 private void ResetAllLocalState()
 {
     anim.SetBool("Dropping", false);
     anim.SetBool("Chopping", false);
     anim.SetBool("Carrying", false);
     anim.SetBool("Walking", false);
     anim.SetBool("OnFire", false);
     Axe.SetActive(false);
     Log.SetActive(false);
     cachedResourcesCount = 0;
     cachedFsmState       = LumberjackFSMState.StateEnum.IDLE;
 }
 public void ChangeStateTo(LumberjackFSMState.StateEnum newState)
 {
     ChangeStateTo(newState, EntityId.InvalidEntityId);
 }
        private IEnumerator ChangeStateAfter(float delayTime, LumberjackFSMState.StateEnum newState)
        {
            yield return(new WaitForSeconds(delayTime));

            ChangeStateTo(newState);
        }