mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-26 15:33:34 +00:00
holy mother of const
Use const everywhere that makes sense return const variables when it makes sense const functions and variables again, where it makes sense No raw access and modifications to protected members Move template definitions to tcc file idk how I feel about this one
This commit is contained in:
parent
d11e2db887
commit
ec00f5fd9d
@ -10,7 +10,7 @@ trim_trailing_whitespace=true
|
||||
end_of_line=lf
|
||||
insert_final_newline=true
|
||||
|
||||
[*.{c++,cc,cpp,cxx,h,h++,hh,hpp,hxx,inl,ipp,tlh,tli}]
|
||||
[*.{c++,cc,cpp,cxx,h,h++,hh,hpp,hxx,inl,ipp,tlh,tli,tcc,tpp}]
|
||||
|
||||
vc_generate_documentation_comments=doxygen_slash_star
|
||||
|
||||
|
@ -95,6 +95,7 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity)
|
||||
m_GMLevel = eGameMasterLevel::CIVILIAN;
|
||||
m_CollectibleID = 0;
|
||||
m_NetworkID = 0;
|
||||
m_Observers = 0;
|
||||
m_Groups = {};
|
||||
m_OwnerOverride = LWOOBJID_EMPTY;
|
||||
m_Timers = {};
|
||||
@ -105,6 +106,9 @@ Entity::Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity)
|
||||
m_DieCallbacks = {};
|
||||
m_PhantomCollisionCallbacks = {};
|
||||
m_IsParentChildDirty = true;
|
||||
m_IsGhostingCandidate = false;
|
||||
m_PlayerIsReadyForUpdates = false;
|
||||
m_ShouldDestroyAfterUpdate = false;
|
||||
|
||||
m_Settings = info.settings;
|
||||
m_NetworkSettings = info.networkSettings;
|
||||
@ -382,7 +386,7 @@ bool Entity::operator==(const Entity& other) const {
|
||||
}
|
||||
|
||||
bool Entity::operator!=(const Entity& other) const {
|
||||
return other.m_ObjectID != m_ObjectID;
|
||||
return !(other.m_ObjectID == m_ObjectID);
|
||||
}
|
||||
|
||||
User* Entity::GetParentUser() const {
|
||||
@ -393,27 +397,22 @@ User* Entity::GetParentUser() const {
|
||||
return static_cast<const Player*>(this)->GetParentUser();
|
||||
}
|
||||
|
||||
const ComponentPtr Entity::GetComponent(eReplicaComponentType componentID) const {
|
||||
const auto& index = m_Components.find(componentID);
|
||||
return index != m_Components.end() ? index->second : nullptr;
|
||||
}
|
||||
|
||||
bool Entity::HasComponent(const eReplicaComponentType componentId) const {
|
||||
return m_Components.find(componentId) != m_Components.end();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ScriptComponent>> Entity::GetScriptComponents() {
|
||||
std::vector<std::shared_ptr<ScriptComponent>> comps;
|
||||
std::vector<ScriptComponent*> Entity::GetScriptComponents() {
|
||||
std::vector<ScriptComponent*> comps;
|
||||
for (const auto&[componentType, component] : m_Components) {
|
||||
if (componentType == eReplicaComponentType::SCRIPT) {
|
||||
comps.push_back(std::dynamic_pointer_cast<ScriptComponent>(component));
|
||||
comps.push_back(dynamic_cast<ScriptComponent*>(component.get()));
|
||||
}
|
||||
}
|
||||
|
||||
return comps;
|
||||
}
|
||||
|
||||
void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) {
|
||||
void Entity::Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) {
|
||||
if (notificationName == "HitOrHealResult" || notificationName == "Hit") {
|
||||
auto destroyableComponent = GetComponent<DestroyableComponent>();
|
||||
if (!destroyableComponent) return;
|
||||
@ -421,7 +420,7 @@ void Entity::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, co
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName) {
|
||||
void Entity::Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName) {
|
||||
if (notificationName == "HitOrHealResult" || notificationName == "Hit") {
|
||||
auto destroyableComponent = GetComponent<DestroyableComponent>();
|
||||
if (!destroyableComponent) return;
|
||||
@ -429,12 +428,12 @@ void Entity::Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationNa
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::SetProximityRadius(float proxRadius, std::string name) {
|
||||
void Entity::SetProximityRadius(const float proxRadius, const std::string& name) {
|
||||
auto proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
|
||||
if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(proxRadius, name);
|
||||
}
|
||||
|
||||
void Entity::SetProximityRadius(dpEntity* entity, std::string name) {
|
||||
void Entity::SetProximityRadius(dpEntity* entity, const std::string& name) {
|
||||
auto proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
|
||||
if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(entity, name);
|
||||
}
|
||||
@ -860,7 +859,7 @@ void Entity::OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16s
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled) {
|
||||
void Entity::RequestActivityExit(Entity* sender, const LWOOBJID& player, const bool canceled) {
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
script->OnRequestActivityExit(sender, player, canceled);
|
||||
}
|
||||
@ -1014,7 +1013,7 @@ void Entity::PickupItem(const LWOOBJID& objectID) {
|
||||
droppedLoot.erase(objectID);
|
||||
}
|
||||
|
||||
bool Entity::CanPickupCoins(uint64_t count) {
|
||||
bool Entity::CanPickupCoins(const uint64_t& count) {
|
||||
if (!IsPlayer()) return false;
|
||||
auto* player = static_cast<Player*>(this);
|
||||
auto droppedCoins = player->GetDroppedCoins();
|
||||
@ -1026,7 +1025,7 @@ bool Entity::CanPickupCoins(uint64_t count) {
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::RegisterCoinDrop(uint64_t count) {
|
||||
void Entity::RegisterCoinDrop(const uint64_t& count) {
|
||||
if (!IsPlayer()) return;
|
||||
auto* player = static_cast<Player*>(this);
|
||||
auto droppedCoins = player->GetDroppedCoins();
|
||||
@ -1056,12 +1055,12 @@ void Entity::RemoveParent() {
|
||||
this->m_ParentEntity = nullptr;
|
||||
}
|
||||
|
||||
void Entity::AddTimer(std::string name, float time) {
|
||||
void Entity::AddTimer(const std::string& name, float time) {
|
||||
EntityTimer* timer = new EntityTimer(name, time);
|
||||
m_PendingTimers.push_back(timer);
|
||||
}
|
||||
|
||||
void Entity::AddCallbackTimer(float time, std::function<void()> callback) {
|
||||
void Entity::AddCallbackTimer(const float time, const std::function<void()>& callback) {
|
||||
EntityCallbackTimer* timer = new EntityCallbackTimer(time, callback);
|
||||
m_CallbackTimers.push_back(timer);
|
||||
}
|
||||
@ -1148,22 +1147,10 @@ const NiQuaternion& Entity::GetDefaultRotation() const {
|
||||
return m_DefaultRotation;
|
||||
}
|
||||
|
||||
float Entity::GetDefaultScale() const {
|
||||
return m_Scale;
|
||||
}
|
||||
|
||||
void Entity::SetOwnerOverride(const LWOOBJID value) {
|
||||
void Entity::SetOwnerOverride(const LWOOBJID& value) {
|
||||
m_OwnerOverride = value;
|
||||
}
|
||||
|
||||
bool Entity::GetIsGhostingCandidate() const {
|
||||
return m_IsGhostingCandidate;
|
||||
}
|
||||
|
||||
int8_t Entity::GetObservers() const {
|
||||
return m_Observers;
|
||||
}
|
||||
|
||||
void Entity::SetObservers(int8_t value) {
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
@ -1251,7 +1238,7 @@ const NiQuaternion& Entity::GetRotation() const {
|
||||
return NiQuaternion::IDENTITY;
|
||||
}
|
||||
|
||||
void Entity::SetPosition(NiPoint3 position) {
|
||||
void Entity::SetPosition(const NiPoint3& position) {
|
||||
auto controllable = GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllable != nullptr) {
|
||||
@ -1279,7 +1266,7 @@ void Entity::SetPosition(NiPoint3 position) {
|
||||
EntityManager::Instance()->SerializeEntity(this);
|
||||
}
|
||||
|
||||
void Entity::SetRotation(NiQuaternion rotation) {
|
||||
void Entity::SetRotation(const NiQuaternion& rotation) {
|
||||
auto controllable = GetComponent<ControllablePhysicsComponent>();
|
||||
|
||||
if (controllable != nullptr) {
|
||||
@ -1341,10 +1328,6 @@ bool Entity::HasVar(const std::u16string& name) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t Entity::GetNetworkId() const {
|
||||
return m_NetworkID;
|
||||
}
|
||||
|
||||
void Entity::SetNetworkId(const uint16_t id) {
|
||||
m_NetworkID = id;
|
||||
}
|
||||
@ -1406,7 +1389,7 @@ void Entity::Resurrect() {
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::AddToGroup(const std::string& group) {
|
||||
void Entity::AddToGroups(const std::string& group) {
|
||||
if (std::find(m_Groups.begin(), m_Groups.end(), group) == m_Groups.end()) {
|
||||
m_Groups.push_back(group);
|
||||
}
|
||||
|
361
dGame/Entity.h
361
dGame/Entity.h
@ -5,9 +5,9 @@
|
||||
#include <functional>
|
||||
#include <typeinfo>
|
||||
#include <type_traits>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "NiPoint3.h"
|
||||
#include "NiQuaternion.h"
|
||||
@ -44,10 +44,12 @@ namespace CppScripts {
|
||||
};
|
||||
|
||||
/**
|
||||
* An entity in the world. Has multiple components.
|
||||
* An entity in the world.
|
||||
* Entities are composed of components which define their behavior.
|
||||
*/
|
||||
|
||||
using ComponentPtr = std::shared_ptr<Component>;
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
explicit Entity(const LWOOBJID& objectID, EntityInfo info, Entity* parentEntity = nullptr);
|
||||
@ -61,20 +63,22 @@ public:
|
||||
/**
|
||||
* Getters
|
||||
*/
|
||||
Character* GetCharacter() const { return m_Character; }
|
||||
void SetCharacter(Character* value) { m_Character = value; }
|
||||
|
||||
const LWOOBJID& GetObjectID() const { return m_ObjectID; }
|
||||
const LWOOBJID GetObjectID() const { return m_ObjectID; }
|
||||
|
||||
const LOT GetLOT() const { return m_TemplateID; }
|
||||
|
||||
Character* GetCharacter() const { return m_Character; }
|
||||
|
||||
eGameMasterLevel GetGMLevel() const { return m_GMLevel; }
|
||||
void SetGMLevel(const eGameMasterLevel value);
|
||||
|
||||
uint8_t GetCollectibleID() const { return uint8_t(m_CollectibleID); }
|
||||
const uint32_t GetCollectibleID() const { return m_CollectibleID; }
|
||||
|
||||
Entity* GetParentEntity() const { return m_ParentEntity; }
|
||||
|
||||
std::vector<std::string>& GetGroups() { return m_Groups; };
|
||||
const std::vector<std::string>& GetGroups() { return m_Groups; };
|
||||
void SetGroups(const std::vector<std::string>& value) { m_Groups = value; }
|
||||
|
||||
Spawner* GetSpawner() const { return m_Spawner; }
|
||||
|
||||
@ -87,113 +91,90 @@ public:
|
||||
bool GetIsDead() const;
|
||||
|
||||
bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; }
|
||||
void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; }
|
||||
|
||||
bool GetIsGhostingCandidate() const;
|
||||
const bool GetIsGhostingCandidate() const { return m_IsGhostingCandidate; }
|
||||
|
||||
int8_t GetObservers() const;
|
||||
const int8_t GetObservers() const { return m_Observers; }
|
||||
void SetObservers(const int8_t value);
|
||||
|
||||
uint16_t GetNetworkId() const;
|
||||
const uint16_t GetNetworkId() const { return m_NetworkID; }
|
||||
void SetNetworkId(const uint16_t id);
|
||||
|
||||
Entity* GetOwner() const;
|
||||
void SetOwnerOverride(const LWOOBJID& value);
|
||||
|
||||
const NiPoint3& GetDefaultPosition() const;
|
||||
|
||||
const NiQuaternion& GetDefaultRotation() const;
|
||||
|
||||
float GetDefaultScale() const;
|
||||
const float GetDefaultScale() const { return m_Scale; }
|
||||
|
||||
const NiPoint3& GetPosition() const;
|
||||
void SetPosition(const NiPoint3& position);
|
||||
|
||||
const NiQuaternion& GetRotation() const;
|
||||
void SetRotation(const NiQuaternion& rotation);
|
||||
|
||||
virtual User* GetParentUser() const;
|
||||
|
||||
virtual SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
||||
virtual const SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; };
|
||||
|
||||
/**
|
||||
* Setters
|
||||
*/
|
||||
virtual void SetRespawnPos(const NiPoint3& position) {};
|
||||
|
||||
void SetCharacter(Character* value) { m_Character = value; }
|
||||
|
||||
void SetGMLevel(eGameMasterLevel value);
|
||||
|
||||
void SetOwnerOverride(LWOOBJID value);
|
||||
|
||||
void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; }
|
||||
|
||||
void SetObservers(int8_t value);
|
||||
|
||||
void SetNetworkId(uint16_t id);
|
||||
|
||||
void SetPosition(NiPoint3 position);
|
||||
|
||||
void SetRotation(NiQuaternion rotation);
|
||||
|
||||
virtual void SetRespawnPos(NiPoint3 position) {}
|
||||
|
||||
virtual void SetRespawnRot(NiQuaternion rotation) {}
|
||||
virtual void SetRespawnRot(const NiQuaternion& rotation) {};
|
||||
|
||||
virtual void SetSystemAddress(const SystemAddress& value) {};
|
||||
|
||||
/**
|
||||
* Component management
|
||||
*/
|
||||
bool HasComponent(const eReplicaComponentType componentId) const;
|
||||
|
||||
const ComponentPtr GetComponent(eReplicaComponentType componentID) const;
|
||||
std::vector<ScriptComponent*> GetScriptComponents();
|
||||
|
||||
template<typename T>
|
||||
std::shared_ptr<T> GetComponent() const;
|
||||
void Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName);
|
||||
void Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName);
|
||||
|
||||
bool HasComponent(eReplicaComponentType componentId) const;
|
||||
|
||||
template<typename Cmpt, typename...ConstructorValues>
|
||||
std::shared_ptr<Cmpt> AddComponent(ConstructorValues... arguments);
|
||||
|
||||
std::vector<std::shared_ptr<ScriptComponent>> GetScriptComponents();
|
||||
|
||||
void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName);
|
||||
void Unsubscribe(LWOOBJID scriptObjId, const std::string& notificationName);
|
||||
|
||||
void SetProximityRadius(float proxRadius, std::string name);
|
||||
void SetProximityRadius(dpEntity* entity, std::string name);
|
||||
void SetProximityRadius(const float proxRadius, const std::string& name);
|
||||
void SetProximityRadius(dpEntity* entity, const std::string& name);
|
||||
|
||||
void AddChild(Entity* child);
|
||||
void RemoveChild(Entity* child);
|
||||
void RemoveParent();
|
||||
void AddTimer(std::string name, float time);
|
||||
void AddCallbackTimer(float time, std::function<void()> callback);
|
||||
void AddTimer(const std::string& name, const float time);
|
||||
void AddCallbackTimer(const float time, const std::function<void()>& callback);
|
||||
bool HasTimer(const std::string& name);
|
||||
void CancelCallbackTimers();
|
||||
void CancelAllTimers();
|
||||
void CancelTimer(const std::string& name);
|
||||
|
||||
void AddToGroup(const std::string& group);
|
||||
void AddToGroups(const std::string& group);
|
||||
bool IsPlayer() const;
|
||||
|
||||
void WriteBaseReplicaData(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
|
||||
void WriteComponents(RakNet::BitStream* outBitStream, eReplicaPacketType packetType);
|
||||
void WriteBaseReplicaData(RakNet::BitStream* outBitStream, const eReplicaPacketType packetType);
|
||||
void WriteComponents(RakNet::BitStream* outBitStream, const eReplicaPacketType packetType);
|
||||
void ResetFlags();
|
||||
void UpdateXMLDoc(tinyxml2::XMLDocument* doc);
|
||||
void Update(float deltaTime);
|
||||
|
||||
// Events
|
||||
void OnCollisionProximity(LWOOBJID otherEntity, const std::string& proxName, const std::string& status);
|
||||
void OnCollisionPhantom(LWOOBJID otherEntity);
|
||||
void OnCollisionLeavePhantom(LWOOBJID otherEntity);
|
||||
void OnCollisionProximity(const LWOOBJID otherEntity, const std::string& proxName, const std::string& status);
|
||||
void OnCollisionPhantom(const LWOOBJID otherEntity);
|
||||
void OnCollisionLeavePhantom(const LWOOBJID otherEntity);
|
||||
|
||||
void OnFireEventServerSide(Entity* sender, std::string args, int32_t param1 = -1, int32_t param2 = -1, int32_t param3 = -1);
|
||||
void OnFireEventServerSide(Entity* sender, const std::string args, const int32_t param1 = -1, const int32_t param2 = -1, const int32_t param3 = -1);
|
||||
void OnActivityStateChangeRequest(const LWOOBJID senderID, const int32_t value1, const int32_t value2,
|
||||
const std::u16string& stringValue);
|
||||
void OnCinematicUpdate(Entity* self, Entity* sender, eCinematicEvent event, const std::u16string& pathName,
|
||||
float_t pathTime, float_t totalTime, int32_t waypoint);
|
||||
void OnCinematicUpdate(Entity* self, Entity* sender, const eCinematicEvent event, const std::u16string& pathName,
|
||||
const float pathTime, const float totalTime, const int32_t waypoint);
|
||||
|
||||
void NotifyObject(Entity* sender, const std::string& name, int32_t param1 = 0, int32_t param2 = 0);
|
||||
void OnEmoteReceived(int32_t emote, Entity* target);
|
||||
void NotifyObject(Entity* sender, const std::string& name, const int32_t param1 = 0, const int32_t param2 = 0);
|
||||
void OnEmoteReceived(const int32_t emote, Entity* target);
|
||||
|
||||
void OnUse(Entity* originator);
|
||||
|
||||
void OnHitOrHealResult(Entity* attacker, int32_t damage);
|
||||
void OnHitOrHealResult(Entity* attacker, const int32_t damage);
|
||||
void OnHit(Entity* attacker);
|
||||
|
||||
void OnZonePropertyEditBegin();
|
||||
@ -205,9 +186,9 @@ public:
|
||||
void OnZonePropertyModelRemovedWhileEquipped(Entity* player);
|
||||
void OnZonePropertyModelRotated(Entity* player);
|
||||
|
||||
void OnMessageBoxResponse(Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData);
|
||||
void OnChoiceBoxResponse(Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier);
|
||||
void RequestActivityExit(Entity* sender, LWOOBJID player, bool canceled);
|
||||
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);
|
||||
|
||||
void Smash(const LWOOBJID source = LWOOBJID_EMPTY, const eKillType killType = eKillType::VIOLENT, const std::u16string& deathType = u"");
|
||||
void Kill(Entity* murderer = nullptr);
|
||||
@ -219,11 +200,11 @@ public:
|
||||
void AddLootItem(const Loot::Info& info);
|
||||
void PickupItem(const LWOOBJID& objectID);
|
||||
|
||||
bool CanPickupCoins(uint64_t count);
|
||||
void RegisterCoinDrop(uint64_t count);
|
||||
bool CanPickupCoins(const uint64_t& count);
|
||||
void RegisterCoinDrop(const uint64_t& count);
|
||||
|
||||
void ScheduleKillAfterUpdate(Entity* murderer = nullptr);
|
||||
void TriggerEvent(eTriggerEventType event, Entity* optionalTarget = nullptr);
|
||||
void TriggerEvent(const eTriggerEventType event, Entity* optionalTarget = nullptr);
|
||||
void ScheduleDestructionAfterUpdate() { m_ShouldDestroyAfterUpdate = true; }
|
||||
|
||||
virtual NiPoint3 GetRespawnPosition() const { return NiPoint3::ZERO; }
|
||||
@ -236,10 +217,8 @@ public:
|
||||
/*
|
||||
* Utility
|
||||
*/
|
||||
/**
|
||||
* Retroactively corrects the model vault size due to incorrect initialization in a previous patch.
|
||||
*
|
||||
*/
|
||||
|
||||
//Retroactively corrects the model vault size due to incorrect initialization in a previous patch.
|
||||
void RetroactiveVaultSize();
|
||||
bool GetBoolean(const std::u16string& name) const;
|
||||
int32_t GetI32(const std::u16string& name) const;
|
||||
@ -251,29 +230,6 @@ public:
|
||||
|
||||
bool HasVar(const std::u16string& name) const;
|
||||
|
||||
template<typename T>
|
||||
const T& GetVar(const std::u16string& name) const;
|
||||
|
||||
template<typename T>
|
||||
void SetVar(const std::u16string& name, T value);
|
||||
|
||||
void SendNetworkVar(const std::string& data, const SystemAddress& sysAddr);
|
||||
|
||||
template<typename T>
|
||||
void SetNetworkVar(const std::u16string& name, T value, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
template<typename T>
|
||||
void SetNetworkVar(const std::u16string& name, std::vector<T> value, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
template<typename T>
|
||||
T GetNetworkVar(const std::u16string& name);
|
||||
|
||||
/**
|
||||
* Get the LDF value and cast it as T.
|
||||
*/
|
||||
template<typename T>
|
||||
T GetVarAs(const std::u16string& name) const;
|
||||
|
||||
/**
|
||||
* Get the LDF data.
|
||||
*/
|
||||
@ -291,7 +247,57 @@ public:
|
||||
|
||||
Entity* GetScheduledKiller() { return m_ScheduleKiller; }
|
||||
|
||||
std::unordered_map<eReplicaComponentType, ComponentPtr>& GetComponents() { return m_Components; }
|
||||
const std::unordered_map<eReplicaComponentType, ComponentPtr>& GetComponents() { return m_Components; }
|
||||
|
||||
// Template declarations
|
||||
template<typename T>
|
||||
const T& GetVar(const std::u16string& name) const;
|
||||
|
||||
template<typename T>
|
||||
T GetVarAs(const std::u16string& name) const;
|
||||
|
||||
template<typename T>
|
||||
void SetVar(const std::u16string& name, const T& value);
|
||||
|
||||
template<typename T>
|
||||
T GetNetworkVar(const std::u16string& name);
|
||||
|
||||
void SendNetworkVar(const std::string& data, const SystemAddress& sysAddr);
|
||||
|
||||
template<typename T>
|
||||
void SetNetworkVar(const std::u16string& name, const T& value, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
template<typename T>
|
||||
void SetNetworkVar(const std::u16string& name, const std::vector<T>& value, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
template<typename Cmpt>
|
||||
Cmpt* GetComponent() const;
|
||||
|
||||
/**
|
||||
* @brief Get an owning reference to a component.
|
||||
*
|
||||
* @tparam Cmpt The component to get a shared reference of
|
||||
* @return std::shared_ptr<Cmpt> The owning shared pointer
|
||||
*/
|
||||
template<typename Cmpt>
|
||||
std::shared_ptr<Cmpt> GetSharedComponent() const;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
template<typename Cmpt, typename...ConstructorValues>
|
||||
Cmpt* AddComponent(ConstructorValues... arguments);
|
||||
|
||||
protected:
|
||||
LWOOBJID m_ObjectID;
|
||||
@ -316,30 +322,30 @@ protected:
|
||||
Entity* m_ParentEntity; //For spawners and the like
|
||||
std::vector<Entity*> m_ChildEntities;
|
||||
eGameMasterLevel m_GMLevel;
|
||||
uint16_t m_CollectibleID;
|
||||
uint32_t m_CollectibleID;
|
||||
std::vector<std::string> m_Groups;
|
||||
uint16_t m_NetworkID;
|
||||
std::vector<std::function<void()>> m_DieCallbacks;
|
||||
std::vector<std::function<void(Entity* target)>> m_PhantomCollisionCallbacks;
|
||||
std::vector<std::function<void(Entity*)>> m_PhantomCollisionCallbacks;
|
||||
|
||||
std::unordered_map<eReplicaComponentType, ComponentPtr> m_Components;
|
||||
std::vector<EntityTimer*> m_Timers;
|
||||
std::vector<EntityTimer*> m_PendingTimers;
|
||||
std::vector<EntityCallbackTimer*> m_CallbackTimers;
|
||||
|
||||
bool m_ShouldDestroyAfterUpdate = false;
|
||||
bool m_ShouldDestroyAfterUpdate;
|
||||
|
||||
LWOOBJID m_OwnerOverride;
|
||||
|
||||
Entity* m_ScheduleKiller;
|
||||
|
||||
bool m_PlayerIsReadyForUpdates = false;
|
||||
bool m_PlayerIsReadyForUpdates;
|
||||
|
||||
bool m_IsGhostingCandidate = false;
|
||||
bool m_IsGhostingCandidate;
|
||||
|
||||
int8_t m_Observers = 0;
|
||||
int8_t m_Observers;
|
||||
|
||||
bool m_IsParentChildDirty = true;
|
||||
bool m_IsParentChildDirty;
|
||||
|
||||
/*
|
||||
* Collision
|
||||
@ -347,151 +353,6 @@ protected:
|
||||
std::vector<LWOOBJID> m_TargetsInPhantom;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::shared_ptr<T> Entity::GetComponent() const {
|
||||
return std::dynamic_pointer_cast<T>(GetComponent(T::ComponentType));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& Entity::GetVar(const std::u16string& name) const {
|
||||
auto* data = GetVarData(name);
|
||||
|
||||
if (data == nullptr) {
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||
|
||||
if (typed == nullptr) {
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
return typed->GetValue();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Entity::GetVarAs(const std::u16string& name) const {
|
||||
const auto data = GetVarAsString(name);
|
||||
|
||||
T value;
|
||||
|
||||
if (!GeneralUtils::TryParse(data, value)) {
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Entity::SetVar(const std::u16string& name, T value) {
|
||||
auto* data = GetVarData(name);
|
||||
|
||||
if (data == nullptr) {
|
||||
auto* data = new LDFData<T>(name, value);
|
||||
|
||||
m_Settings.push_back(data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||
|
||||
if (typed == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
typed->SetValue(value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Entity::SetNetworkVar(const std::u16string& name, T value, const SystemAddress& sysAddr) {
|
||||
LDFData<T>* newData = nullptr;
|
||||
|
||||
for (auto* data : m_NetworkSettings) {
|
||||
if (data->GetKey() != name)
|
||||
continue;
|
||||
|
||||
newData = dynamic_cast<LDFData<T>*>(data);
|
||||
if (newData != nullptr) {
|
||||
newData->SetValue(value);
|
||||
} else { // If we're changing types
|
||||
m_NetworkSettings.erase(
|
||||
std::remove(m_NetworkSettings.begin(), m_NetworkSettings.end(), data), m_NetworkSettings.end()
|
||||
);
|
||||
delete data;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (newData == nullptr) {
|
||||
newData = new LDFData<T>(name, value);
|
||||
}
|
||||
|
||||
m_NetworkSettings.push_back(newData);
|
||||
SendNetworkVar(newData->GetString(true), sysAddr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Entity::SetNetworkVar(const std::u16string& name, std::vector<T> values, const SystemAddress& sysAddr) {
|
||||
std::stringstream updates;
|
||||
auto index = 1;
|
||||
|
||||
for (const auto& value : values) {
|
||||
LDFData<T>* newData = nullptr;
|
||||
const auto& indexedName = name + u"." + GeneralUtils::to_u16string(index);
|
||||
|
||||
for (auto* data : m_NetworkSettings) {
|
||||
if (data->GetKey() != indexedName)
|
||||
continue;
|
||||
|
||||
newData = dynamic_cast<LDFData<T>*>(data);
|
||||
newData->SetValue(value);
|
||||
break;
|
||||
}
|
||||
|
||||
if (newData == nullptr) {
|
||||
newData = new LDFData<T>(indexedName, value);
|
||||
}
|
||||
|
||||
m_NetworkSettings.push_back(newData);
|
||||
|
||||
if (index == values.size()) {
|
||||
updates << newData->GetString(true);
|
||||
} else {
|
||||
updates << newData->GetString(true) << "\n";
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
SendNetworkVar(updates.str(), sysAddr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Entity::GetNetworkVar(const std::u16string& name) {
|
||||
for (auto* data : m_NetworkSettings) {
|
||||
if (data == nullptr || data->GetKey() != name)
|
||||
continue;
|
||||
|
||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||
if (typed == nullptr)
|
||||
continue;
|
||||
|
||||
return typed->GetValue();
|
||||
}
|
||||
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
template<typename Cmpt, typename...ConstructorValues>
|
||||
std::shared_ptr<Cmpt> Entity::AddComponent(ConstructorValues...arguments) {
|
||||
auto component = GetComponent<Cmpt>();
|
||||
if (component) return component;
|
||||
|
||||
auto insertedComponent = m_Components.insert_or_assign(Cmpt::ComponentType,
|
||||
std::make_shared<Cmpt>(this, std::forward<ConstructorValues>(arguments)...)).first->second;
|
||||
return std::dynamic_pointer_cast<Cmpt>(insertedComponent);
|
||||
}
|
||||
#include "Entity.tcc"
|
||||
|
||||
#endif //!__ENTITY__H__
|
||||
|
158
dGame/Entity.tcc
Normal file
158
dGame/Entity.tcc
Normal file
@ -0,0 +1,158 @@
|
||||
// Template definitions for Entity.
|
||||
|
||||
#ifndef __ENTITY__H__
|
||||
#error "Include Entity.h instead of Entity.tpp"
|
||||
#endif
|
||||
|
||||
template <typename Cmpt>
|
||||
Cmpt* Entity::GetComponent() const {
|
||||
const auto& componentItr = this->m_Components.find(Cmpt::ComponentType);
|
||||
return componentItr == this->m_Components.end() ? nullptr : dynamic_cast<Cmpt*>(componentItr->second.get());
|
||||
}
|
||||
template<typename Cmpt>
|
||||
std::shared_ptr<Cmpt> Entity::GetSharedComponent() const {
|
||||
const auto& componentItr = this->m_Components.find(Cmpt::ComponentType);
|
||||
return componentItr == this->m_Components.end() ? nullptr : std::dynamic_pointer_cast<Cmpt>(componentItr->second);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
const T& Entity::GetVar(const std::u16string& name) const {
|
||||
auto* data = GetVarData(name);
|
||||
|
||||
if (data == nullptr) {
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||
|
||||
if (typed == nullptr) {
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
return typed->GetValue();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Entity::GetVarAs(const std::u16string& name) const {
|
||||
const auto data = GetVarAsString(name);
|
||||
|
||||
T value;
|
||||
|
||||
if (!GeneralUtils::TryParse(data, value)) {
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Entity::SetVar(const std::u16string& name, const T& value) {
|
||||
auto* data = GetVarData(name);
|
||||
|
||||
if (data == nullptr) {
|
||||
auto* data = new LDFData<T>(name, value);
|
||||
|
||||
m_Settings.push_back(data);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||
|
||||
if (typed == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
typed->SetValue(value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Entity::SetNetworkVar(const std::u16string& name, const T& value, const SystemAddress& sysAddr) {
|
||||
LDFData<T>* newData = nullptr;
|
||||
|
||||
for (auto* data : m_NetworkSettings) {
|
||||
if (data->GetKey() != name)
|
||||
continue;
|
||||
|
||||
newData = dynamic_cast<LDFData<T>*>(data);
|
||||
if (newData != nullptr) {
|
||||
newData->SetValue(value);
|
||||
} else { // If we're changing types
|
||||
m_NetworkSettings.erase(
|
||||
std::remove(m_NetworkSettings.begin(), m_NetworkSettings.end(), data), m_NetworkSettings.end()
|
||||
);
|
||||
delete data;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (newData == nullptr) {
|
||||
newData = new LDFData<T>(name, value);
|
||||
}
|
||||
|
||||
m_NetworkSettings.push_back(newData);
|
||||
SendNetworkVar(newData->GetString(true), sysAddr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Entity::SetNetworkVar(const std::u16string& name, const std::vector<T>& values, const SystemAddress& sysAddr) {
|
||||
std::stringstream updates;
|
||||
auto index = 1;
|
||||
|
||||
for (const auto& value : values) {
|
||||
LDFData<T>* newData = nullptr;
|
||||
const auto& indexedName = name + u"." + GeneralUtils::to_u16string(index);
|
||||
|
||||
for (auto* data : m_NetworkSettings) {
|
||||
if (data->GetKey() != indexedName)
|
||||
continue;
|
||||
|
||||
newData = dynamic_cast<LDFData<T>*>(data);
|
||||
newData->SetValue(value);
|
||||
break;
|
||||
}
|
||||
|
||||
if (newData == nullptr) {
|
||||
newData = new LDFData<T>(indexedName, value);
|
||||
}
|
||||
|
||||
m_NetworkSettings.push_back(newData);
|
||||
|
||||
if (index == values.size()) {
|
||||
updates << newData->GetString(true);
|
||||
} else {
|
||||
updates << newData->GetString(true) << "\n";
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
SendNetworkVar(updates.str(), sysAddr);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Entity::GetNetworkVar(const std::u16string& name) {
|
||||
for (auto* data : m_NetworkSettings) {
|
||||
if (data == nullptr || data->GetKey() != name)
|
||||
continue;
|
||||
|
||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||
if (typed == nullptr)
|
||||
continue;
|
||||
|
||||
return typed->GetValue();
|
||||
}
|
||||
|
||||
return LDFData<T>::Default;
|
||||
}
|
||||
|
||||
template<typename Cmpt, typename...ConstructorValues>
|
||||
Cmpt* Entity::AddComponent(ConstructorValues...arguments) {
|
||||
auto component = GetComponent<Cmpt>();
|
||||
if (component) return dynamic_cast<Cmpt*>(component);
|
||||
|
||||
auto& insertedComponent = m_Components.insert_or_assign(Cmpt::ComponentType,
|
||||
std::make_shared<Cmpt>(this, std::forward<ConstructorValues>(arguments)...)).first->second;
|
||||
return dynamic_cast<Cmpt*>(insertedComponent.get());
|
||||
}
|
@ -51,21 +51,17 @@ User* Player::GetParentUser() const {
|
||||
return m_ParentUser;
|
||||
}
|
||||
|
||||
SystemAddress Player::GetSystemAddress() const {
|
||||
return m_SystemAddress;
|
||||
}
|
||||
|
||||
void Player::SetSystemAddress(const SystemAddress& value) {
|
||||
m_SystemAddress = value;
|
||||
}
|
||||
|
||||
void Player::SetRespawnPos(const NiPoint3 position) {
|
||||
void Player::SetRespawnPos(const NiPoint3& position) {
|
||||
m_respawnPos = position;
|
||||
|
||||
m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position);
|
||||
}
|
||||
|
||||
void Player::SetRespawnRot(const NiQuaternion rotation) {
|
||||
void Player::SetRespawnRot(const NiQuaternion& rotation) {
|
||||
m_respawnRot = rotation;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
|
||||
User* GetParentUser() const override;
|
||||
|
||||
SystemAddress GetSystemAddress() const override;
|
||||
const SystemAddress GetSystemAddress() const override { return m_SystemAddress; }
|
||||
|
||||
NiPoint3 GetRespawnPosition() const override;
|
||||
|
||||
@ -44,9 +44,9 @@ public:
|
||||
|
||||
void SetSystemAddress(const SystemAddress& value) override;
|
||||
|
||||
void SetRespawnPos(NiPoint3 position) override;
|
||||
void SetRespawnPos(const NiPoint3& position) override;
|
||||
|
||||
void SetRespawnRot(NiQuaternion rotation) override;
|
||||
void SetRespawnRot(const NiQuaternion& rotation) override;
|
||||
|
||||
void SetGhostReferencePoint(const NiPoint3& value);
|
||||
|
||||
|
@ -190,7 +190,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_MovementAI == nullptr) {
|
||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
m_MovementAI = m_OwningEntity->GetSharedComponent<MovementAIComponent>();
|
||||
if (m_MovementAI == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ void BuffComponent::ApplyBuff(const int32_t id, const float duration, const LWOO
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendAddBuff(const_cast<LWOOBJID&>(m_OwningEntity->GetObjectID()), source, (uint32_t)id,
|
||||
GameMessages::SendAddBuff(m_OwningEntity->GetObjectID(), source, (uint32_t)id,
|
||||
(uint32_t)duration * 1000, addImmunity, cancelOnDamaged, cancelOnDeath,
|
||||
cancelOnLogout, cancelOnRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
||||
|
||||
|
@ -22,7 +22,7 @@ MovementAIComponent::MovementAIComponent(Entity* parent, MovementAIInfo info) :
|
||||
|
||||
m_BaseCombatAI = nullptr;
|
||||
|
||||
m_BaseCombatAI = m_OwningEntity->GetComponent<BaseCombatAIComponent>();
|
||||
m_BaseCombatAI = m_OwningEntity->GetSharedComponent<BaseCombatAIComponent>();
|
||||
|
||||
//Try and fix the insane values:
|
||||
if (m_Info.wanderRadius > 5.0f) m_Info.wanderRadius = m_Info.wanderRadius * 0.5f;
|
||||
|
@ -363,7 +363,7 @@ void PetComponent::Update(float deltaTime) {
|
||||
}
|
||||
|
||||
if (m_MovementAI == nullptr) {
|
||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
m_MovementAI = m_OwningEntity->GetSharedComponent<MovementAIComponent>();
|
||||
if (!m_MovementAI) return;
|
||||
}
|
||||
|
||||
@ -792,7 +792,7 @@ void PetComponent::ClientFailTamingMinigame() {
|
||||
}
|
||||
|
||||
void PetComponent::Wander() {
|
||||
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
|
||||
if (!m_MovementAI) m_MovementAI = m_OwningEntity->GetSharedComponent<MovementAIComponent>();
|
||||
|
||||
if (m_MovementAI == nullptr || !m_MovementAI->AtFinalWaypoint()) {
|
||||
return;
|
||||
@ -1038,7 +1038,7 @@ void PetComponent::SetAbility(PetAbilityType value) {
|
||||
m_Ability = value;
|
||||
}
|
||||
|
||||
std::shared_ptr<PetComponent> PetComponent::GetTamingPet(LWOOBJID tamer) {
|
||||
PetComponent* PetComponent::GetTamingPet(LWOOBJID tamer) {
|
||||
const auto& pair = currentActivities.find(tamer);
|
||||
|
||||
if (pair == currentActivities.end()) {
|
||||
@ -1056,7 +1056,7 @@ std::shared_ptr<PetComponent> PetComponent::GetTamingPet(LWOOBJID tamer) {
|
||||
return entity->GetComponent<PetComponent>();
|
||||
}
|
||||
|
||||
std::shared_ptr<PetComponent> PetComponent::GetActivePet(LWOOBJID owner) {
|
||||
PetComponent* PetComponent::GetActivePet(LWOOBJID owner) {
|
||||
const auto& pair = activePets.find(owner);
|
||||
|
||||
if (pair == activePets.end()) {
|
||||
|
@ -195,14 +195,14 @@ public:
|
||||
* @param tamer the entity that's currently taming
|
||||
* @return the pet component of the entity that's being tamed
|
||||
*/
|
||||
static std::shared_ptr<PetComponent> GetTamingPet(LWOOBJID tamer);
|
||||
static PetComponent* GetTamingPet(LWOOBJID tamer);
|
||||
|
||||
/**
|
||||
* Returns the pet that's currently spawned for some entity (if any)
|
||||
* @param owner the owner of the pet that's spawned
|
||||
* @return the pet component of the entity that was spawned by the owner
|
||||
*/
|
||||
static std::shared_ptr<PetComponent> GetActivePet(LWOOBJID owner);
|
||||
static PetComponent* GetActivePet(LWOOBJID owner);
|
||||
|
||||
/**
|
||||
* Adds the timer to the owner of this pet to drain imagination at the rate
|
||||
|
@ -58,7 +58,7 @@ RebuildComponent::~RebuildComponent() {
|
||||
}
|
||||
|
||||
void RebuildComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) {
|
||||
if (m_OwningEntity->GetComponent(eReplicaComponentType::DESTROYABLE) == nullptr) {
|
||||
if (!m_OwningEntity->GetComponent<DestroyableComponent>()) {
|
||||
if (bIsInitialUpdate) {
|
||||
outBitStream->Write(false);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) {
|
||||
|
||||
m_ResetTime = m_OwningEntity->GetVarAs<int32_t>(u"switch_reset_time");
|
||||
|
||||
m_Rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
|
||||
m_Rebuild = m_OwningEntity->GetSharedComponent<RebuildComponent>();
|
||||
}
|
||||
|
||||
SwitchComponent::~SwitchComponent() {
|
||||
|
@ -4565,7 +4565,7 @@ void GameMessages::SendVehicleNotifyFinishedRace(LWOOBJID objectId, const System
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void GameMessages::SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
||||
void GameMessages::SendAddBuff(const LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
||||
bool addImmunity, bool cancelOnDamaged, bool cancelOnDeath, bool cancelOnLogout,
|
||||
bool cancelOnRemoveBuff, bool cancelOnUi, bool cancelOnUnequip, bool cancelOnZone,
|
||||
const SystemAddress& sysAddr) {
|
||||
|
@ -200,7 +200,7 @@ namespace GameMessages {
|
||||
// The success or failure response sent back to the client will preserve the same value for localID.
|
||||
void SendBBBSaveResponse(const LWOOBJID& objectId, const LWOOBJID& localID, unsigned char* buffer, uint32_t bufferSize, const SystemAddress& sysAddr);
|
||||
|
||||
void SendAddBuff(LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
||||
void SendAddBuff(const LWOOBJID& objectID, const LWOOBJID& casterID, uint32_t buffID, uint32_t msDuration,
|
||||
bool addImmunity = false, bool cancelOnDamaged = false, bool cancelOnDeath = true,
|
||||
bool cancelOnLogout = false, bool cancelOnRemoveBuff = true, bool cancelOnUi = false,
|
||||
bool cancelOnUnequip = false, bool cancelOnZone = false, const SystemAddress& sysAddr = UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
@ -213,7 +213,7 @@ void MissionTask::Progress(int32_t value, LWOOBJID associate, const std::string&
|
||||
}
|
||||
|
||||
Entity* entity;
|
||||
std::shared_ptr<ScriptedActivityComponent> activity;
|
||||
ScriptedActivityComponent* activity;
|
||||
uint32_t activityId;
|
||||
uint32_t lot;
|
||||
uint32_t collectionId;
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "UpdateActionMessage.h"
|
||||
#include "UpdateStripUiMessage.h"
|
||||
|
||||
void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, std::shared_ptr<ModelBehaviorComponent> modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) {
|
||||
void ControlBehaviors::RequestUpdatedID(int32_t behaviorID, ModelBehaviorComponent* modelComponent, Entity* modelOwner, const SystemAddress& sysAddr) {
|
||||
// auto behavior = modelComponent->FindBehavior(behaviorID);
|
||||
// if (behavior->GetBehaviorID() == -1 || behavior->GetShouldSetNewID()) {
|
||||
// ObjectIDManager::Instance()->RequestPersistentID(
|
||||
@ -79,7 +79,7 @@ void ControlBehaviors::SendBehaviorListToClient(Entity* modelEntity, const Syste
|
||||
GameMessages::SendUIMessageServerToSingleClient(modelOwner, sysAddr, "UpdateBehaviorList", behaviorsToSerialize);
|
||||
}
|
||||
|
||||
void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr<ModelBehaviorComponent> ModelBehaviorComponent) {
|
||||
void ControlBehaviors::ModelTypeChanged(AMFArrayValue* arguments, ModelBehaviorComponent* ModelComponent) {
|
||||
auto* modelTypeAmf = arguments->Get<double>("ModelType");
|
||||
if (!modelTypeAmf) return;
|
||||
|
||||
@ -137,7 +137,7 @@ void ControlBehaviors::Rename(Entity* modelEntity, const SystemAddress& sysAddr,
|
||||
}
|
||||
|
||||
// TODO This is also supposed to serialize the state of the behaviors in progress but those aren't implemented yet
|
||||
void ControlBehaviors::SendBehaviorBlocksToClient(std::shared_ptr<ModelBehaviorComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) {
|
||||
void ControlBehaviors::SendBehaviorBlocksToClient(ModelBehaviorComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) {
|
||||
// uint32_t behaviorID = ControlBehaviors::GetBehaviorIDFromArgument(arguments);
|
||||
|
||||
// auto modelBehavior = modelComponent->FindBehavior(behaviorID);
|
||||
@ -266,7 +266,7 @@ void ControlBehaviors::UpdateAction(AMFArrayValue* arguments) {
|
||||
}
|
||||
}
|
||||
|
||||
void ControlBehaviors::MoveToInventory(std::shared_ptr<ModelBehaviorComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) {
|
||||
void ControlBehaviors::MoveToInventory(ModelBehaviorComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments) {
|
||||
// This closes the UI menu should it be open while the player is removing behaviors
|
||||
AMFArrayValue args;
|
||||
|
||||
|
@ -41,9 +41,9 @@ public:
|
||||
*/
|
||||
BlockDefinition* GetBlockInfo(const BlockName& blockName);
|
||||
private:
|
||||
void RequestUpdatedID(int32_t behaviorID, std::shared_ptr<ModelBehaviorComponent> modelComponent, Entity* modelOwner, const SystemAddress& sysAddr);
|
||||
void RequestUpdatedID(int32_t behaviorID, ModelBehaviorComponent* modelComponent, Entity* modelOwner, const SystemAddress& sysAddr);
|
||||
void SendBehaviorListToClient(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner);
|
||||
void ModelTypeChanged(AMFArrayValue* arguments, std::shared_ptr<ModelBehaviorComponent> ModelBehaviorComponent);
|
||||
void ModelTypeChanged(AMFArrayValue* arguments, ModelBehaviorComponent* ModelComponent);
|
||||
void ToggleExecutionUpdates();
|
||||
void AddStrip(AMFArrayValue* arguments);
|
||||
void RemoveStrip(AMFArrayValue* arguments);
|
||||
@ -56,9 +56,9 @@ private:
|
||||
void Add(AMFArrayValue* arguments);
|
||||
void RemoveActions(AMFArrayValue* arguments);
|
||||
void Rename(Entity* modelEntity, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
|
||||
void SendBehaviorBlocksToClient(std::shared_ptr<ModelBehaviorComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
|
||||
void SendBehaviorBlocksToClient(ModelBehaviorComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
|
||||
void UpdateAction(AMFArrayValue* arguments);
|
||||
void MoveToInventory(std::shared_ptr<ModelBehaviorComponent> modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
|
||||
void MoveToInventory(ModelBehaviorComponent* modelComponent, const SystemAddress& sysAddr, Entity* modelOwner, AMFArrayValue* arguments);
|
||||
std::map<BlockName, BlockDefinition*> blockTypes{};
|
||||
|
||||
// If false, property behaviors will not be able to be edited.
|
||||
|
@ -17,7 +17,7 @@ void WaveBossApe::OnStartup(Entity* self) {
|
||||
combatAIComponent->SetStunImmune(true);
|
||||
}
|
||||
|
||||
self->AddToGroup("boss");
|
||||
self->AddToGroups("boss");
|
||||
|
||||
BaseEnemyApe::OnStartup(self);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ void WaveBossHammerling::OnStartup(Entity* self) {
|
||||
combatAIComponent->SetStunImmune(true);
|
||||
}
|
||||
|
||||
self->AddToGroup("boss");
|
||||
self->AddToGroups("boss");
|
||||
}
|
||||
|
||||
void WaveBossHammerling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
|
||||
|
@ -11,7 +11,7 @@ void WaveBossHorsemen::OnStartup(Entity* self) {
|
||||
combatAIComponent->SetStunImmune(true);
|
||||
}
|
||||
|
||||
self->AddToGroup("boss");
|
||||
self->AddToGroups("boss");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -11,7 +11,7 @@ void WaveBossSpiderling::OnStartup(Entity* self) {
|
||||
combatAIComponent->SetStunImmune(true);
|
||||
}
|
||||
|
||||
self->AddToGroup("boss");
|
||||
self->AddToGroups("boss");
|
||||
}
|
||||
|
||||
void WaveBossSpiderling::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
|
||||
|
@ -123,7 +123,7 @@ void NtCombatChallengeServer::OnChildLoaded(Entity* self, Entity* child) {
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(child);
|
||||
|
||||
child->GetGroups().push_back("targets_" + std::to_string(self->GetObjectID()));
|
||||
child->AddToGroups("targets_" + std::to_string(self->GetObjectID()));
|
||||
}
|
||||
|
||||
void NtCombatChallengeServer::ResetGame(Entity* self) {
|
||||
|
@ -51,7 +51,7 @@ void EnemySpiderSpawner::OnTimerDone(Entity* self, std::string timerName) {
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
if (newEntity) {
|
||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||
newEntity->GetGroups().push_back("BabySpider");
|
||||
newEntity->AddToGroups("BabySpider");
|
||||
|
||||
/*
|
||||
auto movementAi = newEntity->GetComponent<MovementAIComponent>();
|
||||
|
@ -18,7 +18,7 @@ void ActMine::OnRebuildNotifyState(Entity* self, eRebuildState state) {
|
||||
|
||||
self->SetVar(u"RebuildComplete", true);
|
||||
self->SetVar(u"NumWarnings", 0);
|
||||
self->AddToGroup("reset");
|
||||
self->AddToGroups("reset");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "Entity.h"
|
||||
|
||||
void WildNinjaBricks::OnStartup(Entity* self) {
|
||||
self->AddToGroup("Ninjastuff");
|
||||
self->AddToGroups("Ninjastuff");
|
||||
}
|
||||
|
||||
void WildNinjaBricks::OnNotifyObject(Entity* self, Entity* sender, const std::string& name, int32_t param1, int32_t param2) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "GameMessages.h"
|
||||
|
||||
void WildNinjaStudent::OnStartup(Entity* self) {
|
||||
self->AddToGroup("Ninjastuff");
|
||||
self->AddToGroups("Ninjastuff");
|
||||
GameMessages::SendPlayAnimation(self, u"bow");
|
||||
}
|
||||
|
||||
|
@ -102,23 +102,23 @@ Entity* Spawner::Spawn(std::vector<SpawnerNode*> freeNodes, const bool force) {
|
||||
m_EntityInfo.spawnerID = m_Info.spawnerID;
|
||||
}
|
||||
|
||||
Entity* rezdE = EntityManager::Instance()->CreateEntity(m_EntityInfo, nullptr);
|
||||
Entity* spawnedEntity = EntityManager::Instance()->CreateEntity(m_EntityInfo, nullptr);
|
||||
|
||||
rezdE->GetGroups() = m_Info.groups;
|
||||
spawnedEntity->SetGroups(m_Info.groups);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(rezdE);
|
||||
EntityManager::Instance()->ConstructEntity(spawnedEntity);
|
||||
|
||||
m_Entities.insert({ rezdE->GetObjectID(), spawnNode });
|
||||
spawnNode->entities.push_back(rezdE->GetObjectID());
|
||||
m_Entities.insert({ spawnedEntity->GetObjectID(), spawnNode });
|
||||
spawnNode->entities.push_back(spawnedEntity->GetObjectID());
|
||||
if (m_Entities.size() == m_Info.amountMaintained) {
|
||||
m_NeedsUpdate = false;
|
||||
}
|
||||
|
||||
for (const auto& cb : m_EntitySpawnedCallbacks) {
|
||||
cb(rezdE);
|
||||
cb(spawnedEntity);
|
||||
}
|
||||
|
||||
return rezdE;
|
||||
return spawnedEntity;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user