metaforce/Runtime/World/CScriptTrigger.cpp

58 lines
1.7 KiB
C++
Raw Normal View History

2016-04-19 21:25:26 +00:00
#include "CScriptTrigger.hpp"
#include "Character/CModelData.hpp"
#include "CActorParameters.hpp"
#include "Collision/CMaterialList.hpp"
2016-04-29 10:08:46 +00:00
#include "CStateManager.hpp"
2016-04-19 21:25:26 +00:00
namespace urde
{
CScriptTrigger::CScriptTrigger(TUniqueId uid, const std::string& name, const CEntityInfo& info,
2016-04-29 10:08:46 +00:00
const zeus::CVector3f& pos, const zeus::CAABox& bounds,
const CDamageInfo& dInfo, const zeus::CVector3f& forceField,
u32 triggerFlags, bool active, bool b2, bool b3)
2016-04-19 21:25:26 +00:00
: CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(),
2016-04-29 10:08:46 +00:00
CMaterialList(EMaterialTypes::ThirtyFour), CActorParameters::None(), kInvalidUniqueId),
x100_damageInfo(dInfo),
x11c_forceField(forceField),
x128_forceMagnitude(forceField.magnitude()),
x12c_flags(triggerFlags),
x130_bounds(bounds),
x148_26_(b2),
x148_27_(b3)
2016-04-19 21:25:26 +00:00
{
}
2016-04-29 10:08:46 +00:00
CScriptTrigger::CObjectTracker* CScriptTrigger::FindInhabitant(TUniqueId id)
{
const auto& iter = std::find_if(xe8_inhabitants.begin(), xe8_inhabitants.end(), [&id](CObjectTracker& tr)->bool{
return tr.GetObjectId() == id;
});
if (iter != xe8_inhabitants.end())
return &(*iter);
return nullptr;
}
void CScriptTrigger::UpdateInhabitants(CStateManager& mgr)
{
}
const std::list<CScriptTrigger::CObjectTracker>&CScriptTrigger::GetInhabitants() const
{
return xe8_inhabitants;
}
rstl::optional_object<zeus::CAABox> CScriptTrigger::GetTouchBounds() const
{
if (x30_24_active)
return {GetTriggerBoundsWR()};
return {};
}
zeus::CAABox CScriptTrigger::GetTriggerBoundsWR() const
{
return {x130_bounds.min + x34_transform.origin, x130_bounds.max + x34_transform.origin};
}
2016-04-19 21:25:26 +00:00
}