mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-11-30 13:18:17 +00:00
Add comments, remove dead code etc.
This commit is contained in:
@@ -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) {
|
||||
for (auto& state : m_States | std::views::values) state.Update(deltaTime, modelComponent);
|
||||
}
|
||||
|
||||
@@ -33,14 +33,10 @@ public:
|
||||
void Serialize(tinyxml2::XMLElement& behavior) const;
|
||||
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);
|
||||
private:
|
||||
|
||||
private:
|
||||
// The current active behavior state. Behaviors can only be in ONE state at a time.
|
||||
BehaviorState m_ActiveState;
|
||||
|
||||
// The states this behavior has.
|
||||
|
||||
@@ -21,11 +21,10 @@ public:
|
||||
void Serialize(tinyxml2::XMLElement& state) const;
|
||||
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);
|
||||
private:
|
||||
|
||||
// The strips contained within this state.
|
||||
std::vector<Strip> m_Strips;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "ModelComponent.h"
|
||||
#include "PlayerManager.h"
|
||||
|
||||
#include "DluAssert.h"
|
||||
|
||||
template <>
|
||||
void Strip::HandleMsg(AddStripMessage& msg) {
|
||||
m_Actions = msg.GetActionsToAdd();
|
||||
@@ -105,7 +107,7 @@ void Strip::IncrementAction() {
|
||||
|
||||
void Strip::Spawn(LOT lot, Entity& entity) {
|
||||
EntityInfo info{};
|
||||
info.lot = lot; // Dark Ronin property
|
||||
info.lot = lot;
|
||||
info.pos = entity.GetPosition();
|
||||
info.rot = NiQuaternionConstant::IDENTITY;
|
||||
info.spawnerID = entity.GetObjectID();
|
||||
@@ -126,17 +128,17 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
||||
auto numberAsInt = static_cast<int32_t>(number);
|
||||
auto nextActionType = GetNextAction().GetType();
|
||||
if (nextActionType == "SpawnStromling") {
|
||||
Spawn(10495, entity);
|
||||
Spawn(10495, entity); // Stromling property
|
||||
} else if (nextActionType == "SpawnPirate") {
|
||||
Spawn(10497, entity);
|
||||
Spawn(10497, entity); // Maelstrom Pirate property
|
||||
} else if (nextActionType == "SpawnRonin") {
|
||||
Spawn(10498, entity);
|
||||
Spawn(10498, entity); // Dark Ronin property
|
||||
} 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") {
|
||||
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(177, entity);
|
||||
for (; numberAsInt > 0; numberAsInt--) SpawnDrop(177, entity); // 1 Life powerup
|
||||
} 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") {
|
||||
GameMessages::Smash smash{};
|
||||
smash.target = entity.GetObjectID();
|
||||
@@ -157,10 +159,10 @@ void Strip::ProcNormalAction(float deltaTime, ModelComponent& modelComponent) {
|
||||
sound.soundID = numberAsInt;
|
||||
sound.Send(UNASSIGNED_SYSTEM_ADDRESS);
|
||||
} else {
|
||||
static std::set<std::string> g_PlayedSounds;
|
||||
if (!g_PlayedSounds.contains(nextActionType.data())) {
|
||||
static std::set<std::string> g_WarnedActions;
|
||||
if (!g_WarnedActions.contains(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;
|
||||
}
|
||||
@@ -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 {
|
||||
DluAssert(m_NextActionIndex < m_Actions.size());
|
||||
size_t index = m_NextActionIndex == 0 ? m_Actions.size() - 1 : m_NextActionIndex - 1;
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include "Action.h"
|
||||
#include "StripUiPosition.h"
|
||||
|
||||
#include "DluAssert.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace tinyxml2 {
|
||||
@@ -26,8 +24,7 @@ public:
|
||||
void Serialize(tinyxml2::XMLElement& strip) const;
|
||||
void Deserialize(const tinyxml2::XMLElement& strip);
|
||||
|
||||
const std::vector<Action>& GetActions() const { return m_Actions; }
|
||||
const Action& GetNextAction() const { DluAssert(m_NextActionIndex < m_Actions.size()); return m_Actions[m_NextActionIndex]; }
|
||||
const Action& GetNextAction() const;
|
||||
const Action& GetPreviousAction() const;
|
||||
|
||||
void IncrementAction();
|
||||
@@ -37,10 +34,19 @@ public:
|
||||
void ProcNormalAction(float deltaTime, ModelComponent& modelComponent);
|
||||
void RemoveStates(ModelComponent& modelComponent) const;
|
||||
private:
|
||||
// Indicates this Strip is waiting for an action to be taken upon it to progress to its actions
|
||||
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 };
|
||||
|
||||
// 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 };
|
||||
|
||||
// The list of actions to be executed on this behavior.
|
||||
std::vector<Action> m_Actions;
|
||||
|
||||
// The location of this strip on the UGBehaviorEditor UI
|
||||
StripUiPosition m_Position;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user