Minor CElementGen cleanup, implement CFlaahgraPlants

This commit is contained in:
Phillip Stephens 2019-06-20 14:17:03 -07:00
parent 8c35cd02f0
commit 6df0fcde50
3 changed files with 87 additions and 5 deletions

View File

@ -4,6 +4,7 @@
#include "Collision/CCollisionActor.hpp"
#include "Collision/CCollisionActorManager.hpp"
#include "MP1/World/CFlaahgraProjectile.hpp"
#include "Particle/CElementGen.hpp"
#include "World/CActorParameters.hpp"
#include "World/CGameArea.hpp"
#include "World/CPlayer.hpp"
@ -737,5 +738,69 @@ zeus::CVector3f CFlaahgra::GetAttacktargetPos(CStateManager& mgr) const {
return mgr.GetPlayer().GetTranslation() + zeus::CVector3f(0.f, 0.f, -.5f + mgr.GetPlayer().GetEyeHeight());
}
CFlaahgraPlants::CFlaahgraPlants(const TToken<CGenDescription>& genDesc, const CActorParameters& actParms,
TUniqueId uid, TAreaId aId, TUniqueId owner, const zeus::CTransform& xf,
const CDamageInfo& dInfo, const zeus::CVector3f& extents)
: CActor(uid, true, "Flaahgra Plants"sv, CEntityInfo(aId, NullConnectionList), xf, CModelData::CModelDataNull(),
CMaterialList(EMaterialTypes::Projectile), actParms, kInvalidUniqueId)
, xe8_elementGen(new CElementGen(genDesc))
, xf0_ownerId(owner)
, x130_obbox(xf, extents) {
xe8_elementGen->SetGlobalOrientation(xf.getRotation());
xe8_elementGen->SetGlobalTranslation(xf.origin);
x110_aabox = {x130_obbox.calculateAABox(xf)};
}
void CFlaahgraPlants::Accept(IVisitor& visitor) {
visitor.Visit(this);
}
void CFlaahgraPlants::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Registered) {
xe8_elementGen->SetParticleEmission(true);
if (x16c_colAct == kInvalidUniqueId) {
x16c_colAct = mgr.AllocateUniqueId();
CCollisionActor* colAct = new CCollisionActor(x16c_, GetAreaIdAlways(), GetUniqueId(),
x130_obbox.extents + zeus::CVector3f(10.f, 0.f, 10.f), {}, true,
0.001f, "Flaahgra Plants"sv);
colAct->SetTransform(GetTransform());
colAct->SetMaterialFilter(CMaterialFilter::MakeIncludeExclude(
{EMaterialTypes::Player}, {EMaterialTypes::Trigger, EMaterialTypes::CollisionActor,
EMaterialTypes::NoStaticCollision, EMaterialTypes::Character}));
CMaterialList materialList = colAct->GetMaterialList();
materialList.Add(EMaterialTypes::ProjectilePassthrough);
materialList.Add(EMaterialTypes::Immovable);
colAct->SetMaterialList(materialList);
mgr.AddObject(colAct);
mgr.SetActorAreaId(*colAct, GetAreaIdAlways());
}
} else if (msg == EScriptObjectMessage::Deleted && (x16c_colAct != kInvalidUniqueId) {
mgr.FreeScriptObject(x16c_colAct);
}
}
void CFlaahgraPlants::Think(float dt, CStateManager& mgr) {
if (GetActive()) {
xe8_elementGen->Update(dt);
x12c_lastDt = dt;
}
if (xe8_elementGen->IsSystemDeletable())
mgr.FreeScriptObject(GetUniqueId());
}
void CFlaahgraPlants::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const {
g_Renderer->AddParticleGen(*xe8_elementGen.get());
CActor::AddToRenderer(frustum, mgr);
}
void CFlaahgraPlants::Touch(CActor& act, CStateManager& mgr) {
if (act.GetUniqueId() != mgr.GetPlayer().GetUniqueId() || !x110_aabox)
return;
zeus::COBBox plObb = zeus::COBBox::FromAABox(mgr.GetPlayer().GetBoundingBox(), {});
if (x130_obbox.OBBIntersectsBox(plObb)) {
/* TODO: Finish */
}
}
} // namespace urde::MP1

View File

@ -10,6 +10,7 @@ class CCollisionActorManager;
class CGenDescription;
class CBoneTracking;
class CDependencyGroup;
class CElementGen;
}
namespace urde::MP1 {
@ -49,6 +50,26 @@ public:
std::optional<zeus::CAABox> GetTouchBounds() const { return {}; }
};
class CFlaahgraPlants : public CActor {
std::unique_ptr<CElementGen> xe8_elementGen;
TUniqueId xf0_ownerId;
CDamageInfo xf4_damageInfo;
std::optional<zeus::CAABox> x110_aabox;
float x12c_lastDt = 0.f;
zeus::COBBox x130_obbox;
TUniqueId x16c_colAct = kInvalidUniqueId;
public:
CFlaahgraPlants(const TToken<CGenDescription>&, const CActorParameters&, TUniqueId, TAreaId, TUniqueId,
const zeus::CTransform&, const CDamageInfo&, const zeus::CVector3f&);
void Accept(IVisitor&);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void Think(float, CStateManager&);
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
std::optional<zeus::CAABox> GetTouchBounds() const { return x110_aabox; }
void Touch(CActor&, CStateManager&);
};
class CFlaahgra : public CPatterned {
static const SJointInfo skLeftArmJointList[3];
@ -127,7 +148,6 @@ class CFlaahgra : public CPatterned {
u32 _dummy = 0;
};
void LoadDependencies(CAssetId);
void ResetModelDataAndBodyController();
void GatherAssets(CStateManager& mgr);

View File

@ -1843,10 +1843,7 @@ bool CElementGen::IsSystemDeletable() const {
if (!ch->IsSystemDeletable())
return false;
if (x268_PSLT < x74_curFrame && x25c_activeParticleCount == 0)
return true;
return false;
return x268_PSLT < x74_curFrame && x25c_activeParticleCount == 0;
}
std::optional<zeus::CAABox> CElementGen::GetBounds() const {