mirror of https://github.com/AxioDL/metaforce.git
Implement CDroneLaser
This commit is contained in:
parent
784e956819
commit
94dbd091ae
|
@ -0,0 +1,72 @@
|
||||||
|
#include "Runtime/MP1/World/CDroneLaser.hpp"
|
||||||
|
|
||||||
|
#include "Runtime/CSimplePool.hpp"
|
||||||
|
#include "Runtime/CStateManager.hpp"
|
||||||
|
#include "Runtime/GameGlobalObjects.hpp"
|
||||||
|
#include "Runtime/Graphics/CBooRenderer.hpp"
|
||||||
|
#include "Runtime/Particle/CElementGen.hpp"
|
||||||
|
#include "Runtime/World/CActorParameters.hpp"
|
||||||
|
#include "Runtime/World/CGameLight.hpp"
|
||||||
|
|
||||||
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
||||||
|
|
||||||
|
namespace urde::MP1 {
|
||||||
|
CDroneLaser::CDroneLaser(TUniqueId uid, TAreaId aId, const zeus::CTransform& xf, CAssetId particle)
|
||||||
|
: CActor(uid, true, "DroneLaser"sv, CEntityInfo(aId, CEntity::NullConnectionList), xf, CModelData::CModelDataNull(),
|
||||||
|
CMaterialList(EMaterialTypes::NoStepLogic), CActorParameters::None(), kInvalidUniqueId)
|
||||||
|
, xf8_beamDesc(g_SimplePool->GetObj({SBIG('PART'), particle}))
|
||||||
|
, x104_beamParticle(std::make_unique<CElementGen>(xf8_beamDesc, CElementGen::EModelOrientationType::Normal,
|
||||||
|
CElementGen::EOptionalSystemFlags::One)) {}
|
||||||
|
void CDroneLaser::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
||||||
|
|
||||||
|
void CDroneLaser::Think(float dt, CStateManager& mgr) { x104_beamParticle->Update(dt); }
|
||||||
|
|
||||||
|
void CDroneLaser::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
|
||||||
|
CActor::AcceptScriptMsg(msg, sender, mgr);
|
||||||
|
|
||||||
|
if (msg == EScriptObjectMessage::Deactivate) {
|
||||||
|
SetScannerLightActive(mgr, false);
|
||||||
|
x104_beamParticle->SetParticleEmission(false);
|
||||||
|
} else if (msg == EScriptObjectMessage::Activate) {
|
||||||
|
SetScannerLightActive(mgr, true);
|
||||||
|
x104_beamParticle->SetParticleEmission(true);
|
||||||
|
} else if (msg == EScriptObjectMessage::Deleted) {
|
||||||
|
if (xf4_scannerLight != kInvalidUniqueId) {
|
||||||
|
mgr.FreeScriptObject(xf4_);
|
||||||
|
xf4_scannerLight = kInvalidUniqueId;
|
||||||
|
}
|
||||||
|
} else if (msg == EScriptObjectMessage::Registered) {
|
||||||
|
xf4_scannerLight = mgr.AllocateUniqueId();
|
||||||
|
mgr.AddObject(new CGameLight(xf4_scannerLight, GetAreaIdAlways(), GetActive(), "LaserScanner"sv, zeus::CTransform(),
|
||||||
|
GetUniqueId(), CLight::BuildPoint(zeus::skZero3f, zeus::skRed), 0, 0, 0.f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDroneLaser::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const {
|
||||||
|
g_Renderer->AddParticleGen(*x104_beamParticle);
|
||||||
|
EnsureRendered(mgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDroneLaser::Render(const CStateManager& mgr) const {
|
||||||
|
// g_Renderer->SetDepthReadWrite(true, true);
|
||||||
|
RenderBeam(4, 0.01f, zeus::CColor(1.f, .9f, .9f, 1.f), true);
|
||||||
|
// g_Renderer->SetDepthReadWrite(true, false);
|
||||||
|
RenderBeam(5, 0.06f, zeus::CColor(.4f, .0f, .0f, .5f), true);
|
||||||
|
RenderBeam(7, 0.06f, zeus::CColor(.4f, .2f, .2f, .1f), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDroneLaser::CalculateRenderBounds() {
|
||||||
|
zeus::CAABox box = zeus::skInvertedBox;
|
||||||
|
const zeus::CVector3f diff = xe8_ - GetTranslation();
|
||||||
|
const float mag1 = 0.2f * diff.magnitude();
|
||||||
|
box.accumulateBounds(diff);
|
||||||
|
box.accumulateBounds(xe8_ + (mag1 * GetTransform().basis[2]));
|
||||||
|
box.accumulateBounds(xe8_ - (mag1 * GetTransform().basis[2]));
|
||||||
|
x9c_renderBounds = box;
|
||||||
|
}
|
||||||
|
void CDroneLaser::SetScannerLightActive(CStateManager& mgr, bool activate) {
|
||||||
|
mgr.SendScriptMsgAlways(xf4_, GetUniqueId(),
|
||||||
|
activate ? EScriptObjectMessage::Activate : EScriptObjectMessage::Deactivate);
|
||||||
|
}
|
||||||
|
void CDroneLaser::RenderBeam(u32 w, float f, const zeus::CColor& col, bool) const {}
|
||||||
|
} // namespace urde::MP1
|
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
#include "Runtime/World/CActor.hpp"
|
||||||
|
|
||||||
|
namespace urde {
|
||||||
|
class CElementGen;
|
||||||
|
namespace MP1 {
|
||||||
|
class CDroneLaser : public CActor {
|
||||||
|
zeus::CVector3f xe8_ = zeus::skZero3f;
|
||||||
|
TUniqueId xf4_scannerLight = kInvalidUniqueId;
|
||||||
|
TLockedToken<CGenDescription> xf8_beamDesc;
|
||||||
|
std::unique_ptr<CElementGen> x104_beamParticle;
|
||||||
|
|
||||||
|
void SetScannerLightActive(CStateManager& mgr, bool activate);
|
||||||
|
void RenderBeam(u32 w, float f, const zeus::CColor& col, bool) const;
|
||||||
|
public:
|
||||||
|
CDroneLaser(TUniqueId uid, TAreaId aId, const zeus::CTransform& xf, CAssetId particle);
|
||||||
|
void Accept(IVisitor& visitor) override;
|
||||||
|
void Think(float dt, CStateManager& mgr) override;
|
||||||
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) override;
|
||||||
|
void AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr) const override;
|
||||||
|
void Render(const CStateManager& mgr) const override;
|
||||||
|
void CalculateRenderBounds() override;
|
||||||
|
};
|
||||||
|
} // namespace MP1
|
||||||
|
} // namespace urde
|
|
@ -10,6 +10,7 @@ set(MP1_WORLD_SOURCES
|
||||||
CChozoGhost.hpp CChozoGhost.cpp
|
CChozoGhost.hpp CChozoGhost.cpp
|
||||||
CElitePirate.hpp CElitePirate.cpp
|
CElitePirate.hpp CElitePirate.cpp
|
||||||
CDrone.hpp CDrone.cpp
|
CDrone.hpp CDrone.cpp
|
||||||
|
CDroneLaser.hpp CDroneLaser.cpp
|
||||||
CSpacePirate.hpp CSpacePirate.cpp
|
CSpacePirate.hpp CSpacePirate.cpp
|
||||||
CParasite.hpp CParasite.cpp
|
CParasite.hpp CParasite.cpp
|
||||||
CBabygoth.hpp CBabygoth.cpp
|
CBabygoth.hpp CBabygoth.cpp
|
||||||
|
|
Loading…
Reference in New Issue