Associated compile fixes. Some of these are dirty and temporary-ish.

This commit is contained in:
hispidence 2022-01-27 23:38:47 +00:00
parent 0834bf805f
commit cd9c3e7544
11 changed files with 104 additions and 39 deletions

View file

@ -17,6 +17,7 @@
<ClInclude Include="$(MSBuildThisFileDirectory)Game\animation.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Game\items.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Game\room.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\RGBAColor8Byte.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\level.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\newtypes.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\phd_global.h" />

View file

@ -15,5 +15,6 @@
<ClInclude Include="$(MSBuildThisFileDirectory)Game\animation.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\trmath.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\newtypes.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Specific\RGBAColor8Byte.h" />
</ItemGroup>
</Project>

View file

@ -14,15 +14,6 @@ static const std::unordered_map<std::string, WeatherType> kWeatherTypes
{"Snow", WeatherType::Snow}
};
enum LaraType
{
Normal = 1,
Young = 2,
Bunhead = 3,
Catsuit = 4,
Divesuit = 5,
Invisible = 7
};
static const std::unordered_map<std::string, LaraType> kLaraTypes
{
@ -50,15 +41,20 @@ struct GameScriptLevel : public ScriptInterfaceLevel
WeatherType Weather{ WeatherType::None };
float WeatherStrength{ 1.0f };
bool Rumble{ false };
LaraType LaraType{ LaraType::Normal };
LaraType Type{ LaraType::Normal };
GameScriptMirror Mirror;
int LevelFarView{ 0 };
bool UnlimitedAir{ false };
std::vector<GameScriptInventoryObject> InventoryObjects;
bool GetSkyLayerEnabled(int index) override;
short GetSkyLayerSpeed(int index) override;
float GetWeatherStrength() const override;
bool GetSkyLayerEnabled(int index) const override;
bool HasStorm() const override;
short GetSkyLayerSpeed(int index) const override;
RGBAColor8Byte GetSkyLayerColor(int index) const override;
LaraType GetLaraType() const override;
void SetWeatherStrength(float val);
void SetLevelFarView(byte val);
static void Register(sol::state* state);
WeatherType GetWeatherType() const override;
};

View file

@ -17,6 +17,7 @@ struct GameScriptSkyLayer
GameScriptSkyLayer() = default;
GameScriptSkyLayer(GameScriptColor const & col, short speed);
void SetColor(GameScriptColor const & col);
GameScriptColor GetColor() const;
static void Register(sol::state *);
};

View file

@ -1,4 +1,7 @@
#pragma once
class ScriptInterfaceLevel;
class ScriptInterfaceFlow {
public:
virtual ~ScriptInterfaceFlow() = default;
@ -13,5 +16,6 @@ public:
virtual bool HasMonkeyAutoJump() const = 0;
virtual bool HasOscillateHang() const = 0;
virtual bool HasAFKPose() const = 0;
virtual ScriptInterfaceLevel * GetLevel(int level) = 0;
};

View file

@ -1,5 +1,7 @@
#pragma once
#include "Specific/RGBAColor8Byte.h"
enum class WeatherType
{
None,
@ -7,10 +9,26 @@ enum class WeatherType
Snow
};
// todo make this a scoped enum
enum LaraType
{
Normal = 1,
Young = 2,
Bunhead = 3,
Catsuit = 4,
Divesuit = 5,
Invisible = 7
};
class ScriptInterfaceLevel {
public:
virtual ~ScriptInterfaceLevel() = default;
virtual bool GetSkyLayerEnabled(int index) = 0;
virtual short GetSkyLayerSpeed(int index) = 0;
virtual bool GetSkyLayerEnabled(int index) const = 0;
virtual short GetSkyLayerSpeed(int index) const = 0;
virtual LaraType GetLaraType() const = 0;
virtual bool HasStorm() const = 0;
virtual float GetWeatherStrength() const = 0;
virtual WeatherType GetWeatherType() const = 0;
virtual RGBAColor8Byte GetSkyLayerColor(int index) const = 0;
};

