2009-05-08 15:26:19 +01:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2009 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef RULESETS_DOMAIN_H
|
|
|
|
|
#define RULESETS_DOMAIN_H
|
|
|
|
|
|
2009-05-12 23:26:42 +01:00
|
|
|
#include "physics/Vector3D.h"
|
2014-09-14 00:30:26 +02:00
|
|
|
#include "common/OperationRouter.h"
|
2009-05-12 23:26:42 +01:00
|
|
|
|
2014-09-18 11:06:05 +02:00
|
|
|
#include <wfmath/vector.h>
|
|
|
|
|
|
2009-05-12 23:26:42 +01:00
|
|
|
#include <string>
|
2016-08-15 21:43:08 +02:00
|
|
|
#include <list>
|
2018-03-09 14:37:11 +01:00
|
|
|
#include <set>
|
2009-05-12 23:26:42 +01:00
|
|
|
|
|
|
|
|
class LocatedEntity;
|
2017-01-31 22:12:50 +01:00
|
|
|
|
2014-09-15 18:50:54 +02:00
|
|
|
class Location;
|
2009-05-12 23:26:42 +01:00
|
|
|
|
2009-05-08 15:26:19 +01:00
|
|
|
/// \brief Base class for movement domains
|
|
|
|
|
///
|
|
|
|
|
/// The movement domain implements movement in the game world, including
|
|
|
|
|
/// visibility calculations, collision detection and physics.
|
|
|
|
|
/// Motion objects interact with the movement domain.
|
2017-01-31 22:12:50 +01:00
|
|
|
class Domain
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief The entity to which this domain belongs.
|
|
|
|
|
*/
|
|
|
|
|
LocatedEntity& m_entity;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2018-02-11 23:22:20 +01:00
|
|
|
explicit Domain(LocatedEntity& entity);
|
2017-01-31 22:12:50 +01:00
|
|
|
|
|
|
|
|
virtual ~Domain();
|
|
|
|
|
|
|
|
|
|
virtual void tick(double t, OpVector& res) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Checks if the observing Entity can see the observed entity.
|
|
|
|
|
*
|
|
|
|
|
* This is done by using both a distance check as well as an outfit and wielded check.
|
|
|
|
|
*
|
|
|
|
|
* @param observingEntity The observer entity.
|
|
|
|
|
* @param observedEntity The entity being looked at.
|
|
|
|
|
* @return True if the observer entity can see the observed entity.
|
|
|
|
|
*/
|
|
|
|
|
virtual bool isEntityVisibleFor(const LocatedEntity& observingEntity, const LocatedEntity& observedEntity) const = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds a child entity to this domain. The child entity is guaranteed to be a direct child of the entity to which the domain belongs.
|
|
|
|
|
*
|
|
|
|
|
* @param entity A child entity.
|
|
|
|
|
*/
|
|
|
|
|
virtual void addEntity(LocatedEntity& entity) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes a child entity from this domain. The child entity is guaranteed to be a direct child of the entity to which the domain belongs, and to have addEntity(...) being called earlier.
|
|
|
|
|
*
|
|
|
|
|
* @param entity A child entity.
|
|
|
|
|
*/
|
|
|
|
|
virtual void removeEntity(LocatedEntity& entity) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills the supplied list with all entities in the domain that the supplied entity can currently observe.
|
|
|
|
|
* @param observingEntity The entity that is observing.
|
|
|
|
|
* @param entityList A list of entities.
|
|
|
|
|
*/
|
|
|
|
|
virtual void getVisibleEntitiesFor(const LocatedEntity& observingEntity, std::list<LocatedEntity*>& entityList) const = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fills the supplied list with all entities in the domain that are currently observing the supplied entity.
|
|
|
|
|
* @param observedEntity The entity which is being observed.
|
2017-06-12 18:01:52 +02:00
|
|
|
* @return A list of entities.
|
2017-01-31 22:12:50 +01:00
|
|
|
*/
|
2017-06-12 18:01:52 +02:00
|
|
|
virtual std::list<LocatedEntity*> getObservingEntitiesFor(const LocatedEntity& observedEntity) const
|
2017-01-31 22:12:50 +01:00
|
|
|
{
|
2017-06-12 18:01:52 +02:00
|
|
|
return std::list<LocatedEntity*>();
|
2017-01-31 22:12:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Applies transformations to a child entity in the domain.
|
|
|
|
|
*
|
|
|
|
|
* Note that different domains handle this differently. Some will ignore some or all of the transformations.
|
|
|
|
|
*
|
|
|
|
|
* @param entity The child entity.
|
|
|
|
|
* @param orientation New orientation, applied if valid.
|
|
|
|
|
* @param pos New position, applied if valid.
|
2018-03-09 14:37:11 +01:00
|
|
|
* @param velocity New velocity, applied if valid. This is pseudo-normalized,
|
|
|
|
|
* in the sense that a normalized value means "max speed". The final velocity is calculated by the domain.
|
|
|
|
|
* @param transformedEntities A list of entities that were transformed by this action. In most cases only the moved entity,
|
|
|
|
|
* but there are cases where other are affected too.
|
2017-01-31 22:12:50 +01:00
|
|
|
*/
|
2018-03-09 14:37:11 +01:00
|
|
|
virtual void applyTransform(LocatedEntity& entity, const WFMath::Quaternion& orientation,
|
|
|
|
|
const WFMath::Point<3>& pos, const WFMath::Vector<3>& velocity,
|
|
|
|
|
std::set<LocatedEntity*>& transformedEntities)
|
2017-01-31 22:12:50 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Refreshes the terrain within the supplied areas.
|
|
|
|
|
* @param areas A collection of areas describing the terrain changed.
|
|
|
|
|
*/
|
|
|
|
|
virtual void refreshTerrain(const std::vector<WFMath::AxisBox<2>>& areas)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates perceptive state of a child entity.
|
|
|
|
|
*
|
|
|
|
|
* This is called mainly when an entity becomes perceptive.
|
|
|
|
|
* @param entity A child entity of the entity the domain belongs to.
|
|
|
|
|
*/
|
|
|
|
|
virtual void toggleChildPerception(LocatedEntity& entity)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2016-09-05 21:56:36 +02:00
|
|
|
|
|
|
|
|
|
2009-05-08 15:26:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // RULESETS_DOMAIN_H
|