root/trunk/src/game/PointMovementGenerator.cpp @ 240

Revision 102, 2.4 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include "PointMovementGenerator.h"
22#include "Errors.h"
23#include "Creature.h"
24#include "CreatureAI.h"
25#include "MapManager.h"
26#include "DestinationHolderImp.h"
27
28//----- Point Movement Generator
29template<class T>
30void PointMovementGenerator<T>::Initialize(T &unit)
31{
32    unit.StopMoving();
33    Traveller<T> traveller(unit);
34    i_destinationHolder.SetDestination(traveller,i_x,i_y,i_z);
35   
36    if (unit.GetTypeId() == TYPEID_UNIT && ((Creature*)&unit)->canFly())
37        unit.AddUnitMovementFlag(MOVEMENTFLAG_FLYING2);
38}
39
40template<class T>
41bool PointMovementGenerator<T>::Update(T &unit, const uint32 &diff)
42{
43    if(!&unit)
44        return false;
45
46    if(unit.hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED))
47        return true;
48
49    Traveller<T> traveller(unit);
50
51    i_destinationHolder.UpdateTraveller(traveller, diff, false);
52
53    if(i_destinationHolder.HasArrived())
54    {
55        unit.StopMoving();
56        MovementInform(unit);
57        return false;
58    }
59
60    return true;
61}
62
63template<class T>
64void PointMovementGenerator<T>::MovementInform(T &unit)
65{
66}
67
68template <> void PointMovementGenerator<Creature>::MovementInform(Creature &unit)
69{
70    unit.AI()->MovementInform(POINT_MOTION_TYPE, id);
71}
72
73template void PointMovementGenerator<Player>::Initialize(Player&);
74template bool PointMovementGenerator<Player>::Update(Player &, const uint32 &diff);
75template void PointMovementGenerator<Player>::MovementInform(Player&);
76
77template void PointMovementGenerator<Creature>::Initialize(Creature&);
78template bool PointMovementGenerator<Creature>::Update(Creature&, const uint32 &diff);
Note: See TracBrowser for help on using the browser.