View file

@ -104,7 +104,7 @@ e.g. `myLevel.laraType = LaraType.Divesuit`
__(not yet fully implemented)__
@mem laraType*/
"laraType", &GameScriptLevel::LaraType,
"laraType", &GameScriptLevel::Type,
/// (bool) Enable occasional screen shake effect.
// As seen in TRC's Sinking Submarine.
@ -142,7 +142,7 @@ __(not yet implemented)__
}
//todo add bindings and documents for this
bool GameScriptLevel::GetSkyLayerEnabled(int index)
bool GameScriptLevel::GetSkyLayerEnabled(int index) const
{
bool cond = index == 0 || index == 1;
std::string msg{ "Index must be 0 or 1." };
@ -164,7 +164,7 @@ bool GameScriptLevel::GetSkyLayerEnabled(int index)
}
//todo add bindings and documents for this
short GameScriptLevel::GetSkyLayerSpeed(int index)
short GameScriptLevel::GetSkyLayerSpeed(int index) const
{
bool cond = index == 0 || index == 1;
std::string msg{ "Index must be 0 or 1." };
@ -214,3 +214,45 @@ void GameScriptLevel::SetLevelFarView(byte val)
LevelFarView = val;
}
}
// todo test this
RGBAColor8Byte GameScriptLevel::GetSkyLayerColor(int index) const
{
bool cond = index == 0 || index == 1;
std::string msg{ "Index must be 0 or 1." };
if (index == 0)
{
return Layer1.GetColor();
}
else if (index == 1)
{
return Layer2.GetColor();
}
else
{
ScriptAssert(false, msg);
ScriptWarn("Returning 0, 0, 0, 0.");
return RGBAColor8Byte{ 0 };
}
}
LaraType GameScriptLevel::GetLaraType() const
{
return Type;
}
bool GameScriptLevel::HasStorm() const
{
return Storm;
}
float GameScriptLevel::GetWeatherStrength() const
{
return WeatherStrength;
}
WeatherType GameScriptLevel::GetWeatherType() const
{
return Weather;
}

View file

@ -51,3 +51,7 @@ void GameScriptSkyLayer::SetColor(GameScriptColor const & col)
B = col.GetB();
}
//todo can this return an RGBAColor8Byte instead?
GameScriptColor GameScriptSkyLayer::GetColor() const {
return GameScriptColor{ R, G, B };
}

View file

@ -424,8 +424,8 @@ void LaraSwimCollision(ITEM_INFO* item, COLL_INFO* coll)
height = abs(height);
auto level = g_GameFlow->GetLevel(CurrentLevel);
if (height < ((level->LaraType == LaraType::Divesuit) << 6) + 200)
height = ((level->LaraType == LaraType::Divesuit) << 6) + 200;
if (height < ((level->GetLaraType() == LaraType::Divesuit) << 6) + 200)
height = ((level->GetLaraType() == LaraType::Divesuit) << 6) + 200;
coll->Setup.BadHeightUp = -(STEP_SIZE / 4);
coll->Setup.Height = height;

View file

