2016-04-20 21:44:18 +00:00
|
|
|
#include "CScriptPlatform.hpp"
|
|
|
|
#include "Collision/CMaterialList.hpp"
|
2017-06-11 05:49:27 +00:00
|
|
|
#include "Collision/CCollidableOBBTreeGroup.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-04-20 21:44:18 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
static CMaterialList MakePlatformMaterialList()
|
|
|
|
{
|
|
|
|
CMaterialList ret;
|
2016-12-29 21:38:59 +00:00
|
|
|
ret.Add(EMaterialTypes::Solid);
|
|
|
|
ret.Add(EMaterialTypes::Immovable);
|
|
|
|
ret.Add(EMaterialTypes::Platform);
|
|
|
|
ret.Add(EMaterialTypes::Occluder);
|
2016-04-20 21:44:18 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptPlatform::CScriptPlatform(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2016-09-02 15:26:29 +00:00
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms,
|
2017-06-11 05:49:27 +00:00
|
|
|
const zeus::CAABox& aabb, float f1, bool, float f2, bool active,
|
|
|
|
const CHealthInfo& hInfo, const CDamageVulnerability& dVuln,
|
|
|
|
const rstl::optional_object<TLockedToken<CCollidableOBBTreeGroupContainer>>& dcln,
|
|
|
|
bool, u32, u32)
|
2016-09-02 15:26:29 +00:00
|
|
|
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakePlatformMaterialList(), aabb, SMoverData(15000.f),
|
|
|
|
actParms, 0.3f, 0.1f)
|
2017-06-11 05:49:27 +00:00
|
|
|
, x28c_(hInfo)
|
|
|
|
, x294_(hInfo)
|
|
|
|
, x29c_(dVuln)
|
|
|
|
, x304_treeGroupContainer(dcln)
|
2016-04-20 21:44:18 +00:00
|
|
|
{
|
2017-06-11 05:49:27 +00:00
|
|
|
CActor::SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(
|
|
|
|
CMaterialList(EMaterialTypes::Solid),
|
2017-12-19 03:05:50 +00:00
|
|
|
CMaterialList(EMaterialTypes::NoStaticCollision, EMaterialTypes::NoPlatformCollision, EMaterialTypes::Platform)));
|
2017-06-11 05:49:27 +00:00
|
|
|
if (x304_treeGroupContainer)
|
|
|
|
x314_treeGroup = std::make_unique<CCollidableOBBTreeGroup>(x304_treeGroupContainer->GetObj(), x68_material);
|
2016-04-20 21:44:18 +00:00
|
|
|
}
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2017-06-11 05:49:27 +00:00
|
|
|
void CScriptPlatform::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
|
|
|
|
|
|
|
rstl::optional_object<zeus::CAABox> CScriptPlatform::GetTouchBounds() const
|
2017-01-15 03:07:01 +00:00
|
|
|
{
|
2017-06-11 05:49:27 +00:00
|
|
|
if (x314_treeGroup)
|
|
|
|
return {x314_treeGroup->CalculateAABox(GetTransform())};
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2017-06-11 05:49:27 +00:00
|
|
|
return {CPhysicsActor::GetBoundingBox()};
|
|
|
|
}
|
2017-06-18 01:58:13 +00:00
|
|
|
|
|
|
|
bool CScriptPlatform::IsRider(TUniqueId id) const
|
|
|
|
{
|
|
|
|
for (const SRiders& rider : x318_riders)
|
|
|
|
if (rider.x0_uid == id)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-12 05:30:21 +00:00
|
|
|
|
|
|
|
bool CScriptPlatform::IsSlave(TUniqueId id) const
|
|
|
|
{
|
|
|
|
auto search = std::find_if(x328_slaves1.begin(), x328_slaves1.end(),
|
|
|
|
[id](const SRiders& rider){ return rider.x0_uid == id; });
|
|
|
|
if (search != x328_slaves1.end())
|
|
|
|
return true;
|
|
|
|
search = std::find_if(x338_slaves2.begin(), x338_slaves2.end(),
|
|
|
|
[id](const SRiders& rider){ return rider.x0_uid == id; });
|
|
|
|
return search != x338_slaves2.end();
|
|
|
|
}
|
2016-04-20 21:44:18 +00:00
|
|
|
}
|