[8483] Implement glyph 43361.
[getmangos.git] / src / game / DestinationHolder.h
blob7c8b6ba2bf61f58cd494ba06cc717099aa326e2f
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
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"
23 #include "Timer.h"
25 class WorldObject;
26 class Map;
28 #define TRAVELLER_UPDATE_INTERVAL 300
30 template<typename TRAVELLER>
31 class MANGOS_DLL_DECL DestinationHolder
33 TimeTrackerSmall i_tracker;
34 uint32 i_totalTravelTime;
35 uint32 i_timeElapsed;
36 bool i_destSet;
37 float i_fromX, i_fromY, i_fromZ;
38 float i_destX, i_destY, i_destZ;
40 public:
41 DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL), i_totalTravelTime(0), i_timeElapsed(0),
42 i_destSet(false), i_fromX(0), i_fromY(0), i_fromZ(0), i_destX(0), i_destY(0), i_destZ(0) {}
44 uint32 SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove = true);
45 void GetDestination(float &x, float &y, float &z) const { x = i_destX; y = i_destY; z = i_destZ; }
46 bool UpdateExpired(void) const { return i_tracker.Passed(); }
47 void ResetUpdate(uint32 t = TRAVELLER_UPDATE_INTERVAL) { i_tracker.Reset(t); }
48 uint32 GetTotalTravelTime(void) const { return i_totalTravelTime; }
49 void IncreaseTravelTime(uint32 increment) { i_totalTravelTime += increment; }
50 bool HasDestination(void) const { return i_destSet; }
51 float GetDestinationDiff(float x, float y, float z) const;
52 bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
53 bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false);
54 uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
55 void GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D = false) const;
56 void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
57 float GetDistance3dFromDestSq(const WorldObject &obj) const;
59 private:
60 void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
63 #endif