Complete CScriptDistanceFog RE

This commit is contained in:
Phillip Stephens 2016-08-08 20:58:19 -07:00
parent 8fd5e30d19
commit b8ac7f0082
10 changed files with 269 additions and 83 deletions

View File

@ -13,13 +13,13 @@ struct DistanceFog : IScriptObject
{
DECL_YAML
String<-1> name;
Value<atUint32> unknown1;
Value<atVec4f> unknown2; // CColor
Value<atVec2f> unknown3;
Value<atVec2f> unknown4;
Value<float> unknown5;
Value<bool> unknown6;
Value<bool> unknown7;
Value<atUint32> fogMode;
Value<atVec4f> fogColor; // CColor
Value<atVec2f> range;
Value<float> colorDelta;
Value<atVec2f> rangeDelta;
Value<bool> expl;
Value<bool> active;
};
}
}

View File

@ -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
{
}
}

View File

@ -441,6 +441,18 @@ const zeus::CTransform& CGameArea::IGetTM() const
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
{
return false;

View File

@ -196,8 +196,8 @@ public:
float x1120_thermalSpeed = 0.f;
float x1124_thermalTarget = 0.f;
float x1128_ = 1.f;
float x112c_ = 0.f;
float x1130_ = 1.f;
float x112c_xraySpeed = 0.f;
float x1130_xrayTarget = 1.f;
float x1134_ = 0.f;
float x1138_ = 1.f;
u32 x113c_ = 0;
@ -254,6 +254,11 @@ public:
ResId IGetStringTableAssetId() 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 DoesAreaNeedSkyNow() const;
bool OtherAreaOcclusionChanged();

View File

@ -1,22 +1,85 @@
#include "CScriptDistanceFog.hpp"
#include "CStateManager.hpp"
#include "CWorld.hpp"
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,
const ERglFogMode& mode, const zeus::CColor& col,
const zeus::CVector2f& v1, float f1, const zeus::CVector2f& v2,
bool b1, bool active, float f2, float f3, float f4, float f5)
const ERglFogMode& mode, const zeus::CColor& color,
const zeus::CVector2f& range, float colorDelta,
const zeus::CVector2f& rangeDelta, bool expl, bool active,
float thermalTarget, float thermalSpeed, float xrayTarget, float xraySpeed)
: CEntity(uid, info, active, name),
x34_mode(mode),
x38_col(col),
x3c_(v1),
x44_(f1),
x48_(v2),
x50_(f2),
x54_(f3),
x58_(f4),
x5c_(f5)
x38_color(color),
x3c_range(range),
x44_colorDelta(colorDelta),
x48_rangeDelta(rangeDelta),
x50_thermalTarget(thermalTarget),
x54_thermalSpeed(thermalSpeed),
x58_xrayTarget(xrayTarget),
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);
}
}
}
}

View File

@ -9,20 +9,22 @@ namespace urde
class CScriptDistanceFog : public CEntity
{
ERglFogMode x34_mode;
zeus::CColor x38_col;
zeus::CVector2f x3c_;
float x44_;
zeus::CVector2f x48_;
float x50_;
float x54_;
float x58_;
float x5c_;
bool x60_;
bool x61_;
zeus::CColor x38_color;
zeus::CVector2f x3c_range;
float x44_colorDelta;
zeus::CVector2f x48_rangeDelta;
float x50_thermalTarget;
float x54_thermalSpeed;
float x58_xrayTarget;
float x5c_xraySpeed;
bool x60_explicit;
bool x61_nonZero;
public:
CScriptDistanceFog(TUniqueId, const std::string&, const CEntityInfo&, const ERglFogMode&,
const zeus::CColor&, const zeus::CVector2f&, float, const zeus::CVector2f&,
bool, bool, float, float, float, float);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
};
}

View File

@ -72,6 +72,14 @@ TAreaId CDummyWorld::IGetAreaId(ResId id) const
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> ret;
@ -224,12 +232,22 @@ const CMapWorld* CWorld::IGetMapWorld() const
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
{
return x18_areas.at(id).get();
return GetAreaAlways(id);
}
TAreaId CWorld::IGetCurrentAreaId() const