@ -42,7 +42,7 @@ namespace Environment
void EnvironmentController::Update()
{
GameScriptLevel* level = g_GameFlow->GetLevel(CurrentLevel);
ScriptInterfaceLevel* level = g_GameFlow->GetLevel(CurrentLevel);
UpdateSky(level);
UpdateStorm(level);
@ -80,7 +80,7 @@ namespace Environment
std::clamp(b, 0, UCHAR_MAX) / (float)UCHAR_MAX);
}
void EnvironmentController::UpdateSky(GameScriptLevel* level)
void EnvironmentController::UpdateSky(ScriptInterfaceLevel* level)
{
if (level->GetSkyLayerEnabled(0))
{
@ -111,11 +111,11 @@ namespace Environment
}
}
void EnvironmentController::UpdateStorm(GameScriptLevel* level)
void EnvironmentController::UpdateStorm(ScriptInterfaceLevel* level)
{
auto color = Vector4(level->Layer1.R / 255.0f, level->Layer1.G / 255.0f, level->Layer1.B / 255.0f, 1.0f);
auto color = Vector4(level->GetSkyLayerColor(0).GetR() / 255.0f, level->GetSkyLayerColor(0).GetG() / 255.0f, level->GetSkyLayerColor(0).GetB() / 255.0f, 1.0f);
if (level->Storm)
if (level->HasStorm())
{
if (StormCount || StormRand)
{
@ -168,7 +168,7 @@ namespace Environment
}
}
void EnvironmentController::UpdateWind(GameScriptLevel* level)
void EnvironmentController::UpdateWind(ScriptInterfaceLevel* level)
{
WindCurrent += (GetRandomControl() & 7) - 3;
if (WindCurrent <= -2)
@ -189,7 +189,7 @@ namespace Environment
WindZ = WindCurrent * phd_cos(WindAngle << 3);
}
void EnvironmentController::UpdateFlash(GameScriptLevel* level)
void EnvironmentController::UpdateFlash(ScriptInterfaceLevel* level)
{
if (FlashProgress > 0.0f)
{
@ -202,7 +202,7 @@ namespace Environment
FlashColorBase = Vector3::Zero;
}
void EnvironmentController::UpdateWeather(GameScriptLevel* level)
void EnvironmentController::UpdateWeather(ScriptInterfaceLevel* level)
{
for (auto& p : Particles)
{
@ -363,7 +363,7 @@ namespace Environment
p.Velocity.z = 4;
}
if (p.Velocity.y < p.Size * 2 * std::clamp(level->WeatherStrength, 0.6f, 1.0f))
if (p.Velocity.y < p.Size * 2 * std::clamp(level->GetWeatherStrength(), 0.6f, 1.0f))
p.Velocity.y += p.Size / 5.0f;
break;
@ -371,13 +371,13 @@ namespace Environment
}
}
void EnvironmentController::SpawnWeatherParticles(GameScriptLevel* level)
void EnvironmentController::SpawnWeatherParticles(ScriptInterfaceLevel* level)
{
// Clean up dead particles
if (Particles.size() > 0)
Particles.erase(std::remove_if(Particles.begin(), Particles.end(), [](const WeatherParticle& part) { return !part.Enabled; }), Particles.end());
if (level->Weather == WeatherType::None || level->WeatherStrength == 0.0f)
if (level->Weather == WeatherType::None || level->GetWeatherStrength() == 0.0f)
return;
int newParticlesCount = 0;

View file

@ -1,10 +1,8 @@
#pragma once
#include <SimpleMath.h>
#include "Scripting/ScriptInterfaceLevel.h"
#include "ScriptInterfaceLevel.h"
#include "Specific/trmath.h"
class GameScriptLevel;
namespace TEN {
namespace Effects {
namespace Environment
@ -90,14 +88,14 @@ namespace Environment
byte StormSkyColor = 1;
byte StormSkyColor2 = 1;
void UpdateSky(GameScriptLevel* level);
void UpdateStorm(GameScriptLevel* level);
void UpdateWind(GameScriptLevel* level);
void UpdateFlash(GameScriptLevel* level);
void UpdateWeather(GameScriptLevel* level);
void UpdateSky(ScriptInterfaceLevel* level);
void UpdateStorm(ScriptInterfaceLevel* level);
void UpdateWind(ScriptInterfaceLevel* level);
void UpdateFlash(ScriptInterfaceLevel* level);
void UpdateWeather(ScriptInterfaceLevel* level);
void UpdateLightning();
void SpawnWeatherParticles(GameScriptLevel* level);
void SpawnWeatherParticles(ScriptInterfaceLevel* level);
};
extern EnvironmentController Weather;