mirror of
				https://github.com/DarkflameUniverse/DarkflameServer.git
				synced 2025-10-30 20:22:04 +00:00 
			
		
		
		
	Merge branch 'item-component' into components-wheeeee
This commit is contained in:
		
							
								
								
									
										14
									
								
								dCommon/dEnums/ePhysicsBehaviorType.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								dCommon/dEnums/ePhysicsBehaviorType.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| #ifndef __EPHYSICSBEHAVIORTYPE__H__ | ||||
| #define __EPHYSICSBEHAVIORTYPE__H__ | ||||
|  | ||||
| #include <cstdint> | ||||
|  | ||||
| enum class ePhysicsBehaviorType : int32_t { | ||||
| 	INVALID = -1, | ||||
| 	GROUND, | ||||
| 	FLYING, | ||||
| 	STANDARD, | ||||
| 	DYNAMIC | ||||
| }; | ||||
|  | ||||
| #endif  //!__EPHYSICSBEHAVIORTYPE__H__ | ||||
							
								
								
									
										13
									
								
								dCommon/dEnums/eUgcModerationStatus.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								dCommon/dEnums/eUgcModerationStatus.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
|  | ||||
| #ifndef __EUGCMODERATIONSTATUS__H__ | ||||
| #define __EUGCMODERATIONSTATUS__H__ | ||||
|  | ||||
| #include <cstdint> | ||||
|  | ||||
| enum class eUgcModerationStatus : uint32_t { | ||||
| 	NoStatus, | ||||
| 	Approved, | ||||
| 	Rejected, | ||||
| }; | ||||
|  | ||||
| #endif  //!__EUGCMODERATIONSTATUS__H__ | ||||
| @@ -22,6 +22,7 @@ set(DGAME_DCOMPONENTS_SOURCES "AchievementVendorComponent.cpp" | ||||
| 	"ModuleAssemblyComponent.cpp" | ||||
| 	"MovementAIComponent.cpp" | ||||
| 	"MovingPlatformComponent.cpp" | ||||
| 	"MutableModelBehaviorComponent.cpp" | ||||
| 	"PetComponent.cpp" | ||||
| 	"PhantomPhysicsComponent.cpp" | ||||
| 	"PlayerForcedMovementComponent.cpp" | ||||
|   | ||||
| @@ -1,5 +1,33 @@ | ||||
| #include "ItemComponent.h" | ||||
| #include "Entity.h" | ||||
| #include "eUgcModerationStatus.h" | ||||
|  | ||||
|  | ||||
| ItemComponent::ItemComponent(Entity* parent) : Component(parent) { | ||||
| 	m_Parent = parent; | ||||
|  | ||||
| 	m_DirtyItemInfo = false; | ||||
|  | ||||
| 	m_UgId = m_Parent->GetVarAs<LWOOBJID>(u"userModelID"); | ||||
| 	if (m_UgId == LWOOBJID_EMPTY) m_UgId = m_Parent->GetObjectID(); | ||||
|  | ||||
| 	m_UgModerationStatus = eUgcModerationStatus::NoStatus; | ||||
|  | ||||
| 	m_UgDescription = u""; | ||||
| } | ||||
|  | ||||
| void ItemComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { | ||||
|  | ||||
| 	outBitStream->Write(m_DirtyItemInfo || bIsInitialUpdate); | ||||
| 	if (m_DirtyItemInfo || bIsInitialUpdate){ | ||||
| 		outBitStream->Write(m_UgId); | ||||
| 		outBitStream->Write(m_UgModerationStatus); | ||||
| 		outBitStream->Write(m_UgDescription != u""); | ||||
| 		if (m_UgDescription != u""){ | ||||
| 			outBitStream->Write<uint32_t>(m_UgDescription.length()); | ||||
| 			for (uint16_t character : m_UgDescription) outBitStream->Write(character); | ||||
| 		} | ||||
| 		m_DirtyItemInfo = false; | ||||
| 	} | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -1,15 +1,50 @@ | ||||
| #ifndef __ITEMCOMPONENT__H__ | ||||
| #define __ITEMCOMPONENT__H__ | ||||
|  | ||||
| #pragma once | ||||
| #include "dCommonVars.h" | ||||
| #include "RakNetTypes.h" | ||||
| #include "NiPoint3.h" | ||||
| #include "NiQuaternion.h" | ||||
| #include "Component.h" | ||||
| #include "eReplicaComponentType.h" | ||||
|  | ||||
| class Entity; | ||||
| enum class eUgcModerationStatus : uint32_t; | ||||
|  | ||||
| class ItemComponent : public Component { | ||||
| public: | ||||
| 	inline static const eReplicaComponentType ComponentType = eReplicaComponentType::ITEM; | ||||
| 	ItemComponent(Entity* parent); | ||||
| }; | ||||
| 	static const eReplicaComponentType ComponentType = eReplicaComponentType::ITEM; | ||||
|  | ||||
| #endif  //!__ITEMCOMPONENT__H__ | ||||
| 	ItemComponent(Entity* parent); | ||||
|  | ||||
| 	void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); | ||||
|  | ||||
| 	void SetUgId(LWOOBJID id) { m_UgId = id; m_DirtyItemInfo = true; }; | ||||
| 	LWOOBJID GetUgId() { return m_UgId; }; | ||||
|  | ||||
| 	void SetUgModerationStatus(eUgcModerationStatus status) { m_UgModerationStatus = status; m_DirtyItemInfo = true; }; | ||||
| 	eUgcModerationStatus GetUgModerationStatus() { return m_UgModerationStatus; }; | ||||
|  | ||||
| 	void SetUgDescription(std::u16string description) { m_UgDescription = description; m_DirtyItemInfo = true; }; | ||||
| 	std::u16string  GetUgDescription() { return m_UgDescription;}; | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	/** | ||||
| 	 * If we have change the item info | ||||
| 	 */ | ||||
| 	bool m_DirtyItemInfo; | ||||
|  | ||||
| 	/** | ||||
| 	 * The ID of the user that made the model | ||||
| 	 */ | ||||
| 	LWOOBJID m_UgId; | ||||
|  | ||||
| 	/** | ||||
| 	 * | ||||
| 	 */ | ||||
| 	eUgcModerationStatus m_UgModerationStatus; | ||||
|  | ||||
| 	/** | ||||
| 	 * The user generated description | ||||
| 	 */ | ||||
| 	std::u16string m_UgDescription; | ||||
| }; | ||||
|   | ||||
| @@ -1,31 +1,23 @@ | ||||
| #include "ModelBehaviorComponent.h" | ||||
| #include "Entity.h" | ||||
| #include "ePhysicsBehaviorType.h" | ||||
|  | ||||
| ModelBehaviorComponent::ModelBehaviorComponent(Entity* parent) : Component(parent) { | ||||
| 	m_DirtyModelInfo = false; | ||||
| 	m_IsPickable = false; | ||||
| 	m_PhysicsType = ePhysicsBehaviorType::STANDARD; | ||||
| 	m_OriginalPosition = m_ParentEntity->GetDefaultPosition(); | ||||
| 	m_OriginalRotation = m_ParentEntity->GetDefaultRotation(); | ||||
|  | ||||
| 	m_userModelID = m_ParentEntity->GetVarAs<LWOOBJID>(u"userModelID"); | ||||
| } | ||||
|  | ||||
| void ModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { | ||||
| 	// ItemComponent Serialization.  Pets do not get this serialization. | ||||
| 	if (!m_ParentEntity->HasComponent(eReplicaComponentType::PET)) { | ||||
| 		outBitStream->Write1(); | ||||
| 		outBitStream->Write<LWOOBJID>(m_userModelID != LWOOBJID_EMPTY ? m_userModelID : m_ParentEntity->GetObjectID()); | ||||
| 		outBitStream->Write<int>(0); | ||||
| 		outBitStream->Write0(); | ||||
| 	outBitStream->Write(m_DirtyModelInfo || bIsInitialUpdate); | ||||
| 	if (m_DirtyModelInfo || bIsInitialUpdate) { | ||||
| 		outBitStream->Write(m_IsPickable); | ||||
| 		outBitStream->Write(m_PhysicsType); | ||||
| 		outBitStream->Write(m_OriginalPosition); | ||||
| 		outBitStream->Write(m_OriginalRotation); | ||||
| 		m_DirtyModelInfo = false; | ||||
| 	} | ||||
|  | ||||
| 	//actual model component: | ||||
| 	outBitStream->Write1(); // Yes we are writing model info | ||||
| 	outBitStream->Write0(); // Is pickable | ||||
| 	outBitStream->Write<uint32_t>(2); // Physics type | ||||
| 	outBitStream->Write(m_OriginalPosition); // Original position | ||||
| 	outBitStream->Write(m_OriginalRotation); // Original rotation | ||||
|  | ||||
| 	outBitStream->Write1(); // We are writing behavior info | ||||
| 	outBitStream->Write<uint32_t>(0); // Number of behaviors | ||||
| 	outBitStream->Write1(); // Is this model paused | ||||
| 	if (bIsInitialUpdate) outBitStream->Write0(); // We are not writing model editing info | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -7,6 +7,7 @@ | ||||
| #include "eReplicaComponentType.h" | ||||
|  | ||||
| class Entity; | ||||
| enum class ePhysicsBehaviorType : int32_t; | ||||
|  | ||||
| /** | ||||
|  * Component that represents entities that are a model, e.g. collectible models and BBB models. | ||||
| @@ -29,7 +30,7 @@ public: | ||||
| 	 * Sets the original position of the model | ||||
| 	 * @param pos the original position to set | ||||
| 	 */ | ||||
| 	void SetPosition(const NiPoint3& pos) { m_OriginalPosition = pos; } | ||||
| 	void SetPosition(const NiPoint3& pos) { m_OriginalPosition = pos; m_DirtyModelInfo = true; } | ||||
|  | ||||
| 	/** | ||||
| 	 * Returns the original rotation of the model | ||||
| @@ -41,10 +42,25 @@ public: | ||||
| 	 * Sets the original rotation of the model | ||||
| 	 * @param rot the original rotation to set | ||||
| 	 */ | ||||
| 	void SetRotation(const NiQuaternion& rot) { m_OriginalRotation = rot; } | ||||
| 	void SetRotation(const NiQuaternion& rot) { m_OriginalRotation = rot; m_DirtyModelInfo = true; } | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	/** | ||||
| 	 * if the model info has changed | ||||
| 	 */ | ||||
| 	bool m_DirtyModelInfo; | ||||
|  | ||||
| 	/** | ||||
| 	 * If the model is pickable | ||||
| 	 */ | ||||
| 	bool m_IsPickable; | ||||
|  | ||||
| 	/** | ||||
| 	 * the phsyics type of the model | ||||
| 	 */ | ||||
| 	ePhysicsBehaviorType m_PhysicsType; | ||||
|  | ||||
| 	/** | ||||
| 	 * The original position of the model | ||||
| 	 */ | ||||
| @@ -55,8 +71,4 @@ private: | ||||
| 	 */ | ||||
| 	NiQuaternion m_OriginalRotation; | ||||
|  | ||||
| 	/** | ||||
| 	 * The ID of the user that made the model | ||||
| 	 */ | ||||
| 	LWOOBJID m_userModelID; | ||||
| }; | ||||
|   | ||||
							
								
								
									
										30
									
								
								dGame/dComponents/MutableModelBehaviorComponent.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								dGame/dComponents/MutableModelBehaviorComponent.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| #include "MutableModelBehaviorComponent.h" | ||||
| #include "Entity.h" | ||||
|  | ||||
| MutableModelBehaviorComponent::MutableModelBehaviorComponent(Entity* parent) : Component(parent) { | ||||
| 	m_DirtyModelBehaviorInfo = false; | ||||
| 	m_BehaviorCount = 0; | ||||
| 	m_IsPaused = true; | ||||
|  | ||||
| 	m_DirtyModelEditingInfo = false; | ||||
| 	m_OldObjId = LWOOBJID_EMPTY; | ||||
| 	m_Editor = LWOOBJID_EMPTY; | ||||
|  | ||||
| } | ||||
|  | ||||
| void MutableModelBehaviorComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags) { | ||||
| 	outBitStream->Write(m_DirtyModelBehaviorInfo || bIsInitialUpdate); | ||||
| 	if (m_DirtyModelBehaviorInfo){ | ||||
| 		outBitStream->Write(m_BehaviorCount); | ||||
| 		outBitStream->Write(m_IsPaused); | ||||
| 		m_DirtyModelBehaviorInfo = false; | ||||
| 	} | ||||
|  | ||||
| 	outBitStream->Write(m_DirtyModelEditingInfo && bIsInitialUpdate); | ||||
| 	if (m_DirtyModelEditingInfo && bIsInitialUpdate) { | ||||
| 		outBitStream->Write(m_OldObjId); | ||||
| 		outBitStream->Write(m_Editor); | ||||
| 		m_DirtyModelEditingInfo = false; | ||||
| 	} | ||||
| } | ||||
|  | ||||
							
								
								
									
										53
									
								
								dGame/dComponents/MutableModelBehaviorComponent.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								dGame/dComponents/MutableModelBehaviorComponent.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| #pragma once | ||||
