mirror of https://github.com/AxioDL/metaforce.git
Complete CScriptDistanceFog RE
This commit is contained in:
parent
8fd5e30d19
commit
b8ac7f0082
|
@ -13,13 +13,13 @@ struct DistanceFog : IScriptObject
|
||||||
{
|
{
|
||||||
DECL_YAML
|
DECL_YAML
|
||||||
String<-1> name;
|
String<-1> name;
|
||||||
Value<atUint32> unknown1;
|
Value<atUint32> fogMode;
|
||||||
Value<atVec4f> unknown2; // CColor
|
Value<atVec4f> fogColor; // CColor
|
||||||
Value<atVec2f> unknown3;
|
Value<atVec2f> range;
|
||||||
Value<atVec2f> unknown4;
|
Value<float> colorDelta;
|
||||||
Value<float> unknown5;
|
Value<atVec2f> rangeDelta;
|
||||||
Value<bool> unknown6;
|
Value<bool> expl;
|
||||||
Value<bool> unknown7;
|
Value<bool> active;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
#include "CMapWorld.hpp"
|
||||||
|
|
||||||
|
namespace urde
|
||||||
|
{
|
||||||
|
u32 CMapWorld::GetNumAreas() const
|
||||||
|
{
|
||||||
|
return x0_areas.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::GetLoadedMapArea(s32) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::GetMapArea(s32) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::IsMapAreaInBFSInfoVector(const CMapWorld::CMapAreaData *, const std::vector<CMapWorld::CMapAreaBFSInfo> &) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::SetWhichMapAreasLoaded(const IWorld &, int start, int count)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMapWorld::IsMapAreasStreaming() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::MoveMapAreaToList(CMapWorld::CMapAreaData *, CMapWorld::EMapAreaList)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::GetCurrentMapAreaDepth(const IWorld &, int) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::GetVisibleAreas(const IWorld &, const CMapWorldInfo &) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::Draw(const CMapWorld::CMapWorldDrawParms &, int, int, float, float, bool) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::DoBFS(const IWorld &, int, int, float, float, bool, std::vector<CMapWorld::CMapAreaBFSInfo> &) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CMapWorld::IsMapAreaValid(const IWorld &, int, bool) const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::DrawAreas(const CMapWorld::CMapWorldDrawParms &, int, const std::vector<CMapWorld::CMapAreaBFSInfo> &, bool) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::RecalculateWorldSphere(const CMapWorldInfo &, const IWorld &) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::ConstrainToWorldVolume(const zeus::CVector3f &, const zeus::CVector3f &) const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMapWorld::ClearTraversedFlags() const
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -441,6 +441,18 @@ const zeus::CTransform& CGameArea::IGetTM() const
|
||||||
return xc_transform;
|
return xc_transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameArea::SetXRaySpeedAndTarget(float f1, float f2)
|
||||||
|
{
|
||||||
|
x12c_postConstructed->x112c_xraySpeed = f1;
|
||||||
|
x12c_postConstructed->x1130_xrayTarget = f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CGameArea::SetThermalSpeedAndTarget(float speed, float target)
|
||||||
|
{
|
||||||
|
x12c_postConstructed->x1120_thermalSpeed = speed;
|
||||||
|
x12c_postConstructed->x1124_thermalTarget = target;
|
||||||
|
}
|
||||||
|
|
||||||
bool CGameArea::DoesAreaNeedEnvFx() const
|
bool CGameArea::DoesAreaNeedEnvFx() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -196,8 +196,8 @@ public:
|
||||||
float x1120_thermalSpeed = 0.f;
|
float x1120_thermalSpeed = 0.f;
|
||||||
float x1124_thermalTarget = 0.f;
|
float x1124_thermalTarget = 0.f;
|
||||||
float x1128_ = 1.f;
|
float x1128_ = 1.f;
|
||||||
float x112c_ = 0.f;
|
float x112c_xraySpeed = 0.f;
|
||||||
float x1130_ = 1.f;
|
float x1130_xrayTarget = 1.f;
|
||||||
float x1134_ = 0.f;
|
float x1134_ = 0.f;
|
||||||
float x1138_ = 1.f;
|
float x1138_ = 1.f;
|
||||||
u32 x113c_ = 0;
|
u32 x113c_ = 0;
|
||||||
|
@ -254,6 +254,11 @@ public:
|
||||||
ResId IGetStringTableAssetId() const;
|
ResId IGetStringTableAssetId() const;
|
||||||
const zeus::CTransform& IGetTM() const;
|
const zeus::CTransform& IGetTM() const;
|
||||||
|
|
||||||
|
void SetXRaySpeedAndTarget(float f1, float f2);
|
||||||
|
void SetThermalSpeedAndTarget(float f1, float f2);
|
||||||
|
|
||||||
|
const CAreaFog* GetAreaFog() const { return GetPostConstructed()->x10c4_areaFog.get(); }
|
||||||
|
CAreaFog* AreaFog() { return const_cast<CAreaFog*>(GetAreaFog()); }
|
||||||
bool DoesAreaNeedEnvFx() const;
|
bool DoesAreaNeedEnvFx() const;
|
||||||
bool DoesAreaNeedSkyNow() const;
|
bool DoesAreaNeedSkyNow() const;
|
||||||
bool OtherAreaOcclusionChanged();
|
bool OtherAreaOcclusionChanged();
|
||||||
|
|
|
@ -1,22 +1,85 @@
|
||||||
#include "CScriptDistanceFog.hpp"
|
#include "CScriptDistanceFog.hpp"
|
||||||
|
#include "CStateManager.hpp"
|
||||||
|
#include "CWorld.hpp"
|
||||||
|
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
bool close_enough(const zeus::CVector2f& a, const zeus::CVector2f& b, float epsilon = 0.000099999997f)
|
||||||
|
{
|
||||||
|
if (std::fabs(a.x - b.x) < epsilon && std::fabs(a.y - b.y) < epsilon)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool close_enough(float a, float b, double epsilon = 0.000009999999747378752)
|
||||||
|
{
|
||||||
|
return std::fabs(a - b) < epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
CScriptDistanceFog::CScriptDistanceFog(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
CScriptDistanceFog::CScriptDistanceFog(TUniqueId uid, const std::string& name, const CEntityInfo& info,
|
||||||
const ERglFogMode& mode, const zeus::CColor& col,
|
const ERglFogMode& mode, const zeus::CColor& color,
|
||||||
const zeus::CVector2f& v1, float f1, const zeus::CVector2f& v2,
|
const zeus::CVector2f& range, float colorDelta,
|
||||||
bool b1, bool active, float f2, float f3, float f4, float f5)
|
const zeus::CVector2f& rangeDelta, bool expl, bool active,
|
||||||
|
float thermalTarget, float thermalSpeed, float xrayTarget, float xraySpeed)
|
||||||
: CEntity(uid, info, active, name),
|
: CEntity(uid, info, active, name),
|
||||||
x34_mode(mode),
|
x34_mode(mode),
|
||||||
x38_col(col),
|
x38_color(color),
|
||||||
x3c_(v1),
|
x3c_range(range),
|
||||||
x44_(f1),
|
x44_colorDelta(colorDelta),
|
||||||
x48_(v2),
|
x48_rangeDelta(rangeDelta),
|
||||||
x50_(f2),
|
x50_thermalTarget(thermalTarget),
|
||||||
x54_(f3),
|
x54_thermalSpeed(thermalSpeed),
|
||||||
x58_(f4),
|
x58_xrayTarget(xrayTarget),
|
||||||
x5c_(f5)
|
x5c_xraySpeed(xraySpeed),
|
||||||
|
x60_explicit(expl)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
if (close_enough(rangeDelta, zeus::CVector2f::skZero) && close_enough(colorDelta, 0.f))
|
||||||
|
x61_nonZero = false;
|
||||||
|
else
|
||||||
|
x61_nonZero = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CScriptDistanceFog::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
|
||||||
|
{
|
||||||
|
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
|
||||||
|
|
||||||
|
if (GetAreaId() == kInvalidAreaId || !x30_24_active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (msg == EScriptObjectMessage::InternalMessage13)
|
||||||
|
{
|
||||||
|
if (!x60_explicit)
|
||||||
|
return;
|
||||||
|
CGameArea::CAreaFog* fog = stateMgr.GetWorld()->GetArea(GetAreaId())->AreaFog();
|
||||||
|
if (x34_mode == ERglFogMode::None)
|
||||||
|
fog->DisableFog();
|
||||||
|
else
|
||||||
|
fog->SetFogExplicit(x34_mode, x38_color, x3c_range);
|
||||||
|
}
|
||||||
|
else if (msg == EScriptObjectMessage::Action)
|
||||||
|
{
|
||||||
|
if (!x61_nonZero)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CGameArea::CAreaFog* fog = stateMgr.GetWorld()->GetArea(GetAreaId())->AreaFog();
|
||||||
|
if (x34_mode == ERglFogMode::None)
|
||||||
|
fog->RollFogOut(x48_rangeDelta.x, x44_colorDelta, x38_color);
|
||||||
|
else
|
||||||
|
fog->FadeFog(x34_mode, x38_color, x3c_range, x44_colorDelta, x48_rangeDelta);
|
||||||
|
|
||||||
|
if (close_enough(x54_thermalSpeed, 0.f) && !close_enough(x5c_xraySpeed, 0.f))
|
||||||
|
{
|
||||||
|
CWorld* world = stateMgr.GetWorld();
|
||||||
|
CGameArea* area = world->GetArea(GetAreaId());
|
||||||
|
area->SetXRaySpeedAndTarget(x5c_xraySpeed, x58_xrayTarget);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CWorld* world = stateMgr.GetWorld();
|
||||||
|
CGameArea* area = world->GetArea(GetAreaId());
|
||||||
|
area->SetThermalSpeedAndTarget(x54_thermalSpeed, x50_thermalTarget);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,20 +9,22 @@ namespace urde
|
||||||
class CScriptDistanceFog : public CEntity
|
class CScriptDistanceFog : public CEntity
|
||||||
{
|
{
|
||||||
ERglFogMode x34_mode;
|
ERglFogMode x34_mode;
|
||||||
zeus::CColor x38_col;
|
zeus::CColor x38_color;
|
||||||
zeus::CVector2f x3c_;
|
zeus::CVector2f x3c_range;
|
||||||
float x44_;
|
float x44_colorDelta;
|
||||||
zeus::CVector2f x48_;
|
zeus::CVector2f x48_rangeDelta;
|
||||||
float x50_;
|
float x50_thermalTarget;
|
||||||
float x54_;
|
float x54_thermalSpeed;
|
||||||
float x58_;
|
float x58_xrayTarget;
|
||||||
float x5c_;
|
float x5c_xraySpeed;
|
||||||
bool x60_;
|
bool x60_explicit;
|
||||||
bool x61_;
|
bool x61_nonZero;
|
||||||
public:
|
public:
|
||||||
CScriptDistanceFog(TUniqueId, const std::string&, const CEntityInfo&, const ERglFogMode&,
|
CScriptDistanceFog(TUniqueId, const std::string&, const CEntityInfo&, const ERglFogMode&,
|
||||||
const zeus::CColor&, const zeus::CVector2f&, float, const zeus::CVector2f&,
|
const zeus::CColor&, const zeus::CVector2f&, float, const zeus::CVector2f&,
|
||||||
bool, bool, float, float, float, float);
|
bool, bool, float, float, float, float);
|
||||||
|
|
||||||
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,14 @@ TAreaId CDummyWorld::IGetAreaId(ResId id) const
|
||||||
return kInvalidAreaId;
|
return kInvalidAreaId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CWorld::CRelay::CRelay(CInputStream& in)
|
||||||
|
{
|
||||||
|
x0_relay = in.readUint32Big();
|
||||||
|
x4_target = in.readUint32Big();
|
||||||
|
x8_msg = in.readUint16Big();
|
||||||
|
xa_active = in.readBool();
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<CWorld::CRelay> CWorld::CRelay::ReadMemoryRelays(athena::io::MemoryReader& r)
|
std::vector<CWorld::CRelay> CWorld::CRelay::ReadMemoryRelays(athena::io::MemoryReader& r)
|
||||||
{
|
{
|
||||||
std::vector<CWorld::CRelay> ret;
|
std::vector<CWorld::CRelay> ret;
|
||||||
|
@ -224,12 +232,22 @@ const CMapWorld* CWorld::IGetMapWorld() const
|
||||||
|
|
||||||
CMapWorld* CWorld::IMapWorld()
|
CMapWorld* CWorld::IMapWorld()
|
||||||
{
|
{
|
||||||
return (CMapWorld*)GetMapWorld();
|
return const_cast<CMapWorld*>(GetMapWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
const CGameArea* CWorld::GetAreaAlways(TAreaId id) const
|
||||||
|
{
|
||||||
|
return x18_areas.at(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
CGameArea* CWorld::GetArea(TAreaId id)
|
||||||
|
{
|
||||||
|
return const_cast<CGameArea*>(GetAreaAlways(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
const IGameArea* CWorld::IGetAreaAlways(TAreaId id) const
|
const IGameArea* CWorld::IGetAreaAlways(TAreaId id) const
|
||||||
{
|
{
|
||||||
return x18_areas.at(id).get();
|
return GetAreaAlways(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TAreaId CWorld::IGetCurrentAreaId() const
|
TAreaId CWorld::IGetCurrentAreaId() const
|
||||||
|
|
|
@ -174,6 +174,8 @@ public:
|
||||||
ResId IGetSaveWorldAssetId() const;
|
ResId IGetSaveWorldAssetId() const;
|
||||||
const CMapWorld* IGetMapWorld() const;
|
const CMapWorld* IGetMapWorld() const;
|
||||||
CMapWorld* IMapWorld();
|
CMapWorld* IMapWorld();
|
||||||
|
const CGameArea* GetAreaAlways(TAreaId) const;
|
||||||
|
CGameArea* GetArea(TAreaId);
|
||||||
const IGameArea* IGetAreaAlways(TAreaId id) const;
|
const IGameArea* IGetAreaAlways(TAreaId id) const;
|
||||||
TAreaId IGetCurrentAreaId() const;
|
TAreaId IGetCurrentAreaId() const;
|
||||||
TAreaId IGetAreaId(ResId id) const;
|
TAreaId IGetAreaId(ResId id) const;
|
||||||
|
|
|
@ -1458,14 +1458,14 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in,
|
||||||
|
|
||||||
const std::string* name = mgr.HashInstanceName(in);
|
const std::string* name = mgr.HashInstanceName(in);
|
||||||
u32 mode = in.readUint32Big();
|
u32 mode = in.readUint32Big();
|
||||||
zeus::CColor col;
|
zeus::CColor color;
|
||||||
col.readRGBABig(in);
|
color.readRGBABig(in);
|
||||||
zeus::CVector2f vec1;
|
zeus::CVector2f range;
|
||||||
vec1.readBig(in);
|
range.readBig(in);
|
||||||
float f1 = in.readFloatBig();
|
float colorDelta = in.readFloatBig();
|
||||||
zeus::CVector2f vec2;
|
zeus::CVector2f rangeDelta;
|
||||||
vec2.readBig(in);
|
rangeDelta.readBig(in);
|
||||||
bool b1 = in.readBool();
|
bool expl = in.readBool();
|
||||||
bool active = in.readBool();
|
bool active = in.readBool();
|
||||||
ERglFogMode realMode;
|
ERglFogMode realMode;
|
||||||
|
|
||||||
|
@ -1482,8 +1482,8 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in,
|
||||||
else if (mode == 5)
|
else if (mode == 5)
|
||||||
realMode = ERglFogMode::PerspRevExp2;
|
realMode = ERglFogMode::PerspRevExp2;
|
||||||
|
|
||||||
return new CScriptDistanceFog(mgr.AllocateUniqueId(), *name, info, realMode, col, vec1, f1, vec2, b1, active,
|
return new CScriptDistanceFog(mgr.AllocateUniqueId(), *name, info, realMode, color, range, colorDelta, rangeDelta,
|
||||||
0.f, 0.f, 0.f, 0.f);
|
expl, active, 0.f, 0.f, 0.f, 0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
CEntity* ScriptLoader::LoadFireFlea(CStateManager& mgr, CInputStream& in,
|
CEntity* ScriptLoader::LoadFireFlea(CStateManager& mgr, CInputStream& in,
|
||||||
|
|
|
@ -176,47 +176,47 @@ enum class EScriptObjectState
|
||||||
|
|
||||||
enum class EScriptObjectMessage
|
enum class EScriptObjectMessage
|
||||||
{
|
{
|
||||||
None = -1,
|
None = -1,
|
||||||
UNKM1 = 0,
|
UNKM1 = 0,
|
||||||
Activate,
|
Activate = 1,
|
||||||
UNKM2,
|
UNKM2 = 2,
|
||||||
Close,
|
Close = 3,
|
||||||
Deactivate,
|
Deactivate = 4,
|
||||||
Decrement,
|
Decrement = 5,
|
||||||
Follow,
|
Follow = 6,
|
||||||
Increment,
|
Increment = 7,
|
||||||
Next,
|
Next = 8,
|
||||||
Open,
|
Open = 9,
|
||||||
Reset,
|
Reset = 10,
|
||||||
ResetAndStart,
|
ResetAndStart = 11,
|
||||||
SetToMax,
|
SetToMax = 12,
|
||||||
SetToZero,
|
SetToZero = 13,
|
||||||
Start,
|
Start = 14,
|
||||||
Stop,
|
Stop = 15,
|
||||||
StopAndReset,
|
StopAndReset = 16,
|
||||||
ToggleActive,
|
ToggleActive = 17,
|
||||||
UNKM3,
|
UNKM3 = 18,
|
||||||
Action,
|
Action = 19,
|
||||||
Play,
|
Play = 20,
|
||||||
Alert,
|
Alert = 21,
|
||||||
InternalMessage00,
|
InternalMessage00 = 22,
|
||||||
InternalMessage01,
|
InternalMessage01 = 23,
|
||||||
InternalMessage02,
|
InternalMessage02 = 24,
|
||||||
InternalMessage03,
|
InternalMessage03 = 25,
|
||||||
InternalMessage04,
|
InternalMessage04 = 26,
|
||||||
InternalMessage05,
|
InternalMessage05 = 27,
|
||||||
InternalMessage06,
|
InternalMessage06 = 28,
|
||||||
InternalMessage07,
|
InternalMessage07 = 29,
|
||||||
InternalMessage08,
|
InternalMessage08 = 30,
|
||||||
InternalMessage09,
|
InternalMessage09 = 31,
|
||||||
InternalMessage10,
|
InternalMessage10 = 32,
|
||||||
InternalMessage11,
|
InternalMessage11 = 33,
|
||||||
InternalMessage12,
|
InternalMessage12 = 34,
|
||||||
InternalMessage13,
|
InternalMessage13 = 35,
|
||||||
InternalMessage14,
|
InternalMessage14 = 36,
|
||||||
InternalMessage15,
|
InternalMessage15 = 37,
|
||||||
InternalMessage16,
|
InternalMessage16 = 38,
|
||||||
InternalMessage17
|
InternalMessage17 = 39
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue