コード例 #1
0
ファイル: WaypointMovement.cs プロジェクト: lyosky/CypherCore
        void OnArrived(Creature owner)
        {
            if (_path == null || _path.nodes.Empty())
            {
                return;
            }

            Cypher.Assert(_currentNode < _path.nodes.Count, $"WaypointMovementGenerator.OnArrived: tried to reference a node id ({_currentNode}) which is not included in path ({_path.id})");
            WaypointNode waypoint = _path.nodes.ElementAt((int)_currentNode);

            if (waypoint.delay != 0)
            {
                owner.ClearUnitState(UnitState.RoamingMove);
                _nextMoveTime.Reset((int)waypoint.delay);
            }

            if (waypoint.eventId != 0 && RandomHelper.URand(0, 99) < waypoint.eventChance)
            {
                Log.outDebug(LogFilter.MapsScript, $"Creature movement start script {waypoint.eventId} at point {_currentNode} for {owner.GetGUID()}.");
                owner.ClearUnitState(UnitState.RoamingMove);
                owner.GetMap().ScriptsStart(ScriptsType.Waypoint, waypoint.eventId, owner, null);
            }

            // inform AI
            CreatureAI ai = owner.GetAI();

            if (ai != null)
            {
                ai.MovementInform(MovementGeneratorType.Waypoint, (uint)_currentNode);
                ai.WaypointReached(waypoint.id, _path.id);
            }

            owner.UpdateCurrentWaypointInfo(waypoint.id, _path.id);
        }
コード例 #2
0
ファイル: WaypointMovement.cs プロジェクト: lyosky/CypherCore
        void MovementInform(Creature owner)
        {
            CreatureAI ai = owner.GetAI();

            if (ai != null)
            {
                ai.MovementInform(MovementGeneratorType.Waypoint, (uint)_currentNode);
            }
        }
コード例 #3
0
        static void DoMovementInform(Unit owner, Unit target)
        {
            if (!owner.IsCreature())
            {
                return;
            }

            CreatureAI ai = owner.ToCreature().GetAI();

            if (ai != null)
            {
                ai.MovementInform(MovementGeneratorType.Chase, (uint)target.GetGUID().GetCounter());
            }
        }