2022-08-06 03:01:59 +00:00
|
|
|
#pragma once
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "BitStream.h"
|
|
|
|
#include "BehaviorTemplates.h"
|
|
|
|
#include "dCommonVars.h"
|
|
|
|
|
|
|
|
struct BehaviorContext;
|
|
|
|
struct BehaviorBranchContext;
|
|
|
|
class CDBehaviorParameterTable;
|
|
|
|
|
|
|
|
class Behavior
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/*
|
|
|
|
* Static
|
|
|
|
*/
|
2022-07-09 06:07:52 +00:00
|
|
|
static std::unordered_map<uint32_t, Behavior*> Cache;
|
2021-12-05 17:54:36 +00:00
|
|
|
static CDBehaviorParameterTable* BehaviorParameterTable;
|
|
|
|
|
|
|
|
static Behavior* GetBehavior(uint32_t behaviorId);
|
|
|
|
|
|
|
|
static Behavior* CreateBehavior(uint32_t behaviorId);
|
|
|
|
|
|
|
|
static BehaviorTemplates GetBehaviorTemplate(uint32_t behaviorId);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Utilities
|
|
|
|
*/
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
void PlayFx(std::u16string type, LWOOBJID target, LWOOBJID secondary = LWOOBJID_EMPTY);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Members
|
|
|
|
*/
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
uint32_t m_behaviorId;
|
|
|
|
BehaviorTemplates m_templateId;
|
|
|
|
uint32_t m_effectId;
|
|
|
|
std::string* m_effectHandle = nullptr;
|
|
|
|
std::unordered_map<std::string, std::string>* m_effectNames = nullptr;
|
|
|
|
std::string* m_effectType = nullptr;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/*
|
|
|
|
* Behavior parameters
|
|
|
|
*/
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2022-01-24 22:02:56 +00:00
|
|
|
float GetFloat(const std::string& name, const float defaultValue = 0) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-01-24 22:02:56 +00:00
|
|
|
bool GetBoolean(const std::string& name, const bool defaultValue = false) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-01-24 22:02:56 +00:00
|
|
|
int32_t GetInt(const std::string& name, const int32_t defaultValue = 0) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
Behavior* GetAction(const std::string& name) const;
|
|
|
|
|
|
|
|
Behavior* GetAction(float value) const;
|
|
|
|
|
|
|
|
std::map<std::string, float> GetParameterNames() const;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
/*
|
|
|
|
* Virtual
|
|
|
|
*/
|
|
|
|
|
|
|
|
virtual void Load();
|
|
|
|
|
|
|
|
// Player side
|
|
|
|
virtual void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
virtual void Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch);
|
|
|
|
|
|
|
|
virtual void UnCast(BehaviorContext* context, BehaviorBranchContext branch);
|
|
|
|
|
|
|
|
virtual void Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
virtual void End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
// Npc side
|
|
|
|
virtual void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch);
|
|
|
|
|
|
|
|
virtual void SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Creations/destruction
|
|
|
|
*/
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
explicit Behavior(uint32_t behaviorId);
|
|
|
|
virtual ~Behavior();
|
|
|
|
};
|