2014-05-16 13:09:23 +02:00
|
|
|
#ifndef OPENMW_MWWORLD_PROJECTILEMANAGER_H
|
|
|
|
#define OPENMW_MWWORLD_PROJECTILEMANAGER_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2015-11-20 21:57:04 +01:00
|
|
|
#include <osg/PositionAttitudeTransform>
|
2015-06-01 21:41:13 +02:00
|
|
|
#include <osg/ref_ptr>
|
2014-05-16 13:09:23 +02:00
|
|
|
|
2022-01-22 15:58:41 +01:00
|
|
|
#include <components/esm3/effectlist.hpp>
|
2014-05-16 13:09:23 +02:00
|
|
|
|
|
|
|
#include "../mwbase/soundmanager.hpp"
|
|
|
|
|
|
|
|
#include "ptr.hpp"
|
|
|
|
|
2015-05-12 19:02:56 +02:00
|
|
|
namespace MWPhysics
|
2014-05-16 13:09:23 +02:00
|
|
|
{
|
2015-05-12 19:02:56 +02:00
|
|
|
class PhysicsSystem;
|
2014-05-16 13:09:23 +02:00
|
|
|
}
|
|
|
|
|
2014-05-17 05:21:17 +02:00
|
|
|
namespace Loading
|
|
|
|
{
|
|
|
|
class Listener;
|
|
|
|
}
|
|
|
|
|
2015-06-01 21:41:13 +02:00
|
|
|
namespace osg
|
2014-05-16 13:09:23 +02:00
|
|
|
{
|
2015-06-01 21:41:13 +02:00
|
|
|
class Group;
|
|
|
|
class Quat;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
class ResourceSystem;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
class EffectAnimationTime;
|
2015-12-04 23:28:11 +01:00
|
|
|
class RenderingManager;
|
2014-05-16 13:09:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
|
|
|
|
class ProjectileManager
|
|
|
|
{
|
|
|
|
public:
|
2015-06-01 21:41:13 +02:00
|
|
|
ProjectileManager(osg::Group* parent, Resource::ResourceSystem* resourceSystem,
|
2015-12-04 23:28:11 +01:00
|
|
|
MWRender::RenderingManager* rendering, MWPhysics::PhysicsSystem* physics);
|
2014-05-16 13:09:23 +02:00
|
|
|
|
2014-06-18 01:41:07 +02:00
|
|
|
/// If caster is an actor, the actor's facing orientation is used. Otherwise fallbackDirection is used.
|
2021-08-27 20:07:50 +02:00
|
|
|
void launchMagicBolt(
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
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!
2022-09-25 13:17:09 +02:00
|
|
|
const ESM::RefId& spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection, int slot);
|
2014-05-16 13:09:23 +02:00
|
|
|
|
2021-06-23 23:13:59 +02:00
|
|
|
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);
|
2014-05-16 13:09:23 +02:00
|
|
|
|
2021-02-25 23:12:14 +00:00
|
|
|
void updateCasters();
|
|
|
|
|
2014-05-16 13:09:23 +02:00
|
|
|
void update(float dt);
|
|
|
|
|
2020-10-23 20:27:07 +02:00
|
|
|
void processHits();
|
2019-02-13 11:30:16 +04:00
|
|
|
|
2014-05-16 13:09:23 +02:00
|
|
|
/// Removes all current projectiles. Should be called when switching to a new worldspace.
|
|
|
|
void clear();
|
|
|
|
|
2014-05-17 05:21:17 +02:00
|
|
|
void write(ESM::ESMWriter& writer, Loading::Listener& progress) const;
|
2015-01-22 19:04:59 +01:00
|
|
|
bool readRecord(ESM::ESMReader& reader, uint32_t type);
|
2014-05-17 05:21:17 +02:00
|
|
|
int countSavedGameRecords() const;
|
|
|
|
|
2014-05-16 13:09:23 +02:00
|
|
|
private:
|
2015-06-01 21:41:13 +02:00
|
|
|
osg::ref_ptr<osg::Group> mParent;
|
|
|
|
Resource::ResourceSystem* mResourceSystem;
|
2015-12-04 23:28:11 +01:00
|
|
|
MWRender::RenderingManager* mRendering;
|
2015-06-01 21:41:13 +02:00
|
|
|
MWPhysics::PhysicsSystem* mPhysics;
|
2017-09-23 18:54:17 +02:00
|
|
|
float mCleanupTimer;
|
2014-05-16 13:09:23 +02:00
|
|
|
|
|
|
|
struct State
|
|
|
|
{
|
2015-06-01 21:41:13 +02:00
|
|
|
osg::ref_ptr<osg::PositionAttitudeTransform> mNode;
|
2017-05-05 19:26:09 +02:00
|
|
|
std::shared_ptr<MWRender::EffectAnimationTime> mEffectAnimationTime;
|
2014-05-17 05:21:17 +02:00
|
|
|
|
|
|
|
int mActorId;
|
2019-02-13 11:30:16 +04:00
|
|
|
int mProjectileId;
|
|
|
|
|
2014-06-18 01:41:07 +02:00
|
|
|
// 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.
|
2015-06-01 21:41:13 +02:00
|
|
|
MWWorld::Ptr mCasterHandle;
|
|
|
|
|
|
|
|
MWWorld::Ptr getCaster();
|
2014-06-18 01:41:07 +02:00
|
|
|
|
2016-09-04 01:54:09 +09:00
|
|
|
// MW-ids of a magic projectile
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
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!
2022-09-25 13:17:09 +02:00
|
|
|
std::vector<ESM::RefId> mIdMagic;
|
2016-09-04 01:54:09 +09:00
|
|
|
|
|
|
|
// MW-id of an arrow projectile
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
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!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId mIdArrow;
|
2020-10-23 20:27:07 +02:00
|
|
|
|
|
|
|
bool mToDelete;
|
2014-05-16 13:09:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MagicBoltState : public State
|
|
|
|
{
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
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!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId mSpellId;
|
2014-05-16 13:09:23 +02:00
|
|
|
|
|
|
|
// 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;
|
2021-08-27 20:07:50 +02:00
|
|
|
int mSlot;
|
2014-05-16 13:09:23 +02:00
|
|
|
|
2017-09-11 21:33:18 -07:00
|
|
|
std::vector<MWBase::Sound*> mSounds;
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
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!
2022-09-25 13:17:09 +02:00
|
|
|
std::set<ESM::RefId> mSoundIds;
|
2014-05-16 13:09:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ProjectileState : public State
|
|
|
|
{
|
2014-05-17 02:52:10 +02:00
|
|
|
// RefID of the bow or crossbow the actor was using when this projectile was fired (may be empty)
|
Initial commit: In ESM structures, replace the string members that are RefIds to other records, to a new strong type
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!
2022-09-25 13:17:09 +02:00
|
|
|
ESM::RefId mBowId;
|
2014-05-16 13:09:23 +02:00
|
|
|
|
2015-06-01 21:41:13 +02:00
|
|
|
osg::Vec3f mVelocity;
|
2015-06-26 02:32:41 +02:00
|
|
|
float mAttackStrength;
|
2017-11-23 00:32:22 +01:00
|
|
|
bool mThrown;
|
2014-05-16 13:09:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<MagicBoltState> mMagicBolts;
|
|
|
|
std::vector<ProjectileState> mProjectiles;
|
|
|
|
|
2017-09-23 18:54:17 +02:00
|
|
|
void cleanupProjectile(ProjectileState& state);
|
|
|
|
void cleanupMagicBolt(MagicBoltState& state);
|
|
|
|
void periodicCleanup(float dt);
|
|
|
|
|
2014-05-16 13:09:23 +02:00
|
|
|
void moveProjectiles(float dt);
|
|
|
|
void moveMagicBolts(float dt);
|
|
|
|
|
2021-02-05 12:12:34 +01:00
|
|
|
void createModel(State& state, const std::string& model, const osg::Vec3f& pos, const osg::Quat& orient,
|
2016-12-09 18:10:06 -07:00
|
|
|
bool rotate, bool createLight, osg::Vec4 lightDiffuseColor, std::string texture = "");
|
2015-06-01 21:41:13 +02:00
|
|
|
void update(State& state, float duration);
|
2015-12-04 23:28:11 +01:00
|
|
|
|
|
|
|
void operator=(const ProjectileManager&);
|
|
|
|
ProjectileManager(const ProjectileManager&);
|
2014-05-16 13:09:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|