public override void _Ready()
    {
        _collision_layer = 2;
        ((Area)FindNode("MeleAttackArea")).SetCollisionMaskBit(1, true);        // monitor only player

        var state_spawn     = new OneShotAnim("spawn");
        var state_chase     = new EnemyChase();
        var state_idle      = new EnemyIdle();
        var state_telegraph = new EnemyTelegraph();
        var state_attack    = new EnemyAttack();

        var tr_spawn_finished      = new FromOneShotAnim(state_idle, "spawn");
        var tr_to_chase            = new EnemyToChase(state_chase);
        var tr_to_idle             = new EnemyToIdle(state_idle);
        var tr_start_telegraph     = new EnemyStartTelegraph(state_telegraph);
        var tr_telegraph_finished  = new FromOneShotAnim(state_attack, "telegraph");
        var tr_telegraph_interrupt = new EnemyInterruptTelegraph(state_idle);
        var tr_attack_finished     = new FromOneShotAnim(state_idle, "attack");

        state_spawn.AddTransition(tr_spawn_finished);
        state_chase.AddTransition(tr_to_idle);
        state_chase.AddTransition(tr_start_telegraph);
        state_idle.AddTransition(tr_to_chase);
        state_idle.AddTransition(tr_start_telegraph);
        state_telegraph.AddTransition(tr_telegraph_finished);
        state_telegraph.AddTransition(tr_telegraph_interrupt);
        state_attack.AddTransition(tr_attack_finished);

        _fsm = new FSM(this, state_spawn);
        _fsm.AddTransition(new EnemyDie(new EnemyDead()));

        // temp
        Attributes.RunSpeed   = 10;
        Attributes.MaxHealth  = Attributes.Health = 20;
        Attributes.Damage     = 10;
        Attributes.CritChance = 0.1f;
    }
    private void Start()
    {
        _target = PlayerCharacter.Active.transform;

        EnemyWait   enemyWait   = new EnemyWait(this, _waitTimeOnTargetLost);
        EnemyChase  enemyChase  = new EnemyChase(this, _target);
        EnemyPatrol enemyPatrol = new EnemyPatrol(this, _includeObstaclesOnPatrol, enemyWait);

        // Переходы из состояния патрулирования.
        enemyPatrol.AddTransition(EnemyStateKey.PlayerInSight, enemyChase);

        // Переходы из состояния преследования цели.
        enemyChase.AddTransition(EnemyStateKey.PlayerOffSight, enemyWait);

        // Переходы из состояния ожидания.
        enemyWait.AddTransition(EnemyStateKey.PlayerInSight, enemyChase);
        enemyWait.AddTransition(EnemyStateKey.WaitComplete, enemyPatrol);

        _stateMachine = new StateMachine <EnemyStateKey>(enemyWait);
    }