root/trunk/src/game/DestinationHolder.h @ 34

Revision 2, 2.8 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef MANGOS_DESTINATION_HOLDER_H
20#define MANGOS_DESTINATION_HOLDER_H
21
22#include "Platform/Define.h"
23#include "Timer.h"
24
25class WorldObject;
26
27#define TRAVELLER_UPDATE_INTERVAL  300
28
29template<typename TRAVELLER>
30class MANGOS_DLL_DECL DestinationHolder
31{
32    TimeTrackerSmall i_tracker;
33    uint32 i_totalTravelTime;
34    uint32 i_timeElapsed;
35    bool i_destSet;
36    float i_fromX, i_fromY, i_fromZ;
37    float i_destX, i_destY, i_destZ;
38
39    public:
40        DestinationHolder() : i_tracker(TRAVELLER_UPDATE_INTERVAL), i_totalTravelTime(0), i_timeElapsed(0),
41            i_destSet(false), i_fromX(0), i_fromY(0), i_fromZ(0), i_destX(0), i_destY(0), i_destZ(0) {}
42
43        uint32 SetDestination(TRAVELLER &traveller, float dest_x, float dest_y, float dest_z, bool sendMove = true);
44        void GetDestination(float &x, float &y, float &z) const { x = i_destX; y = i_destY; z = i_destZ; }
45        bool UpdateExpired(void) const { return i_tracker.Passed(); }
46        void ResetUpdate(uint32 t = TRAVELLER_UPDATE_INTERVAL) { i_tracker.Reset(t); }
47        uint32 GetTotalTravelTime(void) const { return i_totalTravelTime; }
48        void IncreaseTravelTime(uint32 increment) { i_totalTravelTime += increment; }
49        bool HasDestination(void) const { return i_destSet; }
50        float GetDestinationDiff(float x, float y, float z) const;
51        bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
52        bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false);
53        uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
54        void GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D = false) const;
55        void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
56        float GetDistance2dFromDestSq(const WorldObject &obj) const;
57
58    private:
59        void _findOffSetPoint(float x1, float y1, float x2, float y2, float offset, float &x, float &y);
60
61};
62#endif
Note: See TracBrowser for help on using the browser.