-
Notifications
You must be signed in to change notification settings - Fork 954
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should replace accidental CRLF with LF
- Loading branch information
1 parent
4d01489
commit 84f8a68
Showing
62 changed files
with
9,894 additions
and
9,894 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
#include "aiactivate.hpp" | ||
|
||
#include <components/esm3/aisequence.hpp> | ||
|
||
#include "../mwbase/world.hpp" | ||
#include "../mwbase/environment.hpp" | ||
|
||
#include "../mwworld/class.hpp" | ||
|
||
#include "creaturestats.hpp" | ||
#include "movement.hpp" | ||
#include "steering.hpp" | ||
|
||
namespace MWMechanics | ||
{ | ||
AiActivate::AiActivate(std::string_view objectId, bool repeat) | ||
: TypedAiPackage<AiActivate>(repeat), mObjectId(objectId) | ||
{ | ||
} | ||
|
||
bool AiActivate::execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) | ||
{ | ||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow | ||
|
||
actor.getClass().getCreatureStats(actor).setDrawState(DrawState::Nothing); | ||
|
||
// Stop if the target doesn't exist | ||
// Really we should be checking whether the target is currently registered with the MechanicsManager | ||
if (target == MWWorld::Ptr() || !target.getRefData().getCount() || !target.getRefData().isEnabled()) | ||
return true; | ||
|
||
// Turn to target and move to it directly, without pathfinding. | ||
const osg::Vec3f targetDir = target.getRefData().getPosition().asVec3() - actor.getRefData().getPosition().asVec3(); | ||
|
||
zTurn(actor, std::atan2(targetDir.x(), targetDir.y()), 0.f); | ||
actor.getClass().getMovementSettings(actor).mPosition[1] = 1; | ||
actor.getClass().getMovementSettings(actor).mPosition[0] = 0; | ||
|
||
if (MWBase::Environment::get().getWorld()->getMaxActivationDistance() >= targetDir.length()) | ||
{ | ||
// Note: we intentionally do not cancel package after activation here for backward compatibility with original engine. | ||
MWBase::Environment::get().getWorld()->activate(target, actor); | ||
} | ||
return false; | ||
} | ||
|
||
void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const | ||
{ | ||
auto activate = std::make_unique<ESM::AiSequence::AiActivate>(); | ||
activate->mTargetId = mObjectId; | ||
activate->mRepeat = getRepeat(); | ||
|
||
ESM::AiSequence::AiPackageContainer package; | ||
package.mType = ESM::AiSequence::Ai_Activate; | ||
package.mPackage = std::move(activate); | ||
sequence.mPackages.push_back(std::move(package)); | ||
} | ||
|
||
AiActivate::AiActivate(const ESM::AiSequence::AiActivate *activate) | ||
: AiActivate(activate->mTargetId, activate->mRepeat) | ||
{ | ||
} | ||
} | ||
#include "aiactivate.hpp" | ||
|
||
#include <components/esm3/aisequence.hpp> | ||
|
||
#include "../mwbase/world.hpp" | ||
#include "../mwbase/environment.hpp" | ||
|
||
#include "../mwworld/class.hpp" | ||
|
||
#include "creaturestats.hpp" | ||
#include "movement.hpp" | ||
#include "steering.hpp" | ||
|
||
namespace MWMechanics | ||
{ | ||
AiActivate::AiActivate(std::string_view objectId, bool repeat) | ||
: TypedAiPackage<AiActivate>(repeat), mObjectId(objectId) | ||
{ | ||
} | ||
|
||
bool AiActivate::execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) | ||
{ | ||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow | ||
|
||
actor.getClass().getCreatureStats(actor).setDrawState(DrawState::Nothing); | ||
|
||
// Stop if the target doesn't exist | ||
// Really we should be checking whether the target is currently registered with the MechanicsManager | ||
if (target == MWWorld::Ptr() || !target.getRefData().getCount() || !target.getRefData().isEnabled()) | ||
return true; | ||
|
||
// Turn to target and move to it directly, without pathfinding. | ||
const osg::Vec3f targetDir = target.getRefData().getPosition().asVec3() - actor.getRefData().getPosition().asVec3(); | ||
|
||
zTurn(actor, std::atan2(targetDir.x(), targetDir.y()), 0.f); | ||
actor.getClass().getMovementSettings(actor).mPosition[1] = 1; | ||
actor.getClass().getMovementSettings(actor).mPosition[0] = 0; | ||
|
||
if (MWBase::Environment::get().getWorld()->getMaxActivationDistance() >= targetDir.length()) | ||
{ | ||
// Note: we intentionally do not cancel package after activation here for backward compatibility with original engine. | ||
MWBase::Environment::get().getWorld()->activate(target, actor); | ||
} | ||
return false; | ||
} | ||
|
||
void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const | ||
{ | ||
auto activate = std::make_unique<ESM::AiSequence::AiActivate>(); | ||
activate->mTargetId = mObjectId; | ||
activate->mRepeat = getRepeat(); | ||
|
||
ESM::AiSequence::AiPackageContainer package; | ||
package.mType = ESM::AiSequence::Ai_Activate; | ||
package.mPackage = std::move(activate); | ||
sequence.mPackages.push_back(std::move(package)); | ||
} | ||
|
||
AiActivate::AiActivate(const ESM::AiSequence::AiActivate *activate) | ||
: AiActivate(activate->mTargetId, activate->mRepeat) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,40 @@ | ||
#ifndef GAME_MWMECHANICS_AIACTIVATE_H | ||
#define GAME_MWMECHANICS_AIACTIVATE_H | ||
|
||
#include "typedaipackage.hpp" | ||
|
||
#include <string> | ||
#include <string_view> | ||
|
||
namespace ESM | ||
{ | ||
namespace AiSequence | ||
{ | ||
struct AiActivate; | ||
} | ||
} | ||
|
||
namespace MWMechanics | ||
{ | ||
/// \brief Causes actor to walk to activatable object and activate it | ||
/** Will activate when close to object **/ | ||
class AiActivate final : public TypedAiPackage<AiActivate> | ||
{ | ||
public: | ||
/// Constructor | ||
/** \param objectId Reference to object to activate **/ | ||
explicit AiActivate(std::string_view objectId, bool repeat); | ||
|
||
explicit AiActivate(const ESM::AiSequence::AiActivate* activate); | ||
|
||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) override; | ||
|
||
static constexpr AiPackageTypeId getTypeId() { return AiPackageTypeId::Activate; } | ||
|
||
void writeState(ESM::AiSequence::AiSequence& sequence) const override; | ||
|
||
private: | ||
const std::string mObjectId; | ||
}; | ||
} | ||
#endif // GAME_MWMECHANICS_AIACTIVATE_H | ||
#ifndef GAME_MWMECHANICS_AIACTIVATE_H | ||
#define GAME_MWMECHANICS_AIACTIVATE_H | ||
|
||
#include "typedaipackage.hpp" | ||
|
||
#include <string> | ||
#include <string_view> | ||
|
||
namespace ESM | ||
{ | ||
namespace AiSequence | ||
{ | ||
struct AiActivate; | ||
} | ||
} | ||
|
||
namespace MWMechanics | ||
{ | ||
/// \brief Causes actor to walk to activatable object and activate it | ||
/** Will activate when close to object **/ | ||
class AiActivate final : public TypedAiPackage<AiActivate> | ||
{ | ||
public: | ||
/// Constructor | ||
/** \param objectId Reference to object to activate **/ | ||
explicit AiActivate(std::string_view objectId, bool repeat); | ||
|
||
explicit AiActivate(const ESM::AiSequence::AiActivate* activate); | ||
|
||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) override; | ||
|
||
static constexpr AiPackageTypeId getTypeId() { return AiPackageTypeId::Activate; } | ||
|
||
void writeState(ESM::AiSequence::AiSequence& sequence) const override; | ||
|
||
private: | ||
const std::string mObjectId; | ||
}; | ||
} | ||
#endif // GAME_MWMECHANICS_AIACTIVATE_H |
Oops, something went wrong.