Merge branch 'split_actorutil_hpp' into 'master'

Split apps/openmw/mwmechanics/actorutil.hpp

See merge request OpenMW/openmw!2056
just_say_no_to_geode
psi29a 3 years ago
commit cef4ce2c01

@ -5,9 +5,9 @@
#include <vector>
#include <set>
#include <cstdint>
#include <map>
#include "../mwmechanics/actorutil.hpp"
// For MWMechanics::GreetingState
#include "../mwmechanics/greetingstate.hpp"
#include "../mwworld/ptr.hpp"

@ -27,8 +27,8 @@
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/inventory.hpp"
namespace MWClass
{

@ -12,6 +12,12 @@
#include "../mwmechanics/disease.hpp"
#include "../mwmechanics/spellcasting.hpp"
#include "../mwmechanics/difficultyscaling.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/combat.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/creaturecustomdataresetter.hpp"
#include "../mwmechanics/aisetting.hpp"
#include "../mwmechanics/inventory.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
@ -27,18 +33,14 @@
#include "../mwworld/containerstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwrender/renderinginterface.hpp"
#include "../mwrender/objects.hpp"
#include "../mwgui/tooltips.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/combat.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace
{
bool isFlagBitSet(const MWWorld::ConstPtr &ptr, ESM::Creature::Flags bitMask)
@ -117,7 +119,7 @@ namespace MWClass
{
auto tempData = std::make_unique<CreatureCustomData>();
CreatureCustomData* data = tempData.get();
MWMechanics::CreatureCustomDataResetter resetter(ptr);
MWMechanics::CreatureCustomDataResetter resetter {ptr};
ptr.getRefData().setCustomData(std::move(tempData));
MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>();

@ -7,8 +7,14 @@
#include "../mwworld/cellstore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
namespace MWClass
{
class CreatureLevListCustomData : public MWWorld::TypedCustomData<CreatureLevListCustomData>

@ -12,6 +12,9 @@
#include <components/esm3/loadnpc.hpp>
#include <components/esm3/npcstate.hpp>
#include <components/settings/settings.hpp>
#include <components/esm3/loadrace.hpp>
#include <components/esm3/loadclas.hpp>
#include <components/esm3/loadnpc.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -31,6 +34,9 @@
#include "../mwmechanics/difficultyscaling.hpp"
#include "../mwmechanics/weapontype.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/creaturecustomdataresetter.hpp"
#include "../mwmechanics/inventory.hpp"
#include "../mwmechanics/aisetting.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
@ -40,6 +46,7 @@
#include "../mwworld/customdata.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/localscripts.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -311,7 +318,7 @@ namespace MWClass
bool recalculate = false;
auto tempData = std::make_unique<NpcCustomData>();
NpcCustomData* data = tempData.get();
MWMechanics::CreatureCustomDataResetter resetter(ptr);
MWMechanics::CreatureCustomDataResetter resetter {ptr};
ptr.getRefData().setCustomData(std::move(tempData));
MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>();

@ -16,6 +16,7 @@
#include "../mwmechanics/actorutil.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include <MyGUI_Macros.h>
#include <components/esm/records.hpp>

@ -28,6 +28,7 @@
#include "../mwworld/actionequip.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "itemview.hpp"
#include "inventoryitemmodel.hpp"

@ -12,6 +12,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
namespace MWGui
{

@ -4,6 +4,8 @@
#include <MyGUI_Button.h>
#include <MyGUI_ScrollView.h>
#include <components/misc/stringops.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
@ -11,7 +13,9 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWGui
{

@ -10,11 +10,16 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/store.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/spellutil.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "tooltips.hpp"
#include "class.hpp"

@ -5,6 +5,7 @@
#include <MyGUI_Gui.h>
#include <components/settings/settings.hpp>
#include <components/esm3/loadgmst.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -16,7 +17,10 @@
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/cellutils.hpp"
#include "../mwworld/store.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWGui
{

@ -3,8 +3,11 @@
#include <memory>
#include "actorutil.hpp"
#include "character.hpp"
#include "greetingstate.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include <components/misc/timer.hpp>

@ -7,7 +7,6 @@
#include <list>
#include <map>
#include "actorutil.hpp"
#include "actor.hpp"
namespace ESM

@ -6,6 +6,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
#include <components/esm3/loadmgef.hpp>
namespace MWMechanics
{
MWWorld::Ptr getPlayer()
@ -29,12 +31,4 @@ namespace MWMechanics
const MWMechanics::MagicEffects& effects = actor.getClass().getCreatureStats(actor).getMagicEffects();
return effects.get(ESM::MagicEffect::WaterWalking).getMagnitude() > 0;
}
CreatureCustomDataResetter::CreatureCustomDataResetter(const MWWorld::Ptr& ptr) : mPtr(ptr) {}
CreatureCustomDataResetter::~CreatureCustomDataResetter()
{
if(!mPtr.isEmpty())
mPtr.getRefData().setCustomData({});
}
}

@ -1,19 +1,6 @@
#ifndef OPENMW_MWMECHANICS_ACTORUTIL_H
#define OPENMW_MWMECHANICS_ACTORUTIL_H
#include <algorithm>
#include <components/esm3/loadcont.hpp>
#include <components/esm3/loadcrea.hpp>
#include <components/esm3/loadnpc.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
#include "./creaturestats.hpp"
namespace MWWorld
{
class Ptr;
@ -21,79 +8,10 @@ namespace MWWorld
namespace MWMechanics
{
enum GreetingState
{
Greet_None,
Greet_InProgress,
Greet_Done
};
MWWorld::Ptr getPlayer();
bool isPlayerInCombat();
bool canActorMoveByZAxis(const MWWorld::Ptr& actor);
bool hasWaterWalking(const MWWorld::Ptr& actor);
template<class T>
void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value)
{
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(id);
switch(setting)
{
case MWMechanics::CreatureStats::AiSetting::AI_Hello:
copy.mAiData.mHello = value;
break;
case MWMechanics::CreatureStats::AiSetting::AI_Fight:
copy.mAiData.mFight = value;
break;
case MWMechanics::CreatureStats::AiSetting::AI_Flee:
copy.mAiData.mFlee = value;
break;
case MWMechanics::CreatureStats::AiSetting::AI_Alarm:
copy.mAiData.mAlarm = value;
break;
default:
assert(0);
}
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
}
template<class T>
void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount)
{
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(actorId);
for(auto& it : copy.mInventory.mList)
{
if(Misc::StringUtils::ciEqual(it.mItem, itemId))
{
int sign = it.mCount < 1 ? -1 : 1;
it.mCount = sign * std::max(it.mCount * sign + amount, 0);
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
return;
}
}
if(amount > 0)
{
ESM::ContItem cont;
cont.mItem = itemId;
cont.mCount = amount;
copy.mInventory.mList.push_back(cont);
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
}
}
template void setBaseAISetting<ESM::Creature>(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value);
template void setBaseAISetting<ESM::NPC>(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value);
template void modifyBaseInventory<ESM::Creature>(const std::string& actorId, const std::string& itemId, int amount);
template void modifyBaseInventory<ESM::NPC>(const std::string& actorId, const std::string& itemId, int amount);
template void modifyBaseInventory<ESM::Container>(const std::string& containerId, const std::string& itemId, int amount);
struct CreatureCustomDataResetter
{
MWWorld::Ptr mPtr;
CreatureCustomDataResetter(const MWWorld::Ptr& ptr);
~CreatureCustomDataResetter();
};
}
#endif

@ -0,0 +1,40 @@
#ifndef OPENMW_MWMECHANICS_AISETTING_H
#define OPENMW_MWMECHANICS_AISETTING_H
#include <string>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
#include "creaturestats.hpp"
namespace MWMechanics
{
template<class T>
void setBaseAISetting(const std::string& id, MWMechanics::CreatureStats::AiSetting setting, int value)
{
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(id);
switch (setting)
{
case MWMechanics::CreatureStats::AiSetting::AI_Hello:
copy.mAiData.mHello = value;
break;
case MWMechanics::CreatureStats::AiSetting::AI_Fight:
copy.mAiData.mFight = value;
break;
case MWMechanics::CreatureStats::AiSetting::AI_Flee:
copy.mAiData.mFlee = value;
break;
case MWMechanics::CreatureStats::AiSetting::AI_Alarm:
copy.mAiData.mAlarm = value;
break;
default:
assert(false);
}
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
}
}
#endif

@ -0,0 +1,20 @@
#ifndef OPENMW_MWMECHANICS_CREATURECUSTOMDATARESETTER_H
#define OPENMW_MWMECHANICS_CREATURECUSTOMDATARESETTER_H
#include "../mwworld/ptr.hpp"
namespace MWMechanics
{
struct CreatureCustomDataResetter
{
MWWorld::Ptr mPtr;
~CreatureCustomDataResetter()
{
if (!mPtr.isEmpty())
mPtr.getRefData().setCustomData({});
}
};
}
#endif

@ -0,0 +1,14 @@
#ifndef OPENMW_MWMECHANICS_GREETINGSTATE_H
#define OPENMW_MWMECHANICS_GREETINGSTATE_H
namespace MWMechanics
{
enum GreetingState
{
Greet_None,
Greet_InProgress,
Greet_Done
};
}
#endif

@ -0,0 +1,42 @@
#ifndef OPENMW_MWMECHANICS_INVENTORY_H
#define OPENMW_MWMECHANICS_INVENTORY_H
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
#include <components/misc/stringops.hpp>
#include <components/esm3/loadcont.hpp>
#include <algorithm>
#include <string>
namespace MWMechanics
{
template <class T>
void modifyBaseInventory(const std::string& actorId, const std::string& itemId, int amount)
{
T copy = *MWBase::Environment::get().getWorld()->getStore().get<T>().find(actorId);
for (auto& it : copy.mInventory.mList)
{
if (Misc::StringUtils::ciEqual(it.mItem, itemId))
{
const int sign = it.mCount < 1 ? -1 : 1;
it.mCount = sign * std::max(it.mCount * sign + amount, 0);
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
return;
}
}
if (amount > 0)
{
ESM::ContItem cont;
cont.mItem = itemId;
cont.mCount = amount;
copy.mInventory.mList.push_back(cont);
MWBase::Environment::get().getWorld()->createOverrideRecord(copy);
}
}
}
#endif

@ -9,11 +9,15 @@
#include <components/misc/barrier.hpp>
#include "components/misc/convert.hpp"
#include "components/settings/settings.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwrender/bulletdebugdraw.hpp"
#include "../mwworld/class.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "actor.hpp"
#include "contacttestwrapper.h"
#include "movementsolver.hpp"

@ -52,14 +52,18 @@
#include <components/detournavigator/navigator.hpp>
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/groundcoverstore.hpp"
#include "../mwgui/loadingscreen.hpp"
#include "../mwgui/postprocessorhud.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "sky.hpp"
#include "effectmanager.hpp"

@ -14,6 +14,7 @@
#include <components/misc/stringops.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/esm3/loadlevlist.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
@ -26,6 +27,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/manualref.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/levelledlist.hpp"

@ -5,6 +5,7 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwmechanics/disease.hpp"
#include "../mwmechanics/actorutil.hpp"
namespace MWWorld
{

@ -1,5 +1,7 @@
#include "actionteleport.hpp"
#include <components/esm3/loadcell.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"

@ -5,6 +5,7 @@
#include <components/debug/debuglog.hpp>
#include <components/esm3/inventorystate.hpp>
#include <components/misc/stringops.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
@ -19,6 +20,7 @@
#include "class.hpp"
#include "localscripts.hpp"
#include "player.hpp"
#include "esmstore.hpp"
namespace
{

@ -8,6 +8,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwmechanics/actorutil.hpp"

@ -47,6 +47,7 @@
#include "../mwmechanics/combat.hpp"
#include "../mwmechanics/aiavoiddoor.hpp" //Used to tell actors to avoid doors
#include "../mwmechanics/summoning.hpp"
#include "../mwmechanics/actorutil.hpp"
#include "../mwrender/animation.hpp"
#include "../mwrender/npcanimation.hpp"

Loading…
Cancel
Save