mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-06 16:05:53 +00:00
CScriptRandomRelay: Brace conditionals where applicable
This commit is contained in:
parent
7145917e30
commit
192cbd5e14
@ -17,8 +17,9 @@ void CScriptRandomRelay::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
|||||||
void CScriptRandomRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
|
void CScriptRandomRelay::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) {
|
||||||
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
||||||
if (msg == EScriptObjectMessage::SetToZero) {
|
if (msg == EScriptObjectMessage::SetToZero) {
|
||||||
if (!x30_24_active)
|
if (!x30_24_active) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
SendLocalScriptMsgs(EScriptObjectState::Zero, stateMgr);
|
SendLocalScriptMsgs(EScriptObjectState::Zero, stateMgr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,33 +33,38 @@ void CScriptRandomRelay::SendLocalScriptMsgs(EScriptObjectState state, CStateMan
|
|||||||
std::vector<std::pair<CEntity*, EScriptObjectMessage>> objs;
|
std::vector<std::pair<CEntity*, EScriptObjectMessage>> objs;
|
||||||
objs.reserve(10);
|
objs.reserve(10);
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
auto list = stateMgr.GetIdListForScript(conn.x8_objId);
|
const auto list = stateMgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = list.first; it != list.second; ++it) {
|
for (auto it = list.first; it != list.second; ++it) {
|
||||||
CEntity* ent = stateMgr.ObjectById(it->second);
|
CEntity* ent = stateMgr.ObjectById(it->second);
|
||||||
if (ent && ent->GetActive())
|
if (ent && ent->GetActive()) {
|
||||||
objs.emplace_back(ent, conn.x4_msg);
|
objs.emplace_back(ent, conn.x4_msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 targetSetSize = x34_sendSetSize;
|
s32 targetSetSize = x34_sendSetSize;
|
||||||
if (x3c_percentSize)
|
if (x3c_percentSize) {
|
||||||
targetSetSize = s32(0.5f + (float(x34_sendSetSize * objs.size()) / 100.f));
|
targetSetSize = s32(0.5f + (float(x34_sendSetSize * objs.size()) / 100.f));
|
||||||
|
}
|
||||||
targetSetSize += s32(float(x38_sendSetVariance) * 2.f * stateMgr.GetActiveRandom()->Float()) - x38_sendSetVariance;
|
targetSetSize += s32(float(x38_sendSetVariance) * 2.f * stateMgr.GetActiveRandom()->Float()) - x38_sendSetVariance;
|
||||||
targetSetSize = zeus::clamp(0, targetSetSize, 64);
|
targetSetSize = zeus::clamp(0, targetSetSize, 64);
|
||||||
|
|
||||||
while (objs.size() > targetSetSize) {
|
while (objs.size() > targetSetSize) {
|
||||||
s32 randomRemoveIdx = s32(stateMgr.GetActiveRandom()->Float() * float(objs.size()) * 0.99f);
|
const s32 randomRemoveIdx = s32(stateMgr.GetActiveRandom()->Float() * float(objs.size()) * 0.99f);
|
||||||
auto it = objs.begin();
|
auto it = objs.begin();
|
||||||
for (s32 i = 0; i < randomRemoveIdx; ++i) {
|
for (s32 i = 0; i < randomRemoveIdx; ++i) {
|
||||||
++it;
|
++it;
|
||||||
if (it == objs.end())
|
if (it == objs.end()) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (it != objs.end())
|
if (it != objs.end()) {
|
||||||
objs.erase(it);
|
objs.erase(it);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& o : objs)
|
for (const auto& o : objs) {
|
||||||
stateMgr.SendScriptMsg(o.first, GetUniqueId(), o.second);
|
stateMgr.SendScriptMsg(o.first, GetUniqueId(), o.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
Loading…
x
Reference in New Issue
Block a user