mirror of https://github.com/AxioDL/metaforce.git
Fix std::make_pair fail (why is it even a problem?)
Add CScriptPickup loader
This commit is contained in:
parent
62b404152f
commit
236da3ac6e
|
@ -461,7 +461,7 @@ void ANIM::ANIM1::read(athena::io::IStreamReader& reader)
|
||||||
for (atUint8 f=0 ; f<boneFlagCount ; ++f)
|
for (atUint8 f=0 ; f<boneFlagCount ; ++f)
|
||||||
{
|
{
|
||||||
atUint8 flag = reader.readUByte();
|
atUint8 flag = reader.readUByte();
|
||||||
bones.emplace_back(f, std::make_tuple(flag & 0x1, flag & 0x2, flag & 0x4));
|
bones.emplace_back(f, std::make_tuple(bool(flag & 0x1), bool(flag & 0x2), bool(flag & 0x4)));
|
||||||
if (flag & 0x1)
|
if (flag & 0x1)
|
||||||
++boneChannelCount;
|
++boneChannelCount;
|
||||||
if (flag & 0x2)
|
if (flag & 0x2)
|
||||||
|
|
|
@ -36,6 +36,7 @@ set(WORLD_SOURCES
|
||||||
CScriptCoverPoint.hpp CScriptCoverPoint.cpp
|
CScriptCoverPoint.hpp CScriptCoverPoint.cpp
|
||||||
CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp
|
CScriptSpawnPoint.hpp CScriptSpawnPoint.cpp
|
||||||
CScriptCameraHint.hpp CScriptCameraHint.cpp
|
CScriptCameraHint.hpp CScriptCameraHint.cpp
|
||||||
|
CScriptPickup.hpp CScriptPickup.cpp
|
||||||
CScriptDamageableTrigger.hpp CScriptDamageableTrigger.cpp
|
CScriptDamageableTrigger.hpp CScriptDamageableTrigger.cpp
|
||||||
CScriptActorRotate.hpp CScriptActorRotate.cpp
|
CScriptActorRotate.hpp CScriptActorRotate.cpp
|
||||||
CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp
|
CScriptSpecialFunction.hpp CScriptSpecialFunction.cpp
|
||||||
|
|
|
@ -11,10 +11,10 @@ class CScriptDoor : public CPhysicsActor
|
||||||
public:
|
public:
|
||||||
enum class EDoorAnimType
|
enum class EDoorAnimType
|
||||||
{
|
{
|
||||||
|
None = -1,
|
||||||
Open,
|
Open,
|
||||||
Close,
|
Close,
|
||||||
Ready,
|
Ready,
|
||||||
Three
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float x25c_;
|
float x25c_;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "CScriptPickup.hpp"
|
||||||
|
|
||||||
|
namespace urde
|
||||||
|
{
|
||||||
|
CScriptPickup::CScriptPickup(TUniqueId uid, const std::string& name, const CEntityInfo& info, const zeus::CTransform& xf,
|
||||||
|
CModelData&& mData, const CActorParameters& aParams, const zeus::CAABox& aabb,
|
||||||
|
s32, s32, s32, s32, float, float, float, float, bool active)
|
||||||
|
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), CMaterialList(), aabb, SMoverData(1.f), aParams, 0.3f, 0.1f)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef __URDE_CSCRIPTPICKUP_HPP__
|
||||||
|
#define __URDE_CSCRIPTPICKUP_HPP__
|
||||||
|
|
||||||
|
#include "CPhysicsActor.hpp"
|
||||||
|
|
||||||
|
namespace urde
|
||||||
|
{
|
||||||
|
class CScriptPickup : public CPhysicsActor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CScriptPickup(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
|
||||||
|
const CActorParameters&, const zeus::CAABox&, s32, s32, s32, s32, float, float, float, float, bool);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __URDE_CSCRIPTPICKUP_HPP__
|
|
@ -6,4 +6,20 @@ namespace urde
|
||||||
CStateMachine::CStateMachine(CInputStream& in)
|
CStateMachine::CStateMachine(CInputStream& in)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 CStateMachine::GetStateIndex(const std::string& state)
|
||||||
|
{
|
||||||
|
auto it = std::find_if(x0_states.begin(), x0_states.end(), [&state](const CAiState& st) -> bool {
|
||||||
|
return (strncmp(st.GetName(), state.c_str(), 31) == 0);
|
||||||
|
});
|
||||||
|
if (it == x0_states.end())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return it - x0_states.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<CAiState>& CStateMachine::GetStateVector() const
|
||||||
|
{
|
||||||
|
return x0_states;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ class CStateMachine
|
||||||
public:
|
public:
|
||||||
CStateMachine(CInputStream& in);
|
CStateMachine(CInputStream& in);
|
||||||
|
|
||||||
const std::vector<CAiState>& GetStateVector() const { return x0_states; }
|
s32 GetStateIndex(const std::string& state);
|
||||||
|
const std::vector<CAiState>& GetStateVector() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CStateMachineState
|
class CStateMachineState
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "CScriptCoverPoint.hpp"
|
#include "CScriptCoverPoint.hpp"
|
||||||
#include "CScriptSpawnPoint.hpp"
|
#include "CScriptSpawnPoint.hpp"
|
||||||
#include "CScriptCameraHint.hpp"
|
#include "CScriptCameraHint.hpp"
|
||||||
|
#include "CScriptPickup.hpp"
|
||||||
#include "CScriptDamageableTrigger.hpp"
|
#include "CScriptDamageableTrigger.hpp"
|
||||||
#include "CScriptActorRotate.hpp"
|
#include "CScriptActorRotate.hpp"
|
||||||
#include "CScriptSpecialFunction.hpp"
|
#include "CScriptSpecialFunction.hpp"
|
||||||
|
@ -286,13 +287,20 @@ CAnimationParameters ScriptLoader::LoadAnimationParameters(CInputStream& in)
|
||||||
|
|
||||||
CFluidUVMotion ScriptLoader::LoadFluidUVMotion(CInputStream& in)
|
CFluidUVMotion ScriptLoader::LoadFluidUVMotion(CInputStream& in)
|
||||||
{
|
{
|
||||||
|
/* NOTE: DO NOT RE-ORDER THIS FUNCTION
|
||||||
|
* For some inexplicable reason Retro stores the layers in this order.
|
||||||
|
* Changing it will change the behavior of CFluidUVMotion,
|
||||||
|
* which is something we don't want.
|
||||||
|
* - Phil
|
||||||
|
* P.S: If you do change it, I'll hunt you down and put pink lipstick on your dog.
|
||||||
|
*/
|
||||||
CFluidUVMotion::EFluidUVMotion motion = CFluidUVMotion::EFluidUVMotion(in.readUint32Big());
|
CFluidUVMotion::EFluidUVMotion motion = CFluidUVMotion::EFluidUVMotion(in.readUint32Big());
|
||||||
float a = in.readFloatBig();
|
float a = in.readFloatBig();
|
||||||
float b = in.readFloatBig();
|
float b = in.readFloatBig();
|
||||||
b = zeus::degToRad(b) - M_PIF;
|
b = zeus::degToRad(b) - M_PIF;
|
||||||
float c = in.readFloatBig();
|
float c = in.readFloatBig();
|
||||||
float d = in.readFloatBig();
|
float d = in.readFloatBig();
|
||||||
CFluidUVMotion::SFluidLayerMotion motionLayer2(motion, a, b, c, d);
|
CFluidUVMotion::SFluidLayerMotion layerMotion2(motion, a, b, c, d);
|
||||||
|
|
||||||
motion = CFluidUVMotion::EFluidUVMotion(in.readUint32Big());
|
motion = CFluidUVMotion::EFluidUVMotion(in.readUint32Big());
|
||||||
a = in.readFloatBig();
|
a = in.readFloatBig();
|
||||||
|
@ -300,7 +308,7 @@ CFluidUVMotion ScriptLoader::LoadFluidUVMotion(CInputStream& in)
|
||||||
b = zeus::degToRad(b) - M_PIF;
|
b = zeus::degToRad(b) - M_PIF;
|
||||||
c = in.readFloatBig();
|
c = in.readFloatBig();
|
||||||
d = in.readFloatBig();
|
d = in.readFloatBig();
|
||||||
CFluidUVMotion::SFluidLayerMotion motionLayer3(motion, a, b, c, d);
|
CFluidUVMotion::SFluidLayerMotion layerMotion3(motion, a, b, c, d);
|
||||||
|
|
||||||
motion = CFluidUVMotion::EFluidUVMotion(in.readUint32Big());
|
motion = CFluidUVMotion::EFluidUVMotion(in.readUint32Big());
|
||||||
a = in.readFloatBig();
|
a = in.readFloatBig();
|
||||||
|
@ -308,14 +316,14 @@ CFluidUVMotion ScriptLoader::LoadFluidUVMotion(CInputStream& in)
|
||||||
b = zeus::degToRad(b) - M_PIF;
|
b = zeus::degToRad(b) - M_PIF;
|
||||||
c = in.readFloatBig();
|
c = in.readFloatBig();
|
||||||
d = in.readFloatBig();
|
d = in.readFloatBig();
|
||||||
CFluidUVMotion::SFluidLayerMotion motionLayer1(motion, a, b, c, d);
|
CFluidUVMotion::SFluidLayerMotion layerMotion1(motion, a, b, c, d);
|
||||||
|
|
||||||
a = in.readFloatBig();
|
a = in.readFloatBig();
|
||||||
b = in.readFloatBig();
|
b = in.readFloatBig();
|
||||||
|
|
||||||
b = zeus::degToRad(b) - M_PIF;
|
b = zeus::degToRad(b) - M_PIF;
|
||||||
|
|
||||||
return CFluidUVMotion(a, b, motionLayer1, motionLayer2, motionLayer3);
|
return CFluidUVMotion(a, b, layerMotion1, layerMotion2, layerMotion3);
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CTransform ScriptLoader::ConvertEditorEulerToTransform4f(const zeus::CVector3f& orientation,
|
zeus::CTransform ScriptLoader::ConvertEditorEulerToTransform4f(const zeus::CVector3f& orientation,
|
||||||
|
@ -406,9 +414,9 @@ CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in,
|
||||||
|
|
||||||
SActorHead head = LoadActorHead(in, mgr);
|
SActorHead head = LoadActorHead(in, mgr);
|
||||||
|
|
||||||
bool b1 = in.readBool();
|
bool active = in.readBool();
|
||||||
float f1 = in.readFloatBig();
|
float f1 = in.readFloatBig();
|
||||||
float f2 = in.readFloatBig();
|
float delay = in.readFloatBig();
|
||||||
u32 w1 = in.readUint32Big();
|
u32 w1 = in.readUint32Big();
|
||||||
u32 w2 = in.readUint32Big();
|
u32 w2 = in.readUint32Big();
|
||||||
u32 w3 = in.readUint32Big();
|
u32 w3 = in.readUint32Big();
|
||||||
|
@ -418,7 +426,7 @@ CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in,
|
||||||
u32 w7 = in.readUint32Big();
|
u32 w7 = in.readUint32Big();
|
||||||
|
|
||||||
return new CScriptWaypoint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform,
|
return new CScriptWaypoint(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform,
|
||||||
b1, f1, f2, w1, w2, w3, w4, w5, w6, w7);
|
active, f1, delay, w1, w2, w3, w4, w5, w6, w7);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in,
|
CEntity* ScriptLoader::LoadDoor(CStateManager& mgr, CInputStream& in,
|
||||||
|
@ -873,6 +881,44 @@ CEntity* ScriptLoader::LoadCameraHint(CStateManager& mgr, CInputStream& in,
|
||||||
CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in,
|
CEntity* ScriptLoader::LoadPickup(CStateManager& mgr, CInputStream& in,
|
||||||
int propCount, const CEntityInfo& info)
|
int propCount, const CEntityInfo& info)
|
||||||
{
|
{
|
||||||
|
if (!EnsurePropertyCount(propCount, 18, "Pickup"))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
SScaledActorHead head = LoadScaledActorHead(in, mgr);
|
||||||
|
zeus::CVector3f extent = zeus::CVector3f::ReadBig(in);
|
||||||
|
zeus::CVector3f offset = zeus::CVector3f::ReadBig(in);
|
||||||
|
u32 w1 = in.readUint32Big();
|
||||||
|
u32 w2 = in.readUint32Big();
|
||||||
|
u32 w3 = in.readUint32Big();
|
||||||
|
float f1 = in.readFloatBig();
|
||||||
|
float f2 = in.readFloatBig();
|
||||||
|
float f3 = in.readFloatBig();
|
||||||
|
ResId staticModel = in.readUint32Big();
|
||||||
|
CAnimationParameters animParms = LoadAnimationParameters(in);
|
||||||
|
CActorParameters actorParms = LoadActorParameters(in);
|
||||||
|
bool active = in.readBool();
|
||||||
|
float f4 = in.readFloatBig();
|
||||||
|
u32 w5 = in.readUint32Big();
|
||||||
|
|
||||||
|
FourCC acsType = g_ResFactory->GetResourceTypeById(animParms.GetACSFile());
|
||||||
|
if (g_ResFactory->GetResourceTypeById(staticModel) == 0 && acsType == 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
zeus::CAABox aabb = GetCollisionBox(mgr, info.GetAreaId(), extent, offset);
|
||||||
|
|
||||||
|
CModelData data;
|
||||||
|
|
||||||
|
if (acsType == SBIG('ANCS'))
|
||||||
|
data = CAnimRes(animParms.GetACSFile(), animParms.GetCharacter(), head.x40_scale,
|
||||||
|
animParms.GetInitialAnimation(), true);
|
||||||
|
else
|
||||||
|
data = CStaticRes(staticModel, head.x40_scale);
|
||||||
|
|
||||||
|
if (extent.isZero())
|
||||||
|
aabb = data.GetBounds(head.x10_transform.getRotation());
|
||||||
|
|
||||||
|
return new CScriptPickup(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), actorParms,
|
||||||
|
aabb, w1, w3, w2, w5, f1, f2, f3, f4, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity* ScriptLoader::LoadMemoryRelay(CStateManager& mgr, CInputStream& in,
|
CEntity* ScriptLoader::LoadMemoryRelay(CStateManager& mgr, CInputStream& in,
|
||||||
|
|
2
hecl
2
hecl
|
@ -1 +1 @@
|
||||||
Subproject commit 33f918ec44ea87965595899acde9ca4fbfc74da0
|
Subproject commit 9d29dcfd38de97ce48d32c9ed9a6ebb61603acc0
|
Loading…
Reference in New Issue