mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-10-30 20:22:04 +00:00 
			
		
		
		
	Organize Entity header
Probably the third or fourth pass of this darn header... Just keep making it better every time Rename some functions to make more sense to a reader Use different method for Observing/subscribing to component events Get rid of abomination of overloading GetParentUser
This commit is contained in:
		| @@ -55,13 +55,13 @@ void Player::SetSystemAddress(const SystemAddress& value) { | |||||||
| 	m_SystemAddress = value; | 	m_SystemAddress = value; | ||||||
| } | } | ||||||
|  |  | ||||||
| void Player::SetRespawnPos(const NiPoint3& position) { | void Player::SetRespawnPosition(const NiPoint3& position) { | ||||||
| 	m_respawnPos = position; | 	m_respawnPos = position; | ||||||
|  |  | ||||||
| 	m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position); | 	m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position); | ||||||
| } | } | ||||||
|  |  | ||||||
| void Player::SetRespawnRot(const NiQuaternion& rotation) { | void Player::SetRespawnRotation(const NiQuaternion& rotation) { | ||||||
| 	m_respawnRot = rotation; | 	m_respawnRot = rotation; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -44,9 +44,9 @@ public: | |||||||
|  |  | ||||||
| 	void SetSystemAddress(const SystemAddress& value) override; | 	void SetSystemAddress(const SystemAddress& value) override; | ||||||
|  |  | ||||||
| 	void SetRespawnPos(const NiPoint3& position) override; | 	void SetRespawnPosition(const NiPoint3& position) override; | ||||||
|  |  | ||||||
| 	void SetRespawnRot(const NiQuaternion& rotation) override; | 	void SetRespawnRotation(const NiQuaternion& rotation) override; | ||||||
|  |  | ||||||
| 	void SetGhostReferencePoint(const NiPoint3& value); | 	void SetGhostReferencePoint(const NiPoint3& value); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -213,7 +213,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet | |||||||
|  |  | ||||||
| 		bitStream->Write(armorDamageDealt); | 		bitStream->Write(armorDamageDealt); | ||||||
| 		bitStream->Write(healthDamageDealt); | 		bitStream->Write(healthDamageDealt); | ||||||
| 		bitStream->Write(targetEntity->GetIsDead()); | 		bitStream->Write(targetEntity->IsDead()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	bitStream->Write(successState); | 	bitStream->Write(successState); | ||||||
|   | |||||||
| @@ -148,7 +148,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitS | |||||||
| 			continue; | 			continue; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if (entity->GetIsDead()) continue; | 		if (entity->IsDead()) continue; | ||||||
|  |  | ||||||
| 		const auto otherPosition = entity->GetPosition(); | 		const auto otherPosition = entity->GetPosition(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -180,7 +180,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) { | |||||||
| 		m_SoftTimer -= deltaTime; | 		m_SoftTimer -= deltaTime; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (m_Disabled || m_ParentEntity->GetIsDead()) | 	if (m_Disabled || m_ParentEntity->IsDead()) | ||||||
| 		return; | 		return; | ||||||
| 	bool stunnedThisFrame = m_Stunned; | 	bool stunnedThisFrame = m_Stunned; | ||||||
| 	CalculateCombat(deltaTime); // Putting this here for now | 	CalculateCombat(deltaTime); // Putting this here for now | ||||||
|   | |||||||
| @@ -692,26 +692,32 @@ void DestroyableComponent::Damage(uint32_t damage, const LWOOBJID source, uint32 | |||||||
| 	Smash(source, eKillType::VIOLENT, u"", skillID); | 	Smash(source, eKillType::VIOLENT, u"", skillID); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DestroyableComponent::Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd) { | void DestroyableComponent::Subscribe(CppScripts::Script* scriptToAdd) { | ||||||
| 	m_SubscribedScripts.insert(std::make_pair(scriptObjId, scriptToAdd)); | 	auto foundScript = std::find(m_SubscribedScripts.begin(), m_SubscribedScripts.end(), scriptToAdd); | ||||||
| 	Game::logger->LogDebug("DestroyableComponent", "Added script %llu to entity %llu", scriptObjId, m_ParentEntity->GetObjectID()); | 	if (foundScript != m_SubscribedScripts.end()) { | ||||||
|  | 		Game::logger->LogDebug("DestroyableComponent", "WARNING: Tried to add a script for Entity %llu but the script was already subscribed", m_ParentEntity->GetObjectID()); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 	m_SubscribedScripts.push_back(scriptToAdd); | ||||||
|  | 	Game::logger->LogDebug("DestroyableComponent", "A script has subscribed to entity %llu", m_ParentEntity->GetObjectID()); | ||||||
| 	Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); | 	Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DestroyableComponent::Unsubscribe(LWOOBJID scriptObjId) { | void DestroyableComponent::Unsubscribe(CppScripts::Script* scriptToRemove) { | ||||||
| 	auto foundScript = m_SubscribedScripts.find(scriptObjId); | 	auto foundScript = std::find(m_SubscribedScripts.begin(), m_SubscribedScripts.end(), scriptToRemove); | ||||||
| 	if (foundScript != m_SubscribedScripts.end()) { | 	if (foundScript != m_SubscribedScripts.end()) { | ||||||
| 		m_SubscribedScripts.erase(foundScript); | 		m_SubscribedScripts.erase(foundScript); | ||||||
| 		Game::logger->LogDebug("DestroyableComponent", "Removed script %llu from entity %llu", scriptObjId, m_ParentEntity->GetObjectID()); | 		Game::logger->LogDebug("DestroyableComponent", "Unsubscribed a script from entity %llu", m_ParentEntity->GetObjectID()); | ||||||
| 	} else { |  | ||||||
| 		Game::logger->LogDebug("DestroyableComponent", "Tried to remove a script for Entity %llu but script %llu didnt exist", m_ParentEntity->GetObjectID(), scriptObjId); |  | ||||||
| 	} |  | ||||||
| 		Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); | 		Game::logger->LogDebug("DestroyableComponent", "Number of subscribed scripts %i", m_SubscribedScripts.size()); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  | 	Game::logger->LogDebug("DestroyableComponent", "WARNING: Tried to remove a script for Entity %llu but the script was not subscribed", m_ParentEntity->GetObjectID()); | ||||||
| } | } | ||||||
|  |  | ||||||
| void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) { | void DestroyableComponent::NotifySubscribers(Entity* attacker, uint32_t damage) { | ||||||
| 	for (auto script : m_SubscribedScripts) { | 	for (auto* script : m_SubscribedScripts) { | ||||||
| 		script.second->NotifyHitOrHealResult(m_ParentEntity, attacker, damage); | 		DluAssert(script != nullptr); | ||||||
|  | 		script->NotifyHitOrHealResult(m_ParentEntity, attacker, damage); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -447,8 +447,8 @@ public: | |||||||
| 	 */ | 	 */ | ||||||
| 	void NotifySubscribers(Entity* attacker, uint32_t damage); | 	void NotifySubscribers(Entity* attacker, uint32_t damage); | ||||||
|  |  | ||||||
| 	void Subscribe(LWOOBJID scriptObjId, CppScripts::Script* scriptToAdd); | 	void Subscribe(CppScripts::Script* scriptToAdd); | ||||||
| 	void Unsubscribe(LWOOBJID scriptObjId); | 	void Unsubscribe(CppScripts::Script* scriptToRemove); | ||||||
|  |  | ||||||
| 	// handle hardcode mode drops | 	// handle hardcode mode drops | ||||||
| 	void DoHardcoreModeDrops(const LWOOBJID source); | 	void DoHardcoreModeDrops(const LWOOBJID source); | ||||||
| @@ -587,9 +587,9 @@ private: | |||||||
| 	std::vector<std::function<void(Entity*)>> m_OnHitCallbacks; | 	std::vector<std::function<void(Entity*)>> m_OnHitCallbacks; | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * The list of scripts subscribed to this components actions | 	 * Scripts that are subscribed to this component | ||||||
| 	 */ | 	 */ | ||||||
| 	std::map<LWOOBJID, CppScripts::Script*> m_SubscribedScripts; | 	std::vector<CppScripts::Script*> m_SubscribedScripts; | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * status immunity counters | 	 * status immunity counters | ||||||
|   | |||||||
| @@ -366,8 +366,8 @@ void PhantomPhysicsComponent::Update(float deltaTime) { | |||||||
|  |  | ||||||
| 			if (entity) { | 			if (entity) { | ||||||
| 				GameMessages::SendPlayerReachedRespawnCheckpoint(entity, m_RespawnPos, m_RespawnRot); | 				GameMessages::SendPlayerReachedRespawnCheckpoint(entity, m_RespawnPos, m_RespawnRot); | ||||||
| 				entity->SetRespawnPos(m_RespawnPos); | 				entity->SetRespawnPosition(m_RespawnPos); | ||||||
| 				entity->SetRespawnRot(m_RespawnRot); | 				entity->SetRespawnRotation(m_RespawnRot); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -569,31 +569,26 @@ bool Entity::operator!=(const Entity& other) const { | |||||||
| 	return !(other.m_ObjectID == m_ObjectID); | 	return !(other.m_ObjectID == m_ObjectID); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Move to header |  | ||||||
| User* Entity::GetParentUser() const { |  | ||||||
| 	return IsPlayer() ? static_cast<const Player*>(this)->GetParentUser() : nullptr; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| // Move to header | // Move to header | ||||||
| bool Entity::HasComponent(const eReplicaComponentType componentId) const { | bool Entity::HasComponent(const eReplicaComponentType componentId) const { | ||||||
| 	return m_Components.find(componentId) != m_Components.end(); | 	return m_Components.find(componentId) != m_Components.end(); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Fine | // Fine | ||||||
| void Entity::Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName) { | void Entity::Subscribe(CppScripts::Script* scriptToAdd, const std::string& notificationName) { | ||||||
|  | 	Game::logger->Log("Entity", "Subscribing a script with notification %s", notificationName.c_str()); | ||||||
| 	if (notificationName == "HitOrHealResult" || notificationName == "Hit") { | 	if (notificationName == "HitOrHealResult" || notificationName == "Hit") { | ||||||
| 		auto* destroyableComponent = GetComponent<DestroyableComponent>(); | 		auto* destroyableComponent = GetComponent<DestroyableComponent>(); | ||||||
| 		if (!destroyableComponent) return; | 		if (destroyableComponent) destroyableComponent->Subscribe(scriptToAdd); | ||||||
| 		destroyableComponent->Subscribe(scriptObjId, scriptToAdd); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| // Fine | // Fine | ||||||
| void Entity::Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName) { | void Entity::Unsubscribe(CppScripts::Script* scriptToRemove, const std::string& notificationName) { | ||||||
|  | 	Game::logger->Log("Entity", "Unsubscribing a script with notification %s", notificationName.c_str()); | ||||||
| 	if (notificationName == "HitOrHealResult" || notificationName == "Hit") { | 	if (notificationName == "HitOrHealResult" || notificationName == "Hit") { | ||||||
| 		auto* destroyableComponent = GetComponent<DestroyableComponent>(); | 		auto* destroyableComponent = GetComponent<DestroyableComponent>(); | ||||||
| 		if (!destroyableComponent) return; | 		if (destroyableComponent) destroyableComponent->Unsubscribe(scriptToRemove); | ||||||
| 		destroyableComponent->Unsubscribe(scriptObjId); |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -857,7 +852,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) { | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (!other->GetIsDead()) { | 	if (!other->IsDead()) { | ||||||
| 		auto* combat = GetComponent<BaseCombatAIComponent>(); | 		auto* combat = GetComponent<BaseCombatAIComponent>(); | ||||||
|  |  | ||||||
| 		if (combat != nullptr) { | 		if (combat != nullptr) { | ||||||
| @@ -1053,7 +1048,7 @@ void Entity::AddRebuildCompleteCallback(const std::function<void(Entity* user)>& | |||||||
| 	if (quickBuildComponent) quickBuildComponent->AddRebuildCompleteCallback(callback); | 	if (quickBuildComponent) quickBuildComponent->AddRebuildCompleteCallback(callback); | ||||||
| } | } | ||||||
|  |  | ||||||
| bool Entity::GetIsDead() const { | bool Entity::IsDead() const { | ||||||
| 	auto* dest = GetComponent<DestroyableComponent>(); | 	auto* dest = GetComponent<DestroyableComponent>(); | ||||||
| 	return dest && dest->GetArmor() == 0 && dest->GetHealth() == 0; | 	return dest && dest->GetArmor() == 0 && dest->GetHealth() == 0; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,6 +19,10 @@ namespace tinyxml2 { | |||||||
| 	class XMLDocument; | 	class XMLDocument; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | namespace CppScripts { | ||||||
|  | 	class Script; | ||||||
|  | }; | ||||||
|  |  | ||||||
| class Player; | class Player; | ||||||
| class EntityInfo; | class EntityInfo; | ||||||
| class User; | class User; | ||||||
| @@ -37,10 +41,6 @@ enum class eReplicaComponentType : uint32_t; | |||||||
| enum class eReplicaPacketType : uint8_t; | enum class eReplicaPacketType : uint8_t; | ||||||
| enum class eCinematicEvent : uint32_t; | enum class eCinematicEvent : uint32_t; | ||||||
|  |  | ||||||
| namespace CppScripts { |  | ||||||
| 	class Script; |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * An entity in the world. |  * An entity in the world. | ||||||
|  * Entities are composed of components which define their behavior. |  * Entities are composed of components which define their behavior. | ||||||
| @@ -58,8 +58,15 @@ public: | |||||||
| 	void ApplyComponentWhitelist(TemplateComponents& components) const; | 	void ApplyComponentWhitelist(TemplateComponents& components) const; | ||||||
| 	static const std::vector<ComponentWhitelist>& GetComponentWhitelists() { return m_ComponentWhitelists; } | 	static const std::vector<ComponentWhitelist>& GetComponentWhitelists() { return m_ComponentWhitelists; } | ||||||
|  |  | ||||||
| 	// 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. | 	 * 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. | ||||||
|  | 	 */ | ||||||
| 	void ApplyComponentBlacklist(TemplateComponents& components) const; | 	void ApplyComponentBlacklist(TemplateComponents& components) const; | ||||||
|  |  | ||||||
| 	// For adding and removing components based on LDF keys | 	// For adding and removing components based on LDF keys | ||||||
| @@ -68,84 +75,100 @@ public: | |||||||
| 	// Paths have several components they could add. This function will add them. | 	// Paths have several components they could add. This function will add them. | ||||||
| 	void AddPathComponent(TemplateComponents& components) const; | 	void AddPathComponent(TemplateComponents& components) const; | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * 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. | ||||||
|  | 	 */ | ||||||
| 	void IsGhosted(); | 	void IsGhosted(); | ||||||
| 	virtual void Initialize(); |  | ||||||
|  |  | ||||||
| 	bool operator==(const Entity& other) const; | 	bool operator==(const Entity& other) const; | ||||||
| 	bool operator!=(const Entity& other) const; | 	bool operator!=(const Entity& other) const; | ||||||
|  |  | ||||||
| 	/** | 	// General Entity info | ||||||
| 	 * 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; } | 	const LOT GetLOT() const { return m_TemplateID; } | ||||||
|  |  | ||||||
| 	eGameMasterLevel GetGMLevel() const { return m_GMLevel; } |  | ||||||
| 	void SetGMLevel(const eGameMasterLevel value); |  | ||||||
|  |  | ||||||
| 	Entity* GetParentEntity() const { return m_ParentEntity; } | 	Entity* GetParentEntity() const { return m_ParentEntity; } | ||||||
|  |  | ||||||
| 	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; } |  | ||||||
|  |  | ||||||
| 	LWOOBJID GetSpawnerID() const { return m_SpawnerID; } |  | ||||||
|  |  | ||||||
| 	const std::vector<LDFBaseData*>& GetSettings() const { return m_Settings; } |  | ||||||
|  |  | ||||||
| 	const std::vector<LDFBaseData*>& GetNetworkSettings() const { return m_NetworkSettings; } |  | ||||||
|  |  | ||||||
| 	bool GetIsDead() const; |  | ||||||
|  |  | ||||||
| 	bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; } |  | ||||||
| 	void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; } |  | ||||||
|  |  | ||||||
| 	const bool GetIsGhostingCandidate() const { return m_IsGhostingCandidate; } | 	const bool GetIsGhostingCandidate() const { return m_IsGhostingCandidate; } | ||||||
|  |  | ||||||
| 	const int8_t GetObservers() const { return m_Observers; } | 	const float GetDefaultScale() const { return m_Scale; } | ||||||
| 	void SetObservers(const int8_t value); |  | ||||||
|  |  | ||||||
| 	const uint16_t GetNetworkId() const { return m_NetworkID; } |  | ||||||
| 	void SetNetworkId(const uint16_t id) { m_NetworkID = id; } |  | ||||||
|  |  | ||||||
| 	Entity* GetOwner() const; | 	Entity* GetOwner() const; | ||||||
| 	void SetOwnerOverride(const LWOOBJID& value) { m_OwnerOverride = value; }; | 	void SetOwnerOverride(const LWOOBJID& value) { m_OwnerOverride = value; }; | ||||||
|  |  | ||||||
|  | 	// Position related info | ||||||
| 	const NiPoint3& GetDefaultPosition() const { return m_DefaultPosition; }; | 	const NiPoint3& GetDefaultPosition() const { return m_DefaultPosition; }; | ||||||
|  |  | ||||||
| 	const NiQuaternion& GetDefaultRotation() const { return m_DefaultRotation; }; | 	const NiQuaternion& GetDefaultRotation() const { return m_DefaultRotation; }; | ||||||
|  |  | ||||||
| 	const float GetDefaultScale() const { return m_Scale; } |  | ||||||
|  |  | ||||||
| 	const NiPoint3& GetPosition() const; | 	const NiPoint3& GetPosition() const; | ||||||
| 	void SetPosition(const NiPoint3& position); | 	void SetPosition(const NiPoint3& position); | ||||||
|  |  | ||||||
| 	const NiQuaternion& GetRotation() const; | 	const NiQuaternion& GetRotation() const; | ||||||
| 	void SetRotation(const NiQuaternion& rotation); | 	void SetRotation(const NiQuaternion& rotation); | ||||||
|  |  | ||||||
| 	virtual User* GetParentUser() const; | 	// Spawner related info | ||||||
|  | 	Spawner* GetSpawner() const { return m_Spawner; } | ||||||
|  |  | ||||||
|  | 	LWOOBJID GetSpawnerID() const { return m_SpawnerID; } | ||||||
|  |  | ||||||
|  | 	const std::vector<std::string>& GetGroups() { return m_Groups; }; | ||||||
|  | 	void SetGroups(const std::vector<std::string>& value) { m_Groups = value; } | ||||||
|  |  | ||||||
|  | 	// LDF related into | ||||||
|  | 	const std::vector<LDFBaseData*>& GetSettings() const { return m_Settings; } | ||||||
|  |  | ||||||
|  | 	const std::vector<LDFBaseData*>& GetNetworkSettings() const { return m_NetworkSettings; } | ||||||
|  |  | ||||||
|  | 	// Networking related info | ||||||
|  | 	const int8_t GetObservers() const { return m_Observers; } | ||||||
|  | 	void SetObservers(const int8_t value); | ||||||
|  |  | ||||||
|  | 	const uint16_t GetNetworkId() const { return m_NetworkID; } | ||||||
|  | 	void SetNetworkId(const uint16_t id) { m_NetworkID = id; } | ||||||
|  |  | ||||||
|  | 	// Player extended info | ||||||
|  | 	virtual User* GetParentUser() const { return nullptr; }; | ||||||
|  |  | ||||||
| 	virtual const SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; }; | 	virtual const SystemAddress GetSystemAddress() const { return UNASSIGNED_SYSTEM_ADDRESS; }; | ||||||
|  |  | ||||||
| 	virtual void SetRespawnPos(const NiPoint3& position) {}; | 	virtual void SetRespawnPosition(const NiPoint3& position) {}; | ||||||
|  |  | ||||||
| 	virtual void SetRespawnRot(const NiQuaternion& rotation) {}; | 	virtual void SetRespawnRotation(const NiQuaternion& rotation) {}; | ||||||
|  |  | ||||||
| 	virtual void SetSystemAddress(const SystemAddress& value) {}; | 	virtual void SetSystemAddress(const SystemAddress& value) {}; | ||||||
|  |  | ||||||
| 	/** | 	eGameMasterLevel GetGMLevel() const { return m_GMLevel; } | ||||||
| 	 * Component management | 	void SetGMLevel(const eGameMasterLevel value); | ||||||
| 	 */ |  | ||||||
|  | 	bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; } | ||||||
|  | 	void SetPlayerReadyForUpdates() { m_PlayerIsReadyForUpdates = true; } | ||||||
|  |  | ||||||
|  | 	Character* GetCharacter() const { return m_Character; } | ||||||
|  | 	void SetCharacter(Character* value) { m_Character = value; } | ||||||
|  |  | ||||||
|  | 	// End info | ||||||
|  |  | ||||||
|  | 	bool IsDead() const; | ||||||
|  |  | ||||||
|  | 	// If you are calling this, then calling GetComponent<T>, just call GetComponent<T> and check for nullptr. | ||||||
| 	bool HasComponent(const eReplicaComponentType componentId) const; | 	bool HasComponent(const eReplicaComponentType componentId) const; | ||||||
|  |  | ||||||
| 	void Subscribe(const LWOOBJID& scriptObjId, CppScripts::Script* scriptToAdd, const std::string& notificationName); | 	/** | ||||||
| 	void Unsubscribe(const LWOOBJID& scriptObjId, const std::string& notificationName); | 	 * 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. | ||||||
|  | 	 */ | ||||||
|  | 	void Subscribe(CppScripts::Script* scriptToAdd, const std::string& notificationName); | ||||||
|  |  | ||||||
|  | 	/** | ||||||
|  | 	 * 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); | ||||||
|  | // ### STOPPED HERE ### | ||||||
| 	void SetProximityRadius(const float proxRadius, const std::string& name); | 	void SetProximityRadius(const float proxRadius, const std::string& name); | ||||||
| 	void SetProximityRadius(dpEntity* entity, const std::string& name); | 	void SetProximityRadius(dpEntity* entity, const std::string& name); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -143,7 +143,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		//Kill player if health == 0 | 		//Kill player if health == 0 | ||||||
| 		if (entity->GetIsDead()) { | 		if (entity->IsDead()) { | ||||||
| 			entity->Smash(entity->GetObjectID()); | 			entity->Smash(entity->GetObjectID()); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ void BaseEnemyApe::OnStartup(Entity* self) { | |||||||
|  |  | ||||||
| void BaseEnemyApe::OnDie(Entity* self, Entity* killer) { | void BaseEnemyApe::OnDie(Entity* self, Entity* killer) { | ||||||
| 	auto* anchor = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"QB")); | 	auto* anchor = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"QB")); | ||||||
| 	if (anchor != nullptr && !anchor->GetIsDead()) { | 	if (anchor != nullptr && !anchor->IsDead()) { | ||||||
| 		anchor->Smash(self->GetObjectID(), eKillType::SILENT); | 		anchor->Smash(self->GetObjectID(), eKillType::SILENT); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -152,13 +152,13 @@ void AmSkullkinDrill::FreezePlayer(Entity* self, Entity* player, bool bFreeze) { | |||||||
| 	auto StateChangeType = eStateChangeType::POP; | 	auto StateChangeType = eStateChangeType::POP; | ||||||
|  |  | ||||||
| 	if (bFreeze) { | 	if (bFreeze) { | ||||||
| 		if (player->GetIsDead()) { | 		if (player->IsDead()) { | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		StateChangeType = eStateChangeType::PUSH; | 		StateChangeType = eStateChangeType::PUSH; | ||||||
| 	} else { | 	} else { | ||||||
| 		if (player->GetIsDead()) { | 		if (player->IsDead()) { | ||||||
| 			// | 			// | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) { | |||||||
| 	auto team = self->GetVar<std::vector<LWOOBJID>>(u"BuilderTeam"); | 	auto team = self->GetVar<std::vector<LWOOBJID>>(u"BuilderTeam"); | ||||||
| 	for (auto memberID : team) { | 	for (auto memberID : team) { | ||||||
| 		auto member = EntityManager::Instance()->GetEntity(memberID); | 		auto member = EntityManager::Instance()->GetEntity(memberID); | ||||||
| 		if (member != nullptr && !member->GetIsDead()) { | 		if (member != nullptr && !member->IsDead()) { | ||||||
| 			GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); | 			GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); | ||||||
| 		} else { | 		} else { | ||||||
| 			// If player left the team or left early erase them from the team variable. | 			// If player left the team or left early erase them from the team variable. | ||||||
|   | |||||||
| @@ -312,7 +312,7 @@ bool BaseSurvivalServer::CheckAllPlayersDead() { | |||||||
|  |  | ||||||
| 	for (const auto& playerID : state.players) { | 	for (const auto& playerID : state.players) { | ||||||
| 		auto* player = EntityManager::Instance()->GetEntity(playerID); | 		auto* player = EntityManager::Instance()->GetEntity(playerID); | ||||||
| 		if (player == nullptr || player->GetIsDead()) { | 		if (player == nullptr || player->IsDead()) { | ||||||
| 			deadPlayers++; | 			deadPlayers++; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -310,7 +310,7 @@ bool BaseWavesServer::CheckAllPlayersDead() { | |||||||
|  |  | ||||||
| 	for (const auto& playerID : state.players) { | 	for (const auto& playerID : state.players) { | ||||||
| 		auto* player = EntityManager::Instance()->GetEntity(playerID); | 		auto* player = EntityManager::Instance()->GetEntity(playerID); | ||||||
| 		if (player == nullptr || player->GetIsDead()) { | 		if (player == nullptr || player->IsDead()) { | ||||||
| 			deadPlayers++; | 			deadPlayers++; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| @@ -430,7 +430,7 @@ void BaseWavesServer::SpawnWave(Entity* self) { | |||||||
|  |  | ||||||
| 		for (const auto& playerID : state.players) { | 		for (const auto& playerID : state.players) { | ||||||
| 			auto* player = EntityManager::Instance()->GetEntity(playerID); | 			auto* player = EntityManager::Instance()->GetEntity(playerID); | ||||||
| 			if (player && player->GetIsDead()) { | 			if (player && player->IsDead()) { | ||||||
| 				player->Resurrect(); | 				player->Resurrect(); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| @@ -500,7 +500,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3 | |||||||
|  |  | ||||||
| 		for (const auto& playerID : state.players) { | 		for (const auto& playerID : state.players) { | ||||||
| 			auto* player = EntityManager::Instance()->GetEntity(playerID); | 			auto* player = EntityManager::Instance()->GetEntity(playerID); | ||||||
| 			if (player != nullptr && !player->GetIsDead()) { | 			if (player != nullptr && !player->IsDead()) { | ||||||
| 				SetActivityValue(self, playerID, 1, currentTime); | 				SetActivityValue(self, playerID, 1, currentTime); | ||||||
| 				SetActivityValue(self, playerID, 2, state.waveNumber); | 				SetActivityValue(self, playerID, 2, state.waveNumber); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
| #include "SkillComponent.h" | #include "SkillComponent.h" | ||||||
|  |  | ||||||
| void CoilBackpackBase::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) { | void CoilBackpackBase::OnFactionTriggerItemEquipped(Entity* itemOwner, LWOOBJID itemObjId) { | ||||||
| 	itemOwner->Subscribe(itemObjId, this, "HitOrHealResult"); | 	itemOwner->Subscribe(this, "HitOrHealResult"); | ||||||
| 	itemOwner->SetVar<uint8_t>(u"coilCount", 0); | 	itemOwner->SetVar<uint8_t>(u"coilCount", 0); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -21,5 +21,5 @@ void CoilBackpackBase::NotifyHitOrHealResult(Entity* self, Entity* attacker, int | |||||||
| } | } | ||||||
|  |  | ||||||
| void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) { | void CoilBackpackBase::OnFactionTriggerItemUnequipped(Entity* itemOwner, LWOOBJID itemObjId) { | ||||||
| 	itemOwner->Unsubscribe(itemObjId, "HitOrHealResult"); | 	itemOwner->Unsubscribe(this, "HitOrHealResult"); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
| #include "Entity.h" | #include "Entity.h" | ||||||
|  |  | ||||||
| void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { | void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { | ||||||
| 	if (!target->IsPlayer() || target->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready | 	if (!target->IsPlayer() || target->IsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready | ||||||
|  |  | ||||||
| 	target->Smash(self->GetObjectID(), eKillType::SILENT); | 	target->Smash(self->GetObjectID(), eKillType::SILENT); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ void ActSharkPlayerDeathTrigger::OnFireEventServerSide(Entity* self, Entity* sen | |||||||
|  |  | ||||||
| 		missionComponent->Progress(eMissionTaskType::SCRIPT, 8419); | 		missionComponent->Progress(eMissionTaskType::SCRIPT, 8419); | ||||||
|  |  | ||||||
| 		if (sender->GetIsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready | 		if (sender->IsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready | ||||||
|  |  | ||||||
| 		if (sender->GetCharacter()) { | 		if (sender->GetCharacter()) { | ||||||
| 			sender->Smash(self->GetObjectID(), eKillType::VIOLENT, u"big-shark-death"); | 			sender->Smash(self->GetObjectID(), eKillType::VIOLENT, u"big-shark-death"); | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
| #include "Entity.h" | #include "Entity.h" | ||||||
|  |  | ||||||
| void AgShipPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { | void AgShipPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { | ||||||
| 	if (target->GetLOT() == 1 && !target->GetIsDead()) { | 	if (target->GetLOT() == 1 && !target->IsDead()) { | ||||||
| 		target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"electro-shock-death"); | 		target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"electro-shock-death"); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) { | |||||||
| 	if (timerName != this->m_TimerName) return; | 	if (timerName != this->m_TimerName) return; | ||||||
| 	auto players = self->GetVar<std::vector<Entity*>>(u"players"); | 	auto players = self->GetVar<std::vector<Entity*>>(u"players"); | ||||||
| 	for (auto player : players) { | 	for (auto player : players) { | ||||||
| 		if (player->GetIsDead() || !player){ | 		if (player->IsDead() || !player){ | ||||||
| 			auto position = std::find(players.begin(), players.end(), player); | 			auto position = std::find(players.begin(), players.end(), player); | ||||||
| 			if (position != players.end()) players.erase(position); | 			if (position != players.end()) players.erase(position); | ||||||
| 			continue; | 			continue; | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ void PetDigBuild::OnDie(Entity* self, Entity* killer) { | |||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	// If the quick build expired and the treasure was not collected, hide the treasure | 	// If the quick build expired and the treasure was not collected, hide the treasure | ||||||
| 	if (!treasure->GetIsDead()) { | 	if (!treasure->IsDead()) { | ||||||
| 		treasure->Smash(self->GetObjectID(), eKillType::SILENT); | 		treasure->Smash(self->GetObjectID(), eKillType::SILENT); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -27,7 +27,7 @@ void NsConcertInstrument::OnRebuildNotifyState(Entity* self, eRebuildState state | |||||||
| } | } | ||||||
|  |  | ||||||
| void NsConcertInstrument::OnRebuildComplete(Entity* self, Entity* target) { | void NsConcertInstrument::OnRebuildComplete(Entity* self, Entity* target) { | ||||||
| 	if (!target->GetIsDead()) { | 	if (!target->IsDead()) { | ||||||
| 		self->SetVar<LWOOBJID>(u"activePlayer", target->GetObjectID()); | 		self->SetVar<LWOOBJID>(u"activePlayer", target->GetObjectID()); | ||||||
|  |  | ||||||
| 		self->AddCallbackTimer(0.2f, [self, target]() { | 		self->AddCallbackTimer(0.2f, [self, target]() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 David Markowitz
					David Markowitz