mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-17 01:10:10 +00:00
125b21de20
The strong type is actually just a string underneath, but this will help in the future to have a distinction so it's easier to search and replace when we use an integer ID Slowly going through all the changes to make, still hundreds of errors a lot of functions/structures use std::string or stringview to designate an ID. So it takes time Continues slowly replacing ids. There are technically more and more compilation errors I have good hope that there is a point where the amount of errors will dramatically go down as all the main functions use the ESM::RefId type Continue moving forward, changes to the stores slowly moving along Starting to see the fruit of those changes. still many many error, but more and more Irun into a situation where a function is sandwiched between two functions that use the RefId type. More replacements. Things are starting to get easier I can see more and more often the issue is that the function is awaiting a RefId, but is given a string there is less need to go down functions and to fix a long list of them. Still moving forward, and for the first time error count is going down! Good pace, not sure about topics though, mId and mName are actually the same thing and are used interchangeably Cells are back to using string for the name, haven't fixed everything yet. Many other changes Under the bar of 400 compilation errors. more good progress <100 compile errors! More progress Game settings store can use string for find, it was a bit absurd how every use of it required to create refId from string some more progress on other fronts Mostly game settings clean one error opened a lot of other errors. Down to 18, but more will prbably appear only link errors left?? Fixed link errors OpenMW compiles, and launches, with some issues, but still!
148 lines
3.9 KiB
C++
148 lines
3.9 KiB
C++
#ifndef OPENMW_MWWORLD_PROJECTILEMANAGER_H
|
|
#define OPENMW_MWWORLD_PROJECTILEMANAGER_H
|
|
|
|
#include <string>
|
|
|
|
#include <osg/PositionAttitudeTransform>
|
|
#include <osg/ref_ptr>
|
|
|
|
#include <components/esm3/effectlist.hpp>
|
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
#include "ptr.hpp"
|
|
|
|
namespace MWPhysics
|
|
{
|
|
class PhysicsSystem;
|
|
}
|
|
|
|
namespace Loading
|
|
{
|
|
class Listener;
|
|
}
|
|
|
|
namespace osg
|
|
{
|
|
class Group;
|
|
class Quat;
|
|
}
|
|
|
|
namespace Resource
|
|
{
|
|
class ResourceSystem;
|
|
}
|
|
|
|
namespace MWRender
|
|
{
|
|
class EffectAnimationTime;
|
|
class RenderingManager;
|
|
}
|
|
|
|
namespace MWWorld
|
|
{
|
|
|
|
class ProjectileManager
|
|
{
|
|
public:
|
|
ProjectileManager(osg::Group* parent, Resource::ResourceSystem* resourceSystem,
|
|
MWRender::RenderingManager* rendering, MWPhysics::PhysicsSystem* physics);
|
|
|
|
/// If caster is an actor, the actor's facing orientation is used. Otherwise fallbackDirection is used.
|
|
void launchMagicBolt(
|
|
const ESM::RefId& spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection, int slot);
|
|
|
|
void launchProjectile(const MWWorld::Ptr& actor, const MWWorld::ConstPtr& projectile, const osg::Vec3f& pos,
|
|
const osg::Quat& orient, const MWWorld::Ptr& bow, float speed, float attackStrength);
|
|
|
|
void updateCasters();
|
|
|
|
void update(float dt);
|
|
|
|
void processHits();
|
|
|
|
/// Removes all current projectiles. Should be called when switching to a new worldspace.
|
|
void clear();
|
|
|
|
void write(ESM::ESMWriter& writer, Loading::Listener& progress) const;
|
|
bool readRecord(ESM::ESMReader& reader, uint32_t type);
|
|
int countSavedGameRecords() const;
|
|
|
|
private:
|
|
osg::ref_ptr<osg::Group> mParent;
|
|
Resource::ResourceSystem* mResourceSystem;
|
|
MWRender::RenderingManager* mRendering;
|
|
MWPhysics::PhysicsSystem* mPhysics;
|
|
float mCleanupTimer;
|
|
|
|
struct State
|
|
{
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
|
|
std::shared_ptr<MWRender::EffectAnimationTime> mEffectAnimationTime;
|
|
|
|
int mActorId;
|
|
int mProjectileId;
|
|
|
|
// TODO: this will break when the game is saved and reloaded, since there is currently
|
|
// no way to write identifiers for non-actors to a savegame.
|
|
MWWorld::Ptr mCasterHandle;
|
|
|
|
MWWorld::Ptr getCaster();
|
|
|
|
// MW-ids of a magic projectile
|
|
std::vector<ESM::RefId> mIdMagic;
|
|
|
|
// MW-id of an arrow projectile
|
|
ESM::RefId mIdArrow;
|
|
|
|
bool mToDelete;
|
|
};
|
|
|
|
struct MagicBoltState : public State
|
|
{
|
|
ESM::RefId mSpellId;
|
|
|
|
// Name of item to display as effect source in magic menu (in case we casted an enchantment)
|
|
std::string mSourceName;
|
|
|
|
ESM::EffectList mEffects;
|
|
|
|
float mSpeed;
|
|
int mSlot;
|
|
|
|
std::vector<MWBase::Sound*> mSounds;
|
|
std::set<ESM::RefId> mSoundIds;
|
|
};
|
|
|
|
struct ProjectileState : public State
|
|
{
|
|
// RefID of the bow or crossbow the actor was using when this projectile was fired (may be empty)
|
|
ESM::RefId mBowId;
|
|
|
|
osg::Vec3f mVelocity;
|
|
float mAttackStrength;
|
|
bool mThrown;
|
|
};
|
|
|
|
std::vector<MagicBoltState> mMagicBolts;
|
|
std::vector<ProjectileState> mProjectiles;
|
|
|
|
void cleanupProjectile(ProjectileState& state);
|
|
void cleanupMagicBolt(MagicBoltState& state);
|
|
void periodicCleanup(float dt);
|
|
|
|
void moveProjectiles(float dt);
|
|
void moveMagicBolts(float dt);
|
|
|
|
void createModel(State& state, const std::string& model, const osg::Vec3f& pos, const osg::Quat& orient,
|
|
bool rotate, bool createLight, osg::Vec4 lightDiffuseColor, std::string texture = "");
|
|
void update(State& state, float duration);
|
|
|
|
void operator=(const ProjectileManager&);
|
|
ProjectileManager(const ProjectileManager&);
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|