2023-06-07 07:23:50 +00:00
|
|
|
#ifndef __ENTITY__H__
|
|
|
|
#define __ENTITY__H__
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
#include <memory>
|
2023-06-16 08:01:13 +00:00
|
|
|
#include <functional>
|
2023-01-07 05:17:05 +00:00
|
|
|
#include <unordered_map>
|
2021-12-05 17:54:36 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-06-15 09:28:27 +00:00
|
|
|
#include "dCommonVars.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
#include "NiPoint3.h"
|
|
|
|
#include "NiQuaternion.h"
|
2023-05-02 22:39:21 +00:00
|
|
|
#include "eKillType.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-01-07 05:17:05 +00:00
|
|
|
namespace Loot {
|
|
|
|
class Info;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace tinyxml2 {
|
|
|
|
class XMLDocument;
|
|
|
|
};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
namespace CppScripts {
|
|
|
|
class Script;
|
|
|
|
};
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
class Player;
|
2023-01-07 05:17:05 +00:00
|
|
|
class EntityInfo;
|
|
|
|
class User;
|
2021-12-05 17:54:36 +00:00
|
|
|
class Spawner;
|
|
|
|
class ScriptComponent;
|
|
|
|
class dpEntity;
|
2023-01-07 05:17:05 +00:00
|
|
|
class EntityTimer;
|
2021-12-05 17:54:36 +00:00
|
|
|
class Component;
|
2022-12-21 22:33:41 +00:00
|
|
|
class Item;
|
2021-12-05 17:54:36 +00:00
|
|
|
class Character;
|
2023-01-07 05:17:05 +00:00
|
|
|
class EntityCallbackTimer;
|
2023-06-15 09:28:27 +00:00
|
|
|
class LDFBaseData;
|
2023-06-17 02:53:22 +00:00
|
|
|
class BoxDimensions;
|
2023-02-10 08:29:53 +00:00
|
|
|
enum class eTriggerEventType;
|
2023-03-24 23:16:45 +00:00
|
|
|
enum class eGameMasterLevel : uint8_t;
|
2023-03-04 07:16:37 +00:00
|
|
|
enum class eReplicaComponentType : uint32_t;
|
2023-05-02 22:39:21 +00:00
|
|
|
enum class eReplicaPacketType : uint8_t;
|
|
|
|
enum class eCinematicEvent : uint32_t;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
/**
|
2023-06-09 08:04:42 +00:00
|
|
|
* An entity in the world.
|
|
|
|
* Entities are composed of components which define their behavior.
|
2021-12-05 17:54:36 +00:00
|
|
|
*/
|
2023-06-07 03:48:30 +00:00
|
|
|
|
2023-06-09 08:22:45 +00:00
|
|
|
using ComponentPtr = std::unique_ptr<Component>;
|
2023-06-10 06:02:28 +00:00
|
|
|
using ComponentWhitelist = std::vector<eReplicaComponentType>;
|
2023-06-10 07:14:20 +00:00
|
|
|
using TemplateComponents = std::vector<std::pair<eReplicaComponentType, uint32_t>>;
|
2023-06-09 08:04:42 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
class Entity {
|
|
|
|
public:
|
|
|
|
explicit Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity = nullptr);
|
|
|
|
virtual ~Entity();
|
|
|
|
|
2023-06-10 11:46:48 +00:00
|
|
|
void ApplyComponentWhitelist(TemplateComponents& components) const;
|
2023-06-10 06:02:28 +00:00
|
|
|
static const std::vector<ComponentWhitelist>& GetComponentWhitelists() { return m_ComponentWhitelists; }
|
2023-06-10 11:46:48 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
/**
|
|
|
|
* Functions used for creating and setting up an Entity.
|
|
|
|
*/
|
|
|
|
void Initialize();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* There are some very very edge cases we need to take care of with what components
|
|
|
|
* are kept and removed. Here is where we take care of those cases.
|
|
|
|
*/
|
2023-06-10 11:46:48 +00:00
|
|
|
void ApplyComponentBlacklist(TemplateComponents& components) const;
|
|
|
|
|
|
|
|
// For adding and removing components based on LDF keys
|
|
|
|
void ApplyComponentConfig(TemplateComponents& components) const;
|
2023-06-12 08:29:43 +00:00
|
|
|
|
|
|
|
// Paths have several components they could add. This function will add them.
|
|
|
|
void AddPathComponent(TemplateComponents& components) const;
|
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
/**
|
|
|
|
* Determines if we should ghost an Entity or not.
|
|
|
|
* Ghosting means we no longer serialize it to a specific player because it is out of range.
|
|
|
|
*/
|
2023-06-12 08:29:43 +00:00
|
|
|
void IsGhosted();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
bool operator==(const Entity& other) const;
|
|
|
|
bool operator!=(const Entity& other) const;
|
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
// General Entity info
|
2023-06-09 08:04:42 +00:00
|
|
|
const LWOOBJID GetObjectID() const { return m_ObjectID; }
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
const LOT GetLOT() const { return m_TemplateID; }
|
|
|
|
|
|
|
|
Entity* GetParentEntity() const { return m_ParentEntity; }
|
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
const bool GetIsGhostingCandidate() const { return m_IsGhostingCandidate; }
|
|
|
|
|
|
|
|
const float GetDefaultScale() const { return m_Scale; }
|
|
|
|
|
|
|
|
Entity* GetOwner() const;
|
|
|
|
void SetOwnerOverride(const LWOOBJID& value) { m_OwnerOverride = value; };
|
2023-06-17 09:39:33 +00:00
|
|
|
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
|
|
|
std::vector<LWOOBJID>& GetTargetsInPhantom();
|
|
|
|
const std::unordered_map<eReplicaComponentType, ComponentPtr>& GetComponents() { return m_Components; }
|
2023-06-16 08:56:02 +00:00
|
|
|
|
|
|
|
// Position related info
|
|
|
|
const NiPoint3& GetDefaultPosition() const { return m_DefaultPosition; };
|
|
|
|
|
|
|
|
const NiQuaternion& GetDefaultRotation() const { return m_DefaultRotation; };
|
|
|
|
|
|
|
|
const NiPoint3& GetPosition() const;
|
|
|
|
void SetPosition(const NiPoint3& position);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
const NiQuaternion& GetRotation() const;
|
|
|
|
void SetRotation(const NiQuaternion& rotation);
|
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
virtual NiPoint3 GetRespawnPosition() const { return NiPoint3::ZERO; }
|
|
|
|
virtual NiQuaternion GetRespawnRotation() const { return NiQuaternion::IDENTITY; }
|
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
// Spawner related info
|
2021-12-05 17:54:36 +00:00
|
|
|
Spawner* GetSpawner() const { return m_Spawner; }
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
LWOOBJID GetSpawnerID() const { return m_SpawnerID; }
|
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
const std::vector<std::string>& GetGroups() { return m_Groups; };
|
|
|
|
void SetGroups(const std::vector<std::string>& value) { m_Groups = value; }
|
2023-06-17 09:39:33 +00:00
|
|
|
void AddGroup(const std::string& group);
|
2023-06-16 08:56:02 +00:00
|
|
|
|
|
|
|
// LDF related into
|
2021-12-05 17:54:36 +00:00
|
|
|
const std::vector<LDFBaseData*>& GetSettings() const { return m_Settings; }
|
|
|
|
|
|
|
|
const std::vector<LDFBaseData*>& GetNetworkSettings() const { return m_NetworkSettings; }
|
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
// Networking related info
|
2023-06-09 08:04:42 +00:00
|
|
|
const int8_t GetObservers() const { return m_Observers; }
|
|
|
|
void SetObservers(const int8_t value);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
const uint16_t GetNetworkId() const { return m_NetworkID; }
|
2023-06-16 08:01:13 +00:00
|
|
|
void SetNetworkId(const uint16_t id) { m_NetworkID = id; }
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
// Player extended info
|
|
|
|
virtual User* GetParentUser() const { return nullptr; };
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
virtual const SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
virtual void SetRespawnPosition(const NiPoint3& position) {};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
virtual void SetRespawnRotation(const NiQuaternion& rotation) {};
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
virtual void SetSystemAddress(const SystemAddress& value) {};
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
eGameMasterLevel GetGMLevel() const { return m_GMLevel; }
|
|
|
|
void SetGMLevel(const eGameMasterLevel value);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; }
|
|
|
|
void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; }
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
Character* GetCharacter() const { return m_Character; }
|
|
|
|
void SetCharacter(Character* value) { m_Character = value; }
|
|
|
|
// End info
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
// If you are calling this, then calling GetComponent<T>, just call GetComponent<T> and check for nullptr.
|
|
|
|
bool HasComponent(const eReplicaComponentType componentId) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Event management
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
2023-06-16 08:56:02 +00:00
|
|
|
* Call these when you want to observe events. Observed events should follow the following naming convention
|
|
|
|
* in scripts Notify<NotificationName>. For example, if you want to observe the "OnDeath" event, you would call
|
|
|
|
* entity->Subscribe(script, "OnDeath"). Then in your script, you would have a function called NotifyOnDeath.
|
2021-12-05 17:54:36 +00:00
|
|
|
*/
|
2023-06-16 08:56:02 +00:00
|
|
|
void Subscribe(CppScripts::Script* scriptToAdd, const std::string& notificationName);
|
2022-12-21 22:33:41 +00:00
|
|
|
|
2023-06-16 08:56:02 +00:00
|
|
|
/**
|
|
|
|
* Call this when you want to stop observing an event. The scriptToRemove will
|
|
|
|
* no longer be notified of notificationName events
|
|
|
|
*/
|
|
|
|
void Unsubscribe(CppScripts::Script* scriptToRemove, const std::string& notificationName);
|
2023-06-17 02:53:22 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Proximity radius management
|
2023-06-17 02:53:22 +00:00
|
|
|
void AddProximityRadius(const float proxRadius, const std::string& name);
|
|
|
|
void AddProximityRadius(const BoxDimensions& dimensions, const std::string& name);
|
|
|
|
|
|
|
|
// Technically this is the live accrate API, however what it does is not setting the proximity radius, but rather
|
|
|
|
// adding a new one to the list of proximity radii. For that reason we will have the old API just call AddProximityRadius.
|
|
|
|
inline void SetProximityRadius(const float proxRadius, const std::string& name) { this->AddProximityRadius(proxRadius, name); }
|
|
|
|
inline void SetProximityRadius(const BoxDimensions& dimensions, const std::string& name) { this->AddProximityRadius(dimensions, name); }
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
void AddRebuildCompleteCallback(const std::function<void(Entity* user)>& callback) const;
|
|
|
|
void AddCollisionPhantomCallback(const std::function<void(Entity* target)>& callback) { m_PhantomCollisionCallbacks.push_back(callback); };
|
|
|
|
void AddDieCallback(const std::function<void()>& callback) { m_DieCallbacks.push_back(callback); };
|
|
|
|
void TriggerEvent(const eTriggerEventType event, Entity* optionalTarget = nullptr);
|
|
|
|
void NotifyObject(Entity* sender, const std::u16string& name, const int32_t param1 = 0, const int32_t param2 = 0);
|
|
|
|
|
|
|
|
// Parent Child management
|
2021-12-05 17:54:36 +00:00
|
|
|
void AddChild(Entity* child);
|
2022-06-17 00:50:33 +00:00
|
|
|
void RemoveChild(Entity* child);
|
2022-07-17 04:39:13 +00:00
|
|
|
void RemoveParent();
|
2023-06-17 09:39:33 +00:00
|
|
|
|
|
|
|
// Timer management
|
2023-06-09 08:04:42 +00:00
|
|
|
void AddTimer(const std::string& name, const float time);
|
|
|
|
void AddCallbackTimer(const float time, const std::function<void()>& callback);
|
2021-12-05 17:54:36 +00:00
|
|
|
bool HasTimer(const std::string& name);
|
|
|
|
void CancelCallbackTimers();
|
|
|
|
void CancelAllTimers();
|
|
|
|
void CancelTimer(const std::string& name);
|
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Serialization
|
2023-06-09 08:04:42 +00:00
|
|
|
void WriteBaseReplicaData(RakNet::BitStream* outBitStream, const eReplicaPacketType packetType);
|
|
|
|
void WriteComponents(RakNet::BitStream* outBitStream, const eReplicaPacketType packetType);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Scripting
|
|
|
|
// Get the script attached to this entity. Will never return nullptr.
|
|
|
|
CppScripts::Script* GetScript() const;
|
2023-06-09 08:04:42 +00:00
|
|
|
void OnCollisionProximity(const LWOOBJID otherEntity, const std::string& proxName, const std::string& status);
|
|
|
|
void OnCollisionPhantom(const LWOOBJID otherEntity);
|
|
|
|
void OnCollisionLeavePhantom(const LWOOBJID otherEntity);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
void OnFireEventServerSide(Entity* sender, const std::string args, const int32_t param1 = -1, const int32_t param2 = -1, const int32_t param3 = -1);
|
2021-12-05 17:54:36 +00:00
|
|
|
void OnActivityStateChangeRequest(const LWOOBJID senderID, const int32_t value1, const int32_t value2,
|
|
|
|
const std::u16string& stringValue);
|
2023-06-09 08:04:42 +00:00
|
|
|
void OnCinematicUpdate(Entity* self, Entity* sender, const eCinematicEvent event, const std::u16string& pathName,
|
|
|
|
const float pathTime, const float totalTime, const int32_t waypoint);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
void OnEmoteReceived(const int32_t emote, Entity* target);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
void OnUse(Entity* originator);
|
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
void OnHitOrHealResult(Entity* attacker, const int32_t damage);
|
2021-12-05 17:54:36 +00:00
|
|
|
void OnHit(Entity* attacker);
|
|
|
|
|
|
|
|
void OnZonePropertyEditBegin();
|
|
|
|
void OnZonePropertyEditEnd();
|
|
|
|
void OnZonePropertyModelEquipped();
|
|
|
|
void OnZonePropertyModelPlaced(Entity* player);
|
|
|
|
void OnZonePropertyModelPickedUp(Entity* player);
|
|
|
|
void OnZonePropertyModelRemoved(Entity* player);
|
|
|
|
void OnZonePropertyModelRemovedWhileEquipped(Entity* player);
|
|
|
|
void OnZonePropertyModelRotated(Entity* player);
|
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
void OnMessageBoxResponse(Entity* sender, const int32_t button, const std::u16string& identifier, const std::u16string& userData);
|
|
|
|
void OnChoiceBoxResponse(Entity* sender, const int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier);
|
|
|
|
void RequestActivityExit(Entity* sender, const LWOOBJID& player, const bool canceled);
|
2023-06-17 09:39:33 +00:00
|
|
|
// End scripting
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Cleanup functions
|
2021-12-05 17:54:36 +00:00
|
|
|
void Smash(const LWOOBJID source = LWOOBJID_EMPTY, const eKillType killType = eKillType::VIOLENT, const std::u16string& deathType = u"");
|
2023-06-17 09:39:33 +00:00
|
|
|
// Odds are you do not need to call this. Call Smash instead.
|
2021-12-05 17:54:36 +00:00
|
|
|
void Kill(Entity* murderer = nullptr);
|
2023-06-17 09:39:33 +00:00
|
|
|
|
|
|
|
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
|
|
|
|
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
void Resurrect();
|
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Loot management (should be moved to Player. Not every Entity needs this.)
|
2021-12-05 17:54:36 +00:00
|
|
|
void AddLootItem(const Loot::Info& info);
|
|
|
|
void PickupItem(const LWOOBJID& objectID);
|
|
|
|
|
2023-06-16 08:01:13 +00:00
|
|
|
bool CanPickupCoins(const uint64_t& count) const;
|
|
|
|
void PickupCoins(const uint64_t& count);
|
2023-06-09 08:04:42 +00:00
|
|
|
void RegisterCoinDrop(const uint64_t& count);
|
2021-12-11 13:21:00 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// State checkers
|
2021-12-05 17:54:36 +00:00
|
|
|
void Sleep();
|
|
|
|
void Wake();
|
|
|
|
bool IsSleeping() const;
|
2023-06-17 09:39:33 +00:00
|
|
|
bool IsDead() const;
|
|
|
|
bool IsPlayer() const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// Update
|
|
|
|
void UpdateXMLDoc(tinyxml2::XMLDocument* doc);
|
|
|
|
void Update(float deltaTime);
|
2023-06-09 08:04:42 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
//Retroactively corrects the model vault size due to incorrect initialization in a previous patch.
|
2022-04-13 08:49:55 +00:00
|
|
|
void RetroactiveVaultSize();
|
2023-06-17 09:39:33 +00:00
|
|
|
void ResetFlags();
|
|
|
|
|
|
|
|
// LDF Setting accessors
|
2023-06-16 08:01:13 +00:00
|
|
|
bool GetBoolean(const std::u16string& name) const { return GetVar<bool>(name); };
|
|
|
|
int32_t GetI32(const std::u16string& name) const { return GetVar<int32_t>(name); };
|
|
|
|
int64_t GetI64(const std::u16string& name) const { return GetVar<int64_t>(name); };
|
2021-12-05 17:54:36 +00:00
|
|
|
bool HasVar(const std::u16string& name) const;
|
2023-06-09 08:04:42 +00:00
|
|
|
LDFBaseData* GetVarData(const std::u16string& name) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
/**
|
|
|
|
* Get the LDF value and convert it to a string.
|
|
|
|
*/
|
|
|
|
std::string GetVarAsString(const std::u16string& name) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-17 09:39:33 +00:00
|
|
|
// LDF Setting assignment shorthands
|
|
|
|
void SetBoolean(const std::u16string& name, bool value) { SetVar<bool>(name, value); }
|
|
|
|
void SetI32(const std::u16string& name, int32_t value) { SetVar<int32_t>(name, value); };
|
|
|
|
void SetI64(const std::u16string& name, int64_t value) { SetVar<int64_t>(name, value); };
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
// Template declarations
|
2021-12-05 17:54:36 +00:00
|
|
|
template<typename T>
|
2023-06-09 08:04:42 +00:00
|
|
|
const T& GetVar(const std::u16string& name) const;
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T GetVarAs(const std::u16string& name) const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
template<typename T>
|
2023-06-09 08:04:42 +00:00
|
|
|
void SetVar(const std::u16string& name, const T& value);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T GetNetworkVar(const std::u16string& name);
|
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
void SendNetworkVar(const std::string& data, const SystemAddress& sysAddr);
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
template<typename T>
|
2023-06-09 08:04:42 +00:00
|
|
|
void SetNetworkVar(const std::u16string& name, const T& value, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
template<typename T>
|
|
|
|
void SetNetworkVar(const std::u16string& name, const std::vector<T>& value, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
2021-12-05 17:54:36 +00:00
|
|
|
/**
|
2023-06-09 08:04:42 +00:00
|
|
|
* @brief Get a non-owning reference to a component
|
|
|
|
*
|
|
|
|
* @tparam Cmpt The component to get a non-owning reference of
|
|
|
|
* @return Cmpt* The non-owning pointer to the component
|
2021-12-05 17:54:36 +00:00
|
|
|
*/
|
2023-06-09 08:04:42 +00:00
|
|
|
template<typename Cmpt>
|
|
|
|
Cmpt* GetComponent() const;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
/**
|
|
|
|
* @brief Adds a component to this Entity.
|
|
|
|
*
|
|
|
|
* @tparam Cmpt The component to create
|
|
|
|
* @tparam ConstructorValues The constructor values to forward to the component
|
|
|
|
* @param arguments The constructor values to forward to the component
|
|
|
|
* @return Cmpt* A non-owning pointer to the created component,
|
|
|
|
* or a non-owning pointer to the existing component if the component already existed.
|
2021-12-05 17:54:36 +00:00
|
|
|
*/
|
2023-06-09 08:04:42 +00:00
|
|
|
template<typename Cmpt, typename...ConstructorValues>
|
|
|
|
Cmpt* AddComponent(ConstructorValues... arguments);
|
2023-06-07 07:23:50 +00:00
|
|
|
|
2023-06-11 10:06:18 +00:00
|
|
|
/**
|
|
|
|
* @brief Removes a component from this Entity.
|
|
|
|
*/
|
|
|
|
template<typename Cmpt>
|
|
|
|
void RemoveComponent();
|
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
protected:
|
|
|
|
LWOOBJID m_ObjectID;
|
2023-06-18 01:41:51 +00:00
|
|
|
LWOOBJID m_SpawnerID;
|
|
|
|
LWOOBJID m_OwnerOverride;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-18 01:41:51 +00:00
|
|
|
uint32_t m_SpawnerNodeID;
|
2021-12-05 17:54:36 +00:00
|
|
|
LOT m_TemplateID;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
NiPoint3 m_DefaultPosition;
|
|
|
|
NiQuaternion m_DefaultRotation;
|
2023-06-18 01:41:51 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
float m_Scale;
|
2023-06-18 01:41:51 +00:00
|
|
|
int8_t m_Observers;
|
|
|
|
eGameMasterLevel m_GMLevel;
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2023-06-18 01:41:51 +00:00
|
|
|
Entity* m_ParentEntity; //For spawners and the like
|
|
|
|
Entity* m_ScheduleKiller;
|
2021-12-05 17:54:36 +00:00
|
|
|
Spawner* m_Spawner;
|
2023-06-18 01:41:51 +00:00
|
|
|
Character* m_Character;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
bool m_HasSpawnerNodeID;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-18 01:41:51 +00:00
|
|
|
bool m_ShouldDestroyAfterUpdate;
|
|
|
|
bool m_PlayerIsReadyForUpdates;
|
|
|
|
bool m_IsGhostingCandidate;
|
|
|
|
bool m_IsParentChildDirty;
|
2021-12-05 17:54:36 +00:00
|
|
|
uint16_t m_NetworkID;
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-06-07 03:48:30 +00:00
|
|
|
std::unordered_map<eReplicaComponentType, ComponentPtr> m_Components;
|
2023-06-15 06:16:31 +00:00
|
|
|
std::vector<std::unique_ptr<EntityTimer>> m_Timers;
|
|
|
|
std::vector<std::unique_ptr<EntityTimer>> m_PendingTimers;
|
|
|
|
std::vector<std::unique_ptr<EntityCallbackTimer>> m_CallbackTimers;
|
2023-06-18 01:41:51 +00:00
|
|
|
std::vector<LDFBaseData*> m_Settings;
|
|
|
|
std::vector<LDFBaseData*> m_NetworkSettings;
|
|
|
|
std::vector<Entity*> m_ChildEntities;
|
|
|
|
std::vector<std::string> m_Groups;
|
|
|
|
std::vector<std::function<void()>> m_DieCallbacks;
|
|
|
|
std::vector<std::function<void(Entity*)>> m_PhantomCollisionCallbacks;
|
2021-12-05 17:54:36 +00:00
|
|
|
std::vector<LWOOBJID> m_TargetsInPhantom;
|
2023-06-10 06:02:28 +00:00
|
|
|
|
|
|
|
static const std::vector<ComponentWhitelist> m_ComponentWhitelists;
|
2023-07-07 19:13:26 +00:00
|
|
|
static const std::array<eReplicaComponentType, 80> m_ComponentOrder;
|
2021-12-05 17:54:36 +00:00
|
|
|
};
|
|
|
|
|
2023-06-09 08:04:42 +00:00
|
|
|
#include "Entity.tcc"
|
2023-06-07 07:23:50 +00:00
|
|
|
|
|
|
|
#endif //!__ENTITY__H__
|