mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-04-26 16:46:31 +00:00
Add comments, remove dead code etc.
This commit is contained in:
parent
a909546e2f
commit
e96eed5316
@ -10,6 +10,7 @@
|
|||||||
#include "SimplePhysicsComponent.h"
|
#include "SimplePhysicsComponent.h"
|
||||||
|
|
||||||
#include "Database.h"
|
#include "Database.h"
|
||||||
|
#include "DluAssert.h"
|
||||||
|
|
||||||
ModelComponent::ModelComponent(Entity* parent) : Component(parent) {
|
ModelComponent::ModelComponent(Entity* parent) : Component(parent) {
|
||||||
m_OriginalPosition = m_Parent->GetDefaultPosition();
|
m_OriginalPosition = m_Parent->GetDefaultPosition();
|
||||||
@ -36,9 +37,14 @@ bool ModelComponent::OnResetModelToDefaults(GameMessages::GameMsg& msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ModelComponent::OnRequestUse(GameMessages::GameMsg& msg) {
|
bool ModelComponent::OnRequestUse(GameMessages::GameMsg& msg) {
|
||||||
auto& requestUse = static_cast<GameMessages::RequestUse&>(msg);
|
bool toReturn = false;
|
||||||
for (auto& behavior : m_Behaviors) behavior.HandleMsg(requestUse);
|
if (!m_IsPaused) {
|
||||||
return true;
|
auto& requestUse = static_cast<GameMessages::RequestUse&>(msg);
|
||||||
|
for (auto& behavior : m_Behaviors) behavior.HandleMsg(requestUse);
|
||||||
|
toReturn = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelComponent::Update(float deltaTime) {
|
void ModelComponent::Update(float deltaTime) {
|
||||||
|
@ -127,10 +127,13 @@ public:
|
|||||||
|
|
||||||
void Resume();
|
void Resume();
|
||||||
private:
|
private:
|
||||||
|
// Whether or not this component needs to have its extra data serialized.
|
||||||
bool m_Dirty{};
|
bool m_Dirty{};
|
||||||
|
|
||||||
|
// The number of strips listening for a RequestUse GM to come in.
|
||||||
uint32_t m_NumListeningInteract{};
|
uint32_t m_NumListeningInteract{};
|
||||||
|
|
||||||
|
// Whether or not the model is paused and should reject all interactions regarding behaviors.
|
||||||
bool m_IsPaused{};
|
bool m_IsPaused{};
|
||||||
/**
|
/**
|
||||||
* The behaviors of the model
|
* The behaviors of the model
|
||||||
|
@ -221,8 +221,6 @@ bool PropertyManagementComponent::Claim(const LWOOBJID playerId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropertyManagementComponent::OnStartBuilding() {
|
void PropertyManagementComponent::OnStartBuilding() {
|
||||||
m_IsBuilding = true;
|
|
||||||
|
|
||||||
auto* ownerEntity = GetOwner();
|
auto* ownerEntity = GetOwner();
|
||||||
|
|
||||||
if (ownerEntity == nullptr) return;
|
if (ownerEntity == nullptr) return;
|
||||||
@ -270,8 +268,6 @@ void PropertyManagementComponent::OnStartBuilding() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PropertyManagementComponent::OnFinishBuilding() {
|
void PropertyManagementComponent::OnFinishBuilding() {
|
||||||
m_IsBuilding = false;
|
|
||||||
|
|
||||||
auto* ownerEntity = GetOwner();
|
auto* ownerEntity = GetOwner();
|
||||||
|
|
||||||
if (ownerEntity == nullptr) return;
|
if (ownerEntity == nullptr) return;
|
||||||
|
@ -239,6 +239,4 @@ private:
|
|||||||
* The privacy setting before it was changed, saved to set back after a player finishes building
|
* The privacy setting before it was changed, saved to set back after a player finishes building
|
||||||
*/
|
*/
|
||||||
PropertyPrivacyOption originalPrivacyOption = PropertyPrivacyOption::Private;
|
PropertyPrivacyOption originalPrivacyOption = PropertyPrivacyOption::Private;
|
||||||
|
|
||||||
bool m_IsBuilding{};
|
|
||||||
};
|
};
|
||||||
|
@ -169,11 +169,6 @@ void PropertyBehavior::Deserialize(const tinyxml2::XMLElement& behavior) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const State& PropertyBehavior::GetState(const BehaviorState state) {
|
|
||||||
DluAssert(state >= BehaviorState::HOME_STATE && state <= BehaviorState::STAR_STATE);
|
|
||||||
return m_States[state];
|
|
||||||
}
|
|
||||||
|
|
||||||
void PropertyBehavior::Update(float deltaTime, ModelComponent& modelComponent) {
|
void PropertyBehavior::Update(float deltaTime, ModelComponent& modelComponent) {
|
||||||
for (auto& state : m_States | std::views::values) state.Update(deltaTime, modelComponent);
|
for (auto& state : m_States | std::views::values) state.Update(deltaTime, modelComponent);
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,10 @@ public:
|
|||||||
void Serialize(tinyxml2::XMLElement& behavior) const;
|
void Serialize(tinyxml2::XMLElement& behavior) const;
|
||||||
void Deserialize(const tinyxml2::XMLElement& behavior);
|
void Deserialize(const tinyxml2::XMLElement& behavior);
|
||||||
|
|
||||||
const std::map<BehaviorState, State>& GetStates() const { return m_States; }
|
|
||||||
const State& GetState(const BehaviorState state);
|
|
||||||
const State& GetActiveState() const { return m_States.at(m_ActiveState); }
|
|
||||||
State& GetActiveStateMut() { return m_States.at(m_ActiveState); }
|
|
||||||
|
|
||||||
void Update(float deltaTime, ModelComponent& modelComponent);
|
void Update(float deltaTime, ModelComponent& modelComponent);
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
// The current active behavior state. Behaviors can only be in ONE state at a time.
|
||||||
BehaviorState m_ActiveState;
|
BehaviorState m_ActiveState;
|
||||||
|
|
||||||
// The states this behavior has.
|
// The states this behavior has.
|
||||||
|
@ -21,11 +21,10 @@ public:
|
|||||||
void Serialize(tinyxml2::XMLElement& state) const;
|
void Serialize(tinyxml2::XMLElement& state) const;
|
||||||
void Deserialize(const tinyxml2::XMLElement& state);
|
void Deserialize(const tinyxml2::XMLElement& state);
|
||||||
|
|
||||||
const std::vector<Strip>& GetStrips() const { return m_Strips; }
|
|
||||||
std::vector<Strip>& GetStripsMut() { return m_Strips; }
|
|
||||||
|
|
||||||
void Update(float deltaTime, ModelComponent& modelComponent);
|
void Update(float deltaTime, ModelComponent& modelComponent);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
// The strips contained within this state.
|
||||||
std::vector<Strip> m_Strips;
|
std::vector<Strip> m_Strips;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
#include "ModelComponent.h"
|
#include "ModelComponent.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
|
|
||||||
|
#include "DluAssert.h"
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
void Strip::HandleMsg(AddStripMessage& msg) {
|
void Strip::HandleMsg(AddStripMessage& msg) {
|
||||||
m_Actions = msg.GetActionsToAdd();
|
m_Actions = msg.GetActionsToAdd();
|
||||||
@ -105,7 +107,7 @@ void Strip::IncrementAction() {
|
|||||||
|
|
||||||
void Strip::Spawn(LOT lot, Entity& entity) {
|
void Strip::Spawn(LOT lot, Entity& entity) {
|
||||||
EntityInfo info{};
|
EntityInfo info{};
|
||||||
info.lot = lot; // Dark Ronin property
|
info.lot = lot;
|
||||||
info.pos = entity.GetPosition();
|
info.pos = entity.GetPosition();
|
||||||
info.rot = NiQuaternionConstant::IDENTITY;
|
info.rot = NiQuaternionConstant::IDENTITY;
|
||||||
info.spawnerID = entity.GetObjectID();
|
info.spawnerID = entity.GetObjectID();
|
||||||
@ -126,17 +128,17 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
|||||||
auto numberAsInt = static_cast<int32_t>(number);
|
auto numberAsInt = static_cast<int32_t>(number);
|
||||||
auto nextActionType = GetNextAction().GetType();
|
auto nextActionType = GetNextAction().GetType();
|
||||||
if (nextActionType == "SpawnStromling") {
|
if (nextActionType == "SpawnStromling") {
|
||||||
Spawn(10495, entity);
|
Spawn(10495, entity); // Stromling property
|
||||||
} else if (nextActionType == "SpawnPirate") {
|
} else if (nextActionType == "SpawnPirate") {
|
||||||
Spawn(10497, entity);
|
Spawn(10497, entity); // Maelstrom Pirate property
|
||||||
} else if (nextActionType == "SpawnRonin") {
|
} else if (nextActionType == "SpawnRonin") {
|
||||||
Spawn(10498, entity);
|
Spawn(10498, entity); // Dark Ronin property
|
||||||
} else if (nextActionType == "DropImagination") {
|
} else if (nextActionType == "DropImagination") {
|
||||||
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(935, entity);
|
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(935, entity); // 1 Imagination powerup
|
||||||
} else if (nextActionType == "DropHealth") {
|
} else if (nextActionType == "DropHealth") {
|
||||||
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(177, entity);
|
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(177, entity); // 1 Life powerup
|
||||||
} else if (nextActionType == "DropArmor") {
|
} else if (nextActionType == "DropArmor") {
|
||||||
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(6431, entity);
|
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(6431, entity); // 1 Armor powerup
|
||||||
} else if (nextActionType == "Smash") {
|
} else if (nextActionType == "Smash") {
|
||||||
GameMessages::Smash smash{};
|
GameMessages::Smash smash{};
|
||||||
smash.target = entity.GetObjectID();
|
smash.target = entity.GetObjectID();
|
||||||
@ -157,10 +159,10 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
|||||||
sound.soundID = numberAsInt;
|
sound.soundID = numberAsInt;
|
||||||
sound.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
sound.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
} else {
|
} else {
|
||||||
static std::set<std::string> g_PlayedSounds;
|
static std::set<std::string> g_WarnedActions;
|
||||||
if (!g_PlayedSounds.contains(nextActionType.data())) {
|
if (!g_WarnedActions.contains(nextActionType.data())) {
|
||||||
LOG("Tried to play action (%s) which is not supported.", nextActionType.data());
|
LOG("Tried to play action (%s) which is not supported.", nextActionType.data());
|
||||||
g_PlayedSounds.insert(nextActionType.data());
|
g_WarnedActions.insert(nextActionType.data());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -235,6 +237,10 @@ void Strip::Deserialize(const tinyxml2::XMLElement& strip) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Action& Strip::GetNextAction() const {
|
||||||
|
DluAssert(m_NextActionIndex < m_Actions.size()); return m_Actions[m_NextActionIndex];
|
||||||
|
}
|
||||||
|
|
||||||
const Action& Strip::GetPreviousAction() const {
|
const Action& Strip::GetPreviousAction() const {
|
||||||
DluAssert(m_NextActionIndex < m_Actions.size());
|
DluAssert(m_NextActionIndex < m_Actions.size());
|
||||||
size_t index = m_NextActionIndex == 0 ? m_Actions.size() - 1 : m_NextActionIndex - 1;
|
size_t index = m_NextActionIndex == 0 ? m_Actions.size() - 1 : m_NextActionIndex - 1;
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
#include "Action.h"
|
#include "Action.h"
|
||||||
#include "StripUiPosition.h"
|
#include "StripUiPosition.h"
|
||||||
|
|
||||||
#include "DluAssert.h"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace tinyxml2 {
|
namespace tinyxml2 {
|
||||||
@ -26,8 +24,7 @@ public:
|
|||||||
void Serialize(tinyxml2::XMLElement& strip) const;
|
void Serialize(tinyxml2::XMLElement& strip) const;
|
||||||
void Deserialize(const tinyxml2::XMLElement& strip);
|
void Deserialize(const tinyxml2::XMLElement& strip);
|
||||||
|
|
||||||
const std::vector<Action>& GetActions() const { return m_Actions; }
|
const Action& GetNextAction() const;
|
||||||
const Action& GetNextAction() const { DluAssert(m_NextActionIndex < m_Actions.size()); return m_Actions[m_NextActionIndex]; }
|
|
||||||
const Action& GetPreviousAction() const;
|
const Action& GetPreviousAction() const;
|
||||||
|
|
||||||
void IncrementAction();
|
void IncrementAction();
|
||||||
@ -37,10 +34,19 @@ public:
|
|||||||
void ProcNormalAction(float deltaTime, ModelComponent& modelComponent);
|
void ProcNormalAction(float deltaTime, ModelComponent& modelComponent);
|
||||||
void RemoveStates(ModelComponent& modelComponent) const;
|
void RemoveStates(ModelComponent& modelComponent) const;
|
||||||
private:
|
private:
|
||||||
|
// Indicates this Strip is waiting for an action to be taken upon it to progress to its actions
|
||||||
bool m_WaitingForAction{ false };
|
bool m_WaitingForAction{ false };
|
||||||
|
|
||||||
|
// The amount of time this strip is paused for. Any interactions with this strip should be bounced if this is greater than 0.
|
||||||
float m_PausedTime{ 0.0f };
|
float m_PausedTime{ 0.0f };
|
||||||
|
|
||||||
|
// The index of the next action to be played. This should always be within range of [0, m_Actions.size()).
|
||||||
size_t m_NextActionIndex{ 0 };
|
size_t m_NextActionIndex{ 0 };
|
||||||
|
|
||||||
|
// The list of actions to be executed on this behavior.
|
||||||
std::vector<Action> m_Actions;
|
std::vector<Action> m_Actions;
|
||||||
|
|
||||||
|
// The location of this strip on the UGBehaviorEditor UI
|
||||||
StripUiPosition m_Position;
|
StripUiPosition m_Position;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user