2
// C++ Interface: EntityMoveAdjuster
7
// Author: Erik Hjortsberg <erik.hjortsberg@gmail.com>, (C) 2006
9
// This program is free software; you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation; either version 2 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program; if not, write to the Free Software
21
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.//
23
#ifndef EMBEROGREENTITYMOVEADJUSTER_H
24
#define EMBEROGREENTITYMOVEADJUSTER_H
26
#include <Eris/Timeout.h>
32
class EntityMoveAdjuster;
33
class EntityMoveManager;
36
@author Erik Hjortsberg <erik.hjortsberg@gmail.com>
37
@see EntityMoveAdjuster
38
An instance of a adjustment operation. After time out, the entity encapsuled by this instance will be synchronized with the server.
40
class EntityMoveAdjustmentInstance
49
EntityMoveAdjustmentInstance(EntityMoveAdjuster* moveAdjuster, EmberEntity* entity);
58
The timeout object which provides timeout functionality.
60
Eris::Timeout mTimeout;
63
* Called when the time has expired.
65
void timout_Expired();
68
A reference to the owner object.
70
EntityMoveAdjuster* mMoveAdjuster;
74
@author Erik Hjortsberg <erik.hjortsberg@gmail.com>
75
@brief This class is responsible for adjusting moved entities to their correct place.
76
Basically, when an entity is moved the client sends the updates to the server, but it's not clear at that time whether the movement is allowed. This can only be seen by waiting to see whether the movement went through, i.e. if the entity was updated.
77
So what this class does, together with EntityMoveAdjustmentInstance, waiting a couple of milleseconds and then telling the entity that was moved to synchronize with the server. If the movement didn't go through, this will lead to the entity "snapping" back to the original position. If it did go through nothing will happen.
79
class EntityMoveAdjuster
81
friend class EntityMoveAdjustmentInstance;
88
EntityMoveAdjuster(EntityMoveManager* manager);
90
typedef std::vector<EntityMoveAdjustmentInstance*> MoveAdjustmentInstanceStore;
93
Holds all instances of EntityMoveAdjustmentInstance.
95
MoveAdjustmentInstanceStore mInstances;
98
* Removes the supplied instance from the list of instances.
101
void removeInstance(EntityMoveAdjustmentInstance*);
104
* When movement has finished, i.e. something has been moved, create an EntityMoveAdjustmentInstance which will update the entity at expiration.
106
void EntityMoveManager_FinishedMoving();
109
* When movement has been cancelled, there's no need to create any EntityMoveAdjustmentInstance, but we want to clean up.
111
void EntityMoveManager_CancelledMoving();
114
* When movement starts, register the entity that is being moved.
117
void EntityMoveManager_StartMoving(EmberEntity* entity);
120
The entity that is being moved.
122
EmberEntity* mActiveEntity;
125
A reference to the manager.
127
EntityMoveManager* mManager;