| #include "dCommonVars.h" | ||||
| #include "RakNetTypes.h" | ||||
| #include "NiPoint3.h" | ||||
| #include "NiQuaternion.h" | ||||
| #include "Component.h" | ||||
| #include "eReplicaComponentType.h" | ||||
|  | ||||
| class Entity; | ||||
|  | ||||
| /** | ||||
|  * Component that represents entities that are a model, e.g. collectible models and BBB models. | ||||
|  */ | ||||
| class MutableModelBehaviorComponent : public Component { | ||||
| public: | ||||
| 	static const eReplicaComponentType ComponentType = eReplicaComponentType::MODEL; | ||||
|  | ||||
| 	MutableModelBehaviorComponent(Entity* parent); | ||||
|  | ||||
| 	void Serialize(RakNet::BitStream* outBitStream, bool bIsInitialUpdate, unsigned int& flags); | ||||
|  | ||||
| private: | ||||
|  | ||||
| 	/** | ||||
| 	 * if the behavior info has changed | ||||
| 	 */ | ||||
| 	bool m_DirtyModelBehaviorInfo; | ||||
|  | ||||
| 	/** | ||||
| 	 * The number of behaviors on the model | ||||
| 	 */ | ||||
| 	uint32_t m_BehaviorCount; | ||||
|  | ||||
| 	/** | ||||
| 	 * if the models behaviors are paused | ||||
| 	 */ | ||||
| 	bool m_IsPaused; | ||||
|  | ||||
| 	/** | ||||
| 	 * if the editing info is dirty | ||||
| 	 */ | ||||
| 	bool m_DirtyModelEditingInfo; | ||||
|  | ||||
| 	/** | ||||
| 	 * The old ID of the model | ||||
| 	 */ | ||||
| 	LWOOBJID m_OldObjId; | ||||
|  | ||||
| 	/** | ||||
| 	 * The ID of the editor of the model | ||||
| 	 */ | ||||
| 	LWOOBJID m_Editor; | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user
	 Aaron Kimbre
					Aaron Kimbre