コード例 #1
0
    private void SetAttackTargetFromRPC(GameObject target, bool shouldIssueCommand)
    {
        if (_attackTarget != null)
        {
            CombatController combat = _attackTarget.GetComponent <CombatController>();
            if (combat != null)
            {
                combat.OnStopAttack(gameObject);
            }
        }

        _attackTarget = target;
        if (_attackTarget != null)
        {
            CombatController combat = _attackTarget.GetComponent <CombatController>();
            if (combat != null)
            {
                combat.OnStartAttack(gameObject);
            }

            if (shouldIssueCommand)
            {
                _characterComponent.IssueAttackCommand(target);
            }
        }

        if (OnAttackTargetChanged != null)
        {
            OnAttackTargetChanged(_attackTarget);
        }
    }