1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
// Cyphesis Online RPG Server and AI Engine
// Copyright (C) 2000,2001 Alistair Riddoch
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// $Id: Movement.h,v 1.35 2008-01-13 01:32:55 alriddoch Exp $
#ifndef RULESETS_MOVEMENT_H
#define RULESETS_MOVEMENT_H
#include "physics/Vector3D.h"
#include "physics/Quaternion.h"
#include <Atlas/Objects/ObjectsFwd.h>
class Entity;
class Location;
/// \brief Base class for handling Character movement
///
/// This class should be replaced by a base class for handling all entity
/// movement.
class Movement {
protected:
/// The Entity this Movement is tracking.
Entity & m_body;
Point3D m_targetPos;
int m_serialno;
// float checkCollisions(const Location & loc);
public:
explicit Movement(Entity & body);
virtual ~Movement();
int serialno() const {
return m_serialno;
}
bool hasTarget() const {
return m_targetPos.isValid();
}
void setTarget(const Point3D & target) {
m_targetPos = target;
}
void reset();
bool updateNeeded(const Location & location) const;
/// \brief Determine the time before the next update is required.
///
/// Calculate how long before the Entity will reach its intended target.
/// If there is no target, or the target is some distance away, then
/// the default tick is returned.
/// @param coordinates the current position.
/// @param velocity the current velocity.
virtual double getTickAddition(const Point3D & coordinates,
const Vector3D & velocity) const = 0;
/// \brief Calculate the update position of the entity.
///
/// @param return_location the returned Location data.
virtual int getUpdatedLocation(Location & return_location) = 0;
/// \brief Generate a new Move operation to implement the movement.
///
/// Create a Move operation object, and set up the argument to describe
/// how the Entity is moving.
/// @param new_location Location data about the entity once movement has
/// changed.
virtual Atlas::Objects::Operation::RootOperation generateMove(const Location & new_location) = 0;
};
#endif // RULESETS_MOVEMENT_H
|