mirror of https://github.com/AxioDL/metaforce.git
CScriptCameraHint: Brace statements where applicable
Makes code consistent.
This commit is contained in:
parent
a8fd2a1992
commit
d6ad152a97
|
@ -29,20 +29,26 @@ void CScriptCameraHint::InitializeInArea(CStateManager& mgr) {
|
||||||
x164_delegatedCamera = kInvalidUniqueId;
|
x164_delegatedCamera = kInvalidUniqueId;
|
||||||
for (CEntity* ent : mgr.GetAllObjectList()) {
|
for (CEntity* ent : mgr.GetAllObjectList()) {
|
||||||
for (const SConnection& conn : ent->GetConnectionList()) {
|
for (const SConnection& conn : ent->GetConnectionList()) {
|
||||||
if (mgr.GetIdForScript(conn.x8_objId) != GetUniqueId())
|
if (mgr.GetIdForScript(conn.x8_objId) != GetUniqueId()) {
|
||||||
continue;
|
continue;
|
||||||
if (conn.x4_msg != EScriptObjectMessage::Increment && conn.x4_msg != EScriptObjectMessage::Decrement)
|
}
|
||||||
|
if (conn.x4_msg != EScriptObjectMessage::Increment && conn.x4_msg != EScriptObjectMessage::Decrement) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = ent->GetConnectionList().begin(); it != ent->GetConnectionList().end(); ++it) {
|
for (auto it = ent->GetConnectionList().begin(); it != ent->GetConnectionList().end(); ++it) {
|
||||||
const SConnection& conn2 = *it;
|
const SConnection& conn2 = *it;
|
||||||
if (conn2.x4_msg != EScriptObjectMessage::Increment && conn2.x4_msg != EScriptObjectMessage::Decrement)
|
if (conn2.x4_msg != EScriptObjectMessage::Increment && conn2.x4_msg != EScriptObjectMessage::Decrement) {
|
||||||
continue;
|
continue;
|
||||||
TUniqueId id = mgr.GetIdForScript(conn2.x8_objId);
|
}
|
||||||
if (TCastToPtr<CPathCamera>(mgr.ObjectById(id)) || TCastToPtr<CScriptSpindleCamera>(mgr.ObjectById((id)))) {
|
|
||||||
|
const TUniqueId id = mgr.GetIdForScript(conn2.x8_objId);
|
||||||
|
const auto* const obj = mgr.ObjectById(id);
|
||||||
|
if (TCastToConstPtr<CPathCamera>(obj) || TCastToConstPtr<CScriptSpindleCamera>(obj)) {
|
||||||
it = ent->GetConnectionList().erase(it);
|
it = ent->GetConnectionList().erase(it);
|
||||||
if (x164_delegatedCamera != id)
|
if (x164_delegatedCamera != id) {
|
||||||
x164_delegatedCamera = id;
|
x164_delegatedCamera = id;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,17 +58,25 @@ void CScriptCameraHint::InitializeInArea(CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptCameraHint::AddHelper(TUniqueId id) {
|
void CScriptCameraHint::AddHelper(TUniqueId id) {
|
||||||
auto search = std::find_if(x150_helpers.begin(), x150_helpers.end(), [id](TUniqueId tid) { return tid == id; });
|
const auto search =
|
||||||
if (search == x150_helpers.end())
|
std::find_if(x150_helpers.cbegin(), x150_helpers.cend(), [id](TUniqueId tid) { return tid == id; });
|
||||||
|
|
||||||
|
if (search != x150_helpers.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x150_helpers.push_back(id);
|
x150_helpers.push_back(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptCameraHint::RemoveHelper(TUniqueId id) {
|
void CScriptCameraHint::RemoveHelper(TUniqueId id) {
|
||||||
auto search = std::find_if(x150_helpers.begin(), x150_helpers.end(), [id](TUniqueId tid) { return tid == id; });
|
const auto search =
|
||||||
if (search != x150_helpers.end())
|
std::find_if(x150_helpers.cbegin(), x150_helpers.cend(), [id](TUniqueId tid) { return tid == id; });
|
||||||
|
|
||||||
|
if (search != x150_helpers.cend()) {
|
||||||
x150_helpers.erase(search);
|
x150_helpers.erase(search);
|
||||||
else
|
} else {
|
||||||
x150_helpers.pop_front();
|
x150_helpers.pop_front();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
||||||
|
@ -96,13 +110,14 @@ void CScriptCameraHint::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId send
|
||||||
|
|
||||||
if (msg == EScriptObjectMessage::Follow) {
|
if (msg == EScriptObjectMessage::Follow) {
|
||||||
if (!GetActive()) {
|
if (!GetActive()) {
|
||||||
if (TCastToConstPtr<CActor> act = mgr.GetObjectById(sender)) {
|
if (const TCastToConstPtr<CActor> act = mgr.GetObjectById(sender)) {
|
||||||
zeus::CVector3f followerToThisFlat = x168_origXf.origin - act->GetTranslation();
|
zeus::CVector3f followerToThisFlat = x168_origXf.origin - act->GetTranslation();
|
||||||
followerToThisFlat.z() = 0.f;
|
followerToThisFlat.z() = 0.f;
|
||||||
if (followerToThisFlat.canBeNormalized())
|
if (followerToThisFlat.canBeNormalized()) {
|
||||||
followerToThisFlat.normalize();
|
followerToThisFlat.normalize();
|
||||||
else
|
} else {
|
||||||
followerToThisFlat = act->GetTransform().basis[1];
|
followerToThisFlat = act->GetTransform().basis[1];
|
||||||
|
}
|
||||||
zeus::CVector3f target = act->GetTranslation() + followerToThisFlat;
|
zeus::CVector3f target = act->GetTranslation() + followerToThisFlat;
|
||||||
target.z() = x168_origXf.origin.z() + followerToThisFlat.z();
|
target.z() = x168_origXf.origin.z() + followerToThisFlat.z();
|
||||||
SetTransform(zeus::lookAt(act->GetTranslation(), target));
|
SetTransform(zeus::lookAt(act->GetTranslation(), target));
|
||||||
|
|
Loading…
Reference in New Issue