View File

@ -174,6 +174,8 @@ public:
ResId IGetSaveWorldAssetId() const;
const CMapWorld* IGetMapWorld() const;
CMapWorld* IMapWorld();
const CGameArea* GetAreaAlways(TAreaId) const;
CGameArea* GetArea(TAreaId);
const IGameArea* IGetAreaAlways(TAreaId id) const;
TAreaId IGetCurrentAreaId() const;
TAreaId IGetAreaId(ResId id) const;

View File

@ -1458,14 +1458,14 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in,
const std::string* name = mgr.HashInstanceName(in);
u32 mode = in.readUint32Big();
zeus::CColor col;
col.readRGBABig(in);
zeus::CVector2f vec1;
vec1.readBig(in);
float f1 = in.readFloatBig();
zeus::CVector2f vec2;
vec2.readBig(in);
bool b1 = in.readBool();
zeus::CColor color;
color.readRGBABig(in);
zeus::CVector2f range;
range.readBig(in);
float colorDelta = in.readFloatBig();
zeus::CVector2f rangeDelta;
rangeDelta.readBig(in);
bool expl = in.readBool();
bool active = in.readBool();
ERglFogMode realMode;
@ -1482,8 +1482,8 @@ CEntity* ScriptLoader::LoadDistanceFog(CStateManager& mgr, CInputStream& in,
else if (mode == 5)
realMode = ERglFogMode::PerspRevExp2;
return new CScriptDistanceFog(mgr.AllocateUniqueId(), *name, info, realMode, col, vec1, f1, vec2, b1, active,
0.f, 0.f, 0.f, 0.f);
return new CScriptDistanceFog(mgr.AllocateUniqueId(), *name, info, realMode, color, range, colorDelta, rangeDelta,
expl, active, 0.f, 0.f, 0.f, 0.f);
}
CEntity* ScriptLoader::LoadFireFlea(CStateManager& mgr, CInputStream& in,

View File

@ -176,47 +176,47 @@ enum class EScriptObjectState
enum class EScriptObjectMessage
{
None = -1,
UNKM1 = 0,
Activate,
UNKM2,
Close,
Deactivate,
Decrement,
Follow,
Increment,
Next,
Open,
Reset,
ResetAndStart,
SetToMax,
SetToZero,
Start,
Stop,
StopAndReset,
ToggleActive,
UNKM3,
Action,
Play,
Alert,
InternalMessage00,
InternalMessage01,
InternalMessage02,
InternalMessage03,
InternalMessage04,
InternalMessage05,
InternalMessage06,
InternalMessage07,
InternalMessage08,
InternalMessage09,
InternalMessage10,
InternalMessage11,
InternalMessage12,
InternalMessage13,
InternalMessage14,
InternalMessage15,
InternalMessage16,
InternalMessage17
None = -1,
UNKM1 = 0,
Activate = 1,
UNKM2 = 2,
Close = 3,
Deactivate = 4,
Decrement = 5,
Follow = 6,
Increment = 7,
Next = 8,
Open = 9,
Reset = 10,
ResetAndStart = 11,
SetToMax = 12,
SetToZero = 13,
Start = 14,
Stop = 15,
StopAndReset = 16,
ToggleActive = 17,
UNKM3 = 18,
Action = 19,
Play = 20,
Alert = 21,
InternalMessage00 = 22,
InternalMessage01 = 23,
InternalMessage02 = 24,
InternalMessage03 = 25,
InternalMessage04 = 26,
InternalMessage05 = 27,
InternalMessage06 = 28,
InternalMessage07 = 29,
InternalMessage08 = 30,
InternalMessage09 = 31,
InternalMessage10 = 32,
InternalMessage11 = 33,
InternalMessage12 = 34,
InternalMessage13 = 35,
InternalMessage14 = 36,
InternalMessage15 = 37,
InternalMessage16 = 38,
InternalMessage17 = 39
};
}