TrinityCore
SplineChainMovementGenerator.h
Go to the documentation of this file.
1/*
2* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3*
4* This program is free software; you can redistribute it and/or modify it
5* under the terms of the GNU General Public License as published by the
6* Free Software Foundation; either version 2 of the License, or (at your
7* option) any later version.
8*
9* This program is distributed in the hope that it will be useful, but WITHOUT
10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12* more details.
13*
14* You should have received a copy of the GNU General Public License along
15* with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef TRINITY_SPLINECHAINMOVEMENTGENERATOR_H
19#define TRINITY_SPLINECHAINMOVEMENTGENERATOR_H
20
21#include "SplineChain.h"
22#include "MovementGenerator.h"
23#include "Optional.h"
24#include <vector>
25
26class Unit;
27
29{
30 public:
31 explicit SplineChainMovementGenerator(uint32 id, std::vector<SplineChainLink> const& chain, bool walk = false);
33
34 void Initialize(Unit*) override;
35 void Reset(Unit*) override;
36 bool Update(Unit*, uint32) override;
37 void Deactivate(Unit*) override;
38 void Finalize(Unit*, bool, bool) override;
40
41 // Builds info that can later be used to resume this spline chain movement at the current position
42 static void GetResumeInfo(SplineChainResumeInfo& info, Unit const* owner, Optional<uint32> id = {});
43 // Leaving the object method public for people that know what they're doing to use
44 // But really, 99% of the time you should be using the static one instead
45 SplineChainResumeInfo GetResumeInfo(Unit const* owner) const;
46 uint32 GetId() const { return _id; }
47
48 private:
49 void SendSplineFor(Unit* owner, uint32 index, uint32& duration);
50 uint32 SendPathSpline(Unit* owner, float velocity, Movement::PointsArray const& path) const;
51
52 uint32 const _id;
53 std::vector<SplineChainLink> const& _chain;
55 bool const _walk;
57 uint8 _nextFirstWP; // only used for resuming
59};
60
61#endif
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
uint32_t uint32
Definition: Define.h:142
MovementGeneratorType
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
virtual void Initialize(Unit *owner)=0
virtual bool Update(Unit *owner, uint32 diff)=0
virtual void Deactivate(Unit *owner)=0
virtual void Finalize(Unit *owner, bool active, bool movementInform)=0
virtual void Reset(Unit *owner)=0
virtual MovementGeneratorType GetMovementGeneratorType() const =0
std::vector< SplineChainLink > const & _chain
Definition: Unit.h:627
std::vector< Vector3 > PointsArray