mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 22:27:43 +00:00
New code style refactor
This commit is contained in:
@@ -2,81 +2,67 @@
|
||||
#include "CStateManager.hpp"
|
||||
#include "TCastTo.hpp"
|
||||
|
||||
namespace urde
|
||||
{
|
||||
namespace urde {
|
||||
|
||||
CScriptCounter::CScriptCounter(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
||||
s32 initial, s32 max, bool autoReset, bool active)
|
||||
CScriptCounter::CScriptCounter(TUniqueId uid, std::string_view name, const CEntityInfo& info, s32 initial, s32 max,
|
||||
bool autoReset, bool active)
|
||||
: CEntity(uid, info, active, name)
|
||||
, x34_initial(initial)
|
||||
, x38_current(initial)
|
||||
, x3c_max(max)
|
||||
, x40_autoReset(autoReset)
|
||||
{
|
||||
}
|
||||
, x40_autoReset(autoReset) {}
|
||||
|
||||
void CScriptCounter::Accept(IVisitor& visitor)
|
||||
{
|
||||
visitor.Visit(this);
|
||||
}
|
||||
void CScriptCounter::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||
|
||||
void CScriptCounter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case EScriptObjectMessage::SetToZero:
|
||||
if (GetActive())
|
||||
{
|
||||
x38_current = 0;
|
||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||
void CScriptCounter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
|
||||
switch (msg) {
|
||||
case EScriptObjectMessage::SetToZero:
|
||||
if (GetActive()) {
|
||||
x38_current = 0;
|
||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::SetToMax:
|
||||
if (GetActive())
|
||||
{
|
||||
x38_current = x3c_max;
|
||||
SendScriptMsgs(EScriptObjectState::MaxReached, stateMgr, EScriptObjectMessage::None);
|
||||
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Decrement:
|
||||
if (GetActive() && x38_current > 0)
|
||||
{
|
||||
--x38_current;
|
||||
if (x38_current == 0)
|
||||
{
|
||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Increment:
|
||||
if (GetActive() && x38_current < x3c_max)
|
||||
{
|
||||
++x38_current;
|
||||
if (x38_current >= x3c_max)
|
||||
{
|
||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Reset:
|
||||
if (GetActive())
|
||||
x38_current = x34_initial;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::SetToMax:
|
||||
if (GetActive()) {
|
||||
x38_current = x3c_max;
|
||||
SendScriptMsgs(EScriptObjectState::MaxReached, stateMgr, EScriptObjectMessage::None);
|
||||
|
||||
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Decrement:
|
||||
if (GetActive() && x38_current > 0) {
|
||||
--x38_current;
|
||||
if (x38_current == 0) {
|
||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Increment:
|
||||
if (GetActive() && x38_current < x3c_max) {
|
||||
++x38_current;
|
||||
if (x38_current >= x3c_max) {
|
||||
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
||||
if (x40_autoReset)
|
||||
x38_current = x34_initial;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EScriptObjectMessage::Reset:
|
||||
if (GetActive())
|
||||
x38_current = x34_initial;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace urde
|
||||
|
||||
Reference in New Issue
Block a user