mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 12:35:46 +00:00
Merge branch 'refactor_actors' into 'master'
Refactor MWMechanics::Actors See merge request OpenMW/openmw!2094
This commit is contained in:
commit
98f839982e
@ -37,6 +37,7 @@ namespace MWMechanics
|
|||||||
void updatePtr(const MWWorld::Ptr& newPtr) { mCharacterController.updatePtr(newPtr); }
|
void updatePtr(const MWWorld::Ptr& newPtr) { mCharacterController.updatePtr(newPtr); }
|
||||||
|
|
||||||
CharacterController& getCharacterController() { return mCharacterController; }
|
CharacterController& getCharacterController() { return mCharacterController; }
|
||||||
|
const CharacterController& getCharacterController() const { return mCharacterController; }
|
||||||
|
|
||||||
int getGreetingTimer() const { return mGreetingTimer; }
|
int getGreetingTimer() const { return mGreetingTimer; }
|
||||||
void setGreetingTimer(int timer) { mGreetingTimer = timer; }
|
void setGreetingTimer(int timer) { mGreetingTimer = timer; }
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -51,11 +51,11 @@ namespace MWMechanics
|
|||||||
|
|
||||||
/// Check if the target actor was detected by an observer
|
/// Check if the target actor was detected by an observer
|
||||||
/// If the observer is a non-NPC, check all actors in AI processing distance as observers
|
/// If the observer is a non-NPC, check all actors in AI processing distance as observers
|
||||||
bool isActorDetected(const MWWorld::Ptr& actor, const MWWorld::Ptr& observer);
|
bool isActorDetected(const MWWorld::Ptr& actor, const MWWorld::Ptr& observer) const;
|
||||||
|
|
||||||
/// Update magic effects for an actor. Usually done automatically once per frame, but if we're currently
|
/// 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)
|
/// paused we may want to do it manually (after equipping permanent enchantment)
|
||||||
void updateMagicEffects (const MWWorld::Ptr& ptr);
|
void updateMagicEffects(const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
void updateProcessingRange();
|
void updateProcessingRange();
|
||||||
float getProcessingRange() const;
|
float getProcessingRange() const;
|
||||||
@ -70,11 +70,11 @@ namespace MWMechanics
|
|||||||
///
|
///
|
||||||
/// \note Ignored, if \a ptr is not a registered actor.
|
/// \note Ignored, if \a ptr is not a registered actor.
|
||||||
|
|
||||||
void resurrect (const MWWorld::Ptr& ptr);
|
void resurrect(const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
void castSpell(const MWWorld::Ptr& ptr, const std::string& spellId, bool manualSpell=false);
|
void castSpell(const MWWorld::Ptr& ptr, const std::string& spellId, bool manualSpell = false) const;
|
||||||
|
|
||||||
void updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr& ptr);
|
void updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr& ptr) const;
|
||||||
///< Updates an actor with a new Ptr
|
///< Updates an actor with a new Ptr
|
||||||
|
|
||||||
void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr& ignore);
|
void dropActors (const MWWorld::CellStore *cellStore, const MWWorld::Ptr& ignore);
|
||||||
@ -86,76 +86,75 @@ namespace MWMechanics
|
|||||||
void update (float duration, bool paused);
|
void update (float duration, bool paused);
|
||||||
///< Update actor stats and store desired velocity vectors in \a movement
|
///< Update actor stats and store desired velocity vectors in \a movement
|
||||||
|
|
||||||
void updateActor (const MWWorld::Ptr& ptr, float duration);
|
void updateActor(const MWWorld::Ptr& ptr, float duration) const;
|
||||||
///< This function is normally called automatically during the update process, but it can
|
///< This function is normally called automatically during the update process, but it can
|
||||||
/// also be called explicitly at any time to force an update.
|
/// also be called explicitly at any time to force an update.
|
||||||
|
|
||||||
/// Removes an actor from combat and makes all of their allies stop fighting the actor's targets
|
/// Removes an actor from combat and makes all of their allies stop fighting the actor's targets
|
||||||
void stopCombat(const MWWorld::Ptr& ptr);
|
void stopCombat(const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
void playIdleDialogue(const MWWorld::Ptr& actor);
|
void playIdleDialogue(const MWWorld::Ptr& actor) const;
|
||||||
void updateMovementSpeed(const MWWorld::Ptr& actor);
|
void updateMovementSpeed(const MWWorld::Ptr& actor) const;
|
||||||
void updateGreetingState(const MWWorld::Ptr& actor, Actor& actorState, bool turnOnly);
|
void updateGreetingState(const MWWorld::Ptr& actor, Actor& actorState, bool turnOnly);
|
||||||
void turnActorToFacePlayer(const MWWorld::Ptr& actor, Actor& actorState, const osg::Vec3f& dir);
|
void turnActorToFacePlayer(const MWWorld::Ptr& actor, Actor& actorState, const osg::Vec3f& dir) const;
|
||||||
|
|
||||||
void updateHeadTracking(const MWWorld::Ptr& actor, const MWWorld::Ptr& targetActor,
|
void rest(double hours, bool sleep) const;
|
||||||
MWWorld::Ptr& headTrackTarget, float& sqrHeadTrackDistance,
|
|
||||||
bool inCombatOrPursue);
|
|
||||||
|
|
||||||
void rest(double hours, bool sleep);
|
|
||||||
///< Update actors while the player is waiting or sleeping.
|
///< Update actors while the player is waiting or sleeping.
|
||||||
|
|
||||||
void updateSneaking(CharacterController* ctrl, float duration);
|
void updateSneaking(CharacterController* ctrl, float duration);
|
||||||
///< Update the sneaking indicator state according to the given player character controller.
|
///< Update the sneaking indicator state according to the given player character controller.
|
||||||
|
|
||||||
void restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep);
|
void restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep) const;
|
||||||
|
|
||||||
int getHoursToRest(const MWWorld::Ptr& ptr) const;
|
int getHoursToRest(const MWWorld::Ptr& ptr) const;
|
||||||
///< Calculate how many hours the given actor needs to rest in order to be fully healed
|
///< Calculate how many hours the given actor needs to rest in order to be fully healed
|
||||||
|
|
||||||
void fastForwardAi();
|
void fastForwardAi() const;
|
||||||
///< Simulate the passing of time
|
///< Simulate the passing of time
|
||||||
|
|
||||||
int countDeaths (const std::string& id) const;
|
int countDeaths (const std::string& id) const;
|
||||||
///< Return the number of deaths for actors with the given ID.
|
///< Return the number of deaths for actors with the given ID.
|
||||||
|
|
||||||
bool isAttackPreparing(const MWWorld::Ptr& ptr);
|
bool isAttackPreparing(const MWWorld::Ptr& ptr) const;
|
||||||
bool isRunning(const MWWorld::Ptr& ptr);
|
bool isRunning(const MWWorld::Ptr& ptr) const;
|
||||||
bool isSneaking(const MWWorld::Ptr& ptr);
|
bool isSneaking(const MWWorld::Ptr& ptr) const;
|
||||||
|
|
||||||
void forceStateUpdate(const MWWorld::Ptr &ptr);
|
void forceStateUpdate(const MWWorld::Ptr &ptr) const;
|
||||||
|
|
||||||
bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number, bool persist=false);
|
bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
|
||||||
void skipAnimation(const MWWorld::Ptr& ptr);
|
int number, bool persist = false) const;
|
||||||
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName);
|
void skipAnimation(const MWWorld::Ptr& ptr) const;
|
||||||
void persistAnimationStates();
|
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) const;
|
||||||
|
void persistAnimationStates() const;
|
||||||
|
|
||||||
void getObjectsInRange(const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& out);
|
void getObjectsInRange(const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& out) const;
|
||||||
|
|
||||||
bool isAnyObjectInRange(const osg::Vec3f& position, float radius);
|
bool isAnyObjectInRange(const osg::Vec3f& position, float radius) const;
|
||||||
|
|
||||||
void cleanupSummonedCreature (CreatureStats& casterStats, int creatureActorId);
|
void cleanupSummonedCreature(CreatureStats& casterStats, int creatureActorId) const;
|
||||||
|
|
||||||
///Returns the list of actors which are siding with the given actor in fights
|
///Returns the list of actors which are siding with the given actor in fights
|
||||||
/**ie AiFollow or AiEscort is active and the target is the actor **/
|
/**ie AiFollow or AiEscort is active and the target is the actor **/
|
||||||
std::vector<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor, bool excludeInfighting = false);
|
std::vector<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor,
|
||||||
std::vector<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
|
bool excludeInfighting = false) const;
|
||||||
|
std::vector<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor) const;
|
||||||
|
|
||||||
/// Recursive version of getActorsFollowing
|
/// Recursive version of getActorsFollowing
|
||||||
void getActorsFollowing(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out);
|
void getActorsFollowing(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out) const;
|
||||||
/// Recursive version of getActorsSidingWith
|
/// Recursive version of getActorsSidingWith
|
||||||
void getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out, bool excludeInfighting = false);
|
void getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out,
|
||||||
|
bool excludeInfighting = false) const;
|
||||||
|
|
||||||
/// Get the list of AiFollow::mFollowIndex for all actors following this target
|
/// Get the list of AiFollow::mFollowIndex for all actors following this target
|
||||||
std::vector<int> getActorsFollowingIndices(const MWWorld::Ptr& actor);
|
std::vector<int> getActorsFollowingIndices(const MWWorld::Ptr& actor) const;
|
||||||
std::map<int, MWWorld::Ptr> getActorsFollowingByIndex(const MWWorld::Ptr& actor);
|
std::map<int, MWWorld::Ptr> getActorsFollowingByIndex(const MWWorld::Ptr& actor) const;
|
||||||
|
|
||||||
///Returns the list of actors which are fighting the given actor
|
///Returns the list of actors which are fighting the given actor
|
||||||
/**ie AiCombat is active and the target is the actor **/
|
/**ie AiCombat is active and the target is the actor **/
|
||||||
std::vector<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor);
|
std::vector<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor) const;
|
||||||
|
|
||||||
/// Unlike getActorsFighting, also returns actors that *would* fight the given actor if they saw him.
|
/// Unlike getActorsFighting, also returns actors that *would* fight the given actor if they saw him.
|
||||||
std::vector<MWWorld::Ptr> getEnemiesNearby(const MWWorld::Ptr& actor);
|
std::vector<MWWorld::Ptr> getEnemiesNearby(const MWWorld::Ptr& actor) const;
|
||||||
|
|
||||||
void write (ESM::ESMWriter& writer, Loading::Listener& listener) const;
|
void write (ESM::ESMWriter& writer, Loading::Listener& listener) const;
|
||||||
|
|
||||||
@ -193,32 +192,31 @@ namespace MWMechanics
|
|||||||
bool mSmoothMovement;
|
bool mSmoothMovement;
|
||||||
MusicType mCurrentMusic = MusicType::Title;
|
MusicType mCurrentMusic = MusicType::Title;
|
||||||
|
|
||||||
void updateVisibility (const MWWorld::Ptr& ptr, CharacterController& ctrl);
|
void updateVisibility(const MWWorld::Ptr& ptr, CharacterController& ctrl) const;
|
||||||
|
|
||||||
void adjustMagicEffects (const MWWorld::Ptr& creature, float duration);
|
void adjustMagicEffects(const MWWorld::Ptr& creature, float duration) const;
|
||||||
|
|
||||||
void calculateRestoration (const MWWorld::Ptr& ptr, float duration);
|
void calculateRestoration(const MWWorld::Ptr& ptr, float duration) const;
|
||||||
|
|
||||||
void updateDrowning (const MWWorld::Ptr& ptr, float duration, bool isKnockedOut, bool isPlayer);
|
void updateCrimePursuit(const MWWorld::Ptr& ptr, float duration) const;
|
||||||
|
|
||||||
void updateEquippedLight (const MWWorld::Ptr& ptr, float duration, bool mayEquip);
|
|
||||||
|
|
||||||
void updateCrimePursuit (const MWWorld::Ptr& ptr, float duration);
|
|
||||||
|
|
||||||
void killDeadActors ();
|
void killDeadActors ();
|
||||||
|
|
||||||
void purgeSpellEffects (int casterActorId);
|
void purgeSpellEffects(int casterActorId) const;
|
||||||
|
|
||||||
void predictAndAvoidCollisions(float duration);
|
void predictAndAvoidCollisions(float duration) const;
|
||||||
|
|
||||||
/** Start combat between two actors
|
/** Start combat between two actors
|
||||||
@Notes: If againstPlayer = true then actor2 should be the Player.
|
@Notes: If againstPlayer = true then actor2 should be the Player.
|
||||||
If one of the combatants is creature it should be actor1.
|
If one of the combatants is creature it should be actor1.
|
||||||
*/
|
*/
|
||||||
void engageCombat(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2, std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> >& cachedAllies, bool againstPlayer);
|
void engageCombat(const MWWorld::Ptr& actor1, const MWWorld::Ptr& actor2,
|
||||||
|
std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr>>& cachedAllies, bool againstPlayer) const;
|
||||||
|
|
||||||
/// Recursive version of getActorsSidingWith that takes, adds to and returns a cache of actors mapped to their allies. Excludes infighting
|
/// Recursive version of getActorsSidingWith that takes, adds to and returns a cache of
|
||||||
void getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out, std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> >& cachedAllies);
|
/// actors mapped to their allies. Excludes infighting
|
||||||
|
void getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out,
|
||||||
|
std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr>>& cachedAllies) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user