mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
remove unneeded Component.cpp, forward declare dependencies, and make Component definition header-only (#1688)
This commit is contained in:
parent
fced6d753a
commit
0ae9eb4a96
@ -7,7 +7,6 @@ set(DGAME_DCOMPONENTS_SOURCES
|
|||||||
"BuildBorderComponent.cpp"
|
"BuildBorderComponent.cpp"
|
||||||
"CharacterComponent.cpp"
|
"CharacterComponent.cpp"
|
||||||
"CollectibleComponent.cpp"
|
"CollectibleComponent.cpp"
|
||||||
"Component.cpp"
|
|
||||||
"ControllablePhysicsComponent.cpp"
|
"ControllablePhysicsComponent.cpp"
|
||||||
"DestroyableComponent.cpp"
|
"DestroyableComponent.cpp"
|
||||||
"DonationVendorComponent.cpp"
|
"DonationVendorComponent.cpp"
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
#include "Component.h"
|
|
||||||
|
|
||||||
|
|
||||||
Component::Component(Entity* parent) {
|
|
||||||
m_Parent = parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
Component::~Component() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Entity* Component::GetParent() const {
|
|
||||||
return m_Parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Component::Update(float deltaTime) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Component::OnUse(Entity* originator) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Component::UpdateXml(tinyxml2::XMLDocument& doc) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Component::LoadFromXml(const tinyxml2::XMLDocument& doc) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Component::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "tinyxml2.h"
|
namespace tinyxml2 {
|
||||||
|
class XMLDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace RakNet {
|
||||||
|
class BitStream;
|
||||||
|
}
|
||||||
|
|
||||||
class Entity;
|
class Entity;
|
||||||
|
|
||||||
@ -9,40 +15,40 @@ class Entity;
|
|||||||
*/
|
*/
|
||||||
class Component {
|
class Component {
|
||||||
public:
|
public:
|
||||||
Component(Entity* parent);
|
Component(Entity* parent) : m_Parent{ parent } {}
|
||||||
virtual ~Component();
|
virtual ~Component() = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the owner of this component
|
* Gets the owner of this component
|
||||||
* @return the owner of this component
|
* @return the owner of this component
|
||||||
*/
|
*/
|
||||||
Entity* GetParent() const;
|
Entity* GetParent() const { return m_Parent; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the component in the game loop
|
* Updates the component in the game loop
|
||||||
* @param deltaTime time passed since last update
|
* @param deltaTime time passed since last update
|
||||||
*/
|
*/
|
||||||
virtual void Update(float deltaTime);
|
virtual void Update(float deltaTime) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event called when this component is being used, e.g. when some entity interacted with it
|
* Event called when this component is being used, e.g. when some entity interacted with it
|
||||||
* @param originator
|
* @param originator
|
||||||
*/
|
*/
|
||||||
virtual void OnUse(Entity* originator);
|
virtual void OnUse(Entity* originator) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save data from this componennt to character XML
|
* Save data from this componennt to character XML
|
||||||
* @param doc the document to write data to
|
* @param doc the document to write data to
|
||||||
*/
|
*/
|
||||||
virtual void UpdateXml(tinyxml2::XMLDocument& doc);
|
virtual void UpdateXml(tinyxml2::XMLDocument& doc) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load base data for this component from character XML
|
* Load base data for this component from character XML
|
||||||
* @param doc the document to read data from
|
* @param doc the document to read data from
|
||||||
*/
|
*/
|
||||||
virtual void LoadFromXml(const tinyxml2::XMLDocument& doc);
|
virtual void LoadFromXml(const tinyxml2::XMLDocument& doc) {}
|
||||||
|
|
||||||
virtual void Serialize(RakNet::BitStream& outBitStream, bool isConstruction);
|
virtual void Serialize(RakNet::BitStream& outBitStream, bool isConstruction) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user