2 * Copyright (C) 2005,2006 MaNGOS <http://www.mangosproject.org/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_DESTINATION_HOLDER_H
20 #define MANGOS_DESTINATION_HOLDER_H
22 #include "Platform/Define.h"
27 #define TRAVELLER_UPDATE_INTERVAL 300
29 template<typename TRAVELLER
>
30 class MANGOS_DLL_DECL DestinationHolder
32 TimeTracker i_tracker
;
33 uint32 i_totalTravelTime
;
35 float i_fromX
, i_fromY
, i_fromZ
;
36 float i_destX
, i_destY
, i_destZ
;
39 DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL
), i_totalTravelTime(0), i_timeStarted(0) {}
41 uint32
SetDestination(TRAVELLER
&traveller
, float dest_x
, float dest_y
, float dest_z
, float offset
= 0);
42 inline bool UpdateExpired(void) const { return i_tracker
.Passed(); }
43 inline void ResetUpdate(uint32 t
= TRAVELLER_UPDATE_INTERVAL
) { i_tracker
.Reset(TRAVELLER_UPDATE_INTERVAL
); }
44 inline uint32
GetTotalTravelTime(void) const { return i_totalTravelTime
; }
45 inline uint32
GetStartTravelTime(void) const { return i_timeStarted
; }
46 inline bool HasArrived(void) const { return (i_totalTravelTime
== 0 || (getMSTime() - i_timeStarted
) >= i_totalTravelTime
); }
47 bool UpdateTraveller(TRAVELLER
&traveller
, uint32 diff
, bool force_update
);
48 void UpdateLocation(TRAVELLER
&traveller
, float, float, float);
49 void GetLocationNow(float &x
, float &y
, float &z
) const;
50 float GetDistanceFromDestSq(const Object
&obj
) const;
53 void _findOffSetPoint(float x1
, float y1
, float x2
, float y2
, float offset
, float &x
, float &y
);