1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 10:19:55 +00:00
openmw-tes3mp/apps/openmw/mwmechanics/actors.hpp

140 lines
5.2 KiB
C++
Raw Normal View History

#ifndef GAME_MWMECHANICS_ACTORS_H
#define GAME_MWMECHANICS_ACTORS_H
#include <set>
#include <vector>
#include <string>
2012-10-27 09:15:52 +00:00
#include <map>
2015-01-31 22:27:34 +00:00
#include <list>
#include "movement.hpp"
#include "../mwbase/world.hpp"
namespace MWWorld
{
class Ptr;
class CellStore;
}
namespace MWMechanics
{
class Actor;
class Actors
{
std::map<std::string, int> mDeathCount;
2014-05-15 20:03:48 +00:00
void updateNpc(const MWWorld::Ptr &ptr, float duration);
void adjustMagicEffects (const MWWorld::Ptr& creature);
void calculateDynamicStats (const MWWorld::Ptr& ptr);
2013-11-16 02:16:21 +00:00
void calculateCreatureStatModifiers (const MWWorld::Ptr& ptr, float duration);
void calculateNpcStatModifiers (const MWWorld::Ptr& ptr, float duration);
void calculateRestoration (const MWWorld::Ptr& ptr, float duration);
void updateDrowning (const MWWorld::Ptr& ptr, float duration);
void updateEquippedLight (const MWWorld::Ptr& ptr, float duration);
2014-04-03 04:50:09 +00:00
void updateCrimePersuit (const MWWorld::Ptr& ptr, float duration);
void killDeadActors ();
public:
Actors();
~Actors();
typedef std::map<MWWorld::Ptr,Actor*> PtrActorMap;
2014-01-07 18:49:16 +00:00
PtrActorMap::const_iterator begin() { return mActors.begin(); }
PtrActorMap::const_iterator end() { return mActors.end(); }
2014-01-07 18:49:16 +00:00
/// Update magic effects for an actor. Usually done automatically once per frame, but if we're currently
/// paused we may want to do it manually (after equipping permanent enchantment)
void updateMagicEffects (const MWWorld::Ptr& ptr);
void addActor (const MWWorld::Ptr& ptr, bool updateImmediately=false);
///< Register an actor for stats management
///
/// \note Dead actors are ignored.
void removeActor (const MWWorld::Ptr& ptr);
///< Deregister an actor for stats management
///
/// \note Ignored, if \a ptr is not a registered actor.
void updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr& ptr);
///< Updates an actor with a new Ptr
void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr& ignore);
///< Deregister all actors (except for \a ignore) in the given cell.
void update (float duration, bool paused);
///< Update actor stats and store desired velocity vectors in \a movement
void updateActor (const MWWorld::Ptr& ptr, float duration);
///< This function is normally called automatically during the update process, but it can
/// also be called explicitly at any time to force an update.
2014-05-15 20:03:48 +00:00
/** Start combat between two actors
@Notes: If againstPlayer = true then actor2 should be the Player.
If one of the combatants is creature it should be actor1.
*/
void engageCombat(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, bool againstPlayer);
void updateHeadTracking(const MWWorld::Ptr& actor, const MWWorld::Ptr& targetActor,
MWWorld::Ptr& headTrackTarget, float& sqrHeadTrackDistance);
2014-01-14 01:20:13 +00:00
void restoreDynamicStats(bool sleep);
///< If the player is sleeping, this should be called every hour.
2014-01-14 01:52:34 +00:00
void restoreDynamicStats(const MWWorld::Ptr& actor, bool sleep);
2014-01-14 01:52:34 +00:00
int getHoursToRest(const MWWorld::Ptr& ptr) const;
///< Calculate how many hours the given actor needs to rest in order to be fully healed
void fastForwardAi();
///< Simulate the passing of time
int countDeaths (const std::string& id) const;
///< Return the number of deaths for actors with the given ID.
void forceStateUpdate(const MWWorld::Ptr &ptr);
bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number);
void skipAnimation(const MWWorld::Ptr& ptr);
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName);
2014-01-07 18:49:16 +00:00
2015-06-01 19:41:13 +00:00
void getObjectsInRange(const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& out);
///Returns the list of actors which are following the given actor
/**ie AiFollow is active and the target is the actor **/
2014-01-12 13:02:15 +00:00
std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
/// Get the list of AiFollow::mFollowIndex for all actors following this target
std::list<int> getActorsFollowingIndices(const MWWorld::Ptr& actor);
///Returns the list of actors which are fighting the given actor
/**ie AiCombat is active and the target is the actor **/
std::list<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor);
2014-01-20 12:00:43 +00:00
void write (ESM::ESMWriter& writer, Loading::Listener& listener) const;
2015-01-22 18:04:59 +00:00
void readRecord (ESM::ESMReader& reader, uint32_t type);
void clear(); // Clear death counter
bool isReadyToBlock(const MWWorld::Ptr& ptr) const;
2014-01-07 18:49:16 +00:00
private:
PtrActorMap mActors;
2014-01-07 18:49:16 +00:00
};
}
#endif