diff --git a/CHANGELOG.md b/CHANGELOG.md
index 301a29fcb..983158c3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -34,7 +34,6 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Added TR4 Statue Plinth.
### Lua API changes
-
* Added Collision.Probe class for basic room collision detection.
* Added advanced particle emitter allowing animations and other effects.
* Added diary module.
@@ -46,11 +45,13 @@ TombEngine releases are located in this repository (alongside with Tomb Editor):
* Added Effects.EmitStreamer() function to emit streamers.
* Added Moveable:GetScale() and Movebale:SetScale() methods to set visible scale of moveables.
* Added Rotation:Lerp() function to allow linear interpolation between rotations.
+* Added ability to perform additive and subtractive operations on Rotation class and compare one Rotation to another.
* Added various Translate() methods to Vec2 and Vec3 script objects.
* Added alpha transparency functionality for statics and moveables to be used with SetColor() method.
* Added extra arguments for sprite object slots and starting rotation value for EmitParticle function.
-* Added ability to save Flow.Level fields such as fog or horizon to a savegame.
+* Added ability to dynamically change Flow.Level fields such as fog, starfield or horizon, and save them to a savegame.
* Added pickup count to Flow.Statistics class.
+* Changed Flow.StarField and Flow.LensFlare primitive types to use parameters instead of getters and setters.
* Fixed medipack level count in Flow.Statistics class.
## [Version 1.7.1](https://github.com/TombEngine/TombEditorReleases/releases/tag/v1.7.4) - 2025-04-01
diff --git a/Documentation/config.ld b/Documentation/config.ld
index bae3388cd..abc23eb0c 100644
--- a/Documentation/config.ld
+++ b/Documentation/config.ld
@@ -12,27 +12,27 @@ new_type("luautil", "5 Lua utility modules", true)
not_luadoc = true
-local version = "1.7.2 (Developer)"
+local version = "1.8"
project = " TombEngine"
title = "TombEngine " .. version .. " Lua API"
description = "TombEngine " .. version .. " scripting interface"
-full_description = [[Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.
+full_description = [[Welcome to the TombEngine scripting API.
+Note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.
At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website .
-####Module Hierarchy (boring but important)
-Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN.
+
+####Module Hierarchy
+Other than the "special tables" (`GameVars`, `LevelVars` and `LevelFuncs`), every module described herein is held in a master table called TEN.
For convenience, these modules and classes are automatically put in the global table. For example, you can call GetMoveableByName either of these two ways:
local door = TEN.Objects.GetMoveableByName("door_type4_14")
local door = GetMoveableByName("door_type4_14")
####Always check logs/TENLog.txt
-If you are scripting levels, TombEngine will often kick you back to the title screen, even if `errorMode` (see Flow.Settings) is set to `ErrorMode.WARN` or `ErrorMode.SILENT`.
+If you are scripting levels, TombEngine will often kick you back to the title screen, even if `errorMode` (see @{Flow.Settings}) is set to `ErrorMode.WARN` or `ErrorMode.SILENT`.
-This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing `end` at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless.
+This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing `end` at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless. If this happens, check __logs/TENLog.txt__ and look for an error message with the word "unrecoverable".
-If this happens, check __logs/TENLog.txt__ and look for an error message with the word "unrecoverable".
-
-Enjoy.
+Happy building!
\- _squidshire and the TombEngine development team._
]]
diff --git a/Documentation/doc/1 modules/Effects.html b/Documentation/doc/1 modules/Effects.html
index 3e7751034..1a475096e 100644
--- a/Documentation/doc/1 modules/Effects.html
+++ b/Documentation/doc/1 modules/Effects.html
@@ -3,7 +3,7 @@
-
- PlayAudioTrack(name, type)
- Play an audio track
+ PlayAudioTrack(filename, type)
+ Play an audio track.
SetAmbientTrack(name, fromStart)
- Set and play an ambient track
+ Set and play an ambient track.
StopAudioTracks()
- Stop any audio tracks currently playing
+ Stop any audio tracks currently playing.
StopAudioTrack(type)
- Stop audio track that is currently playing
+ Stop audio track that is currently playing.
GetAudioTrackLoudness(type)
- Get current loudness level for specified track type
+ Get current loudness level for specified track type.
- PlaySound(sound[, position])
- Play sound effect
+ PlaySound(soundID[, position])
+ Play sound effect.
- StopSound(sound)
- Stop sound effect
+ StopSound(soundID)
+ Stop sound effect.
- IsSoundPlaying(Sound)
- Check if the sound effect is playing
+ IsSoundPlaying(soundID)
+ Check if the sound effect is playing.
IsAudioTrackPlaying(Track)
- Check if the audio track is playing
+ Check if the audio track is playing.
GetCurrentSubtitle()
@@ -174,22 +174,22 @@
- PlayAudioTrack(name, type)
+ PlayAudioTrack(filename, type)
- Play an audio track
+ Play an audio track. Supported formats are wav, mp3 and ogg.
Parameters:
- name
+ filename
string
- of track (without file extension) to play
+ Filename of a track (without file extension) to play.
type
SoundTrackType
- of the audio track to play
+ Type of the audio track to play.
@@ -203,7 +203,7 @@
SetAmbientTrack(name, fromStart)
- Set and play an ambient track
+ Set and play an ambient track.
@@ -211,11 +211,11 @@
name
string
- of track (without file extension) to play
+ Name of track (without file extension) to play.
fromStart
bool
- specifies whether ambient track should play from the start, or crossfade at a random position
+ Specifies whether ambient track should play from the start, or crossfade at a random position.
@@ -229,7 +229,7 @@
StopAudioTracks()
- Stop any audio tracks currently playing
+ Stop any audio tracks currently playing.
@@ -244,7 +244,7 @@
StopAudioTrack(type)
- Stop audio track that is currently playing
+ Stop audio track that is currently playing.
@@ -252,7 +252,7 @@
@@ -266,7 +266,7 @@
GetAudioTrackLoudness(type)
- Get current loudness level for specified track type
+ Get current loudness level for specified track type.
@@ -274,7 +274,7 @@
@@ -282,7 +282,7 @@
float
- current loudness of a specified audio track
+ Current loudness of a specified audio track.
@@ -291,18 +291,18 @@
- PlaySound(sound[, position])
+ PlaySound(soundID[, position])
- Play sound effect
+ Play sound effect.
Parameters:
- sound
+ soundID
int
- ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
+ Sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
position
Vec3
@@ -318,18 +318,18 @@
- StopSound(sound)
+ StopSound(soundID)
- Stop sound effect
+ Stop sound effect.
Parameters:
- sound
+ soundID
int
- ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
+ Sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
@@ -340,18 +340,18 @@
- IsSoundPlaying(Sound)
+ IsSoundPlaying(soundID)
- Check if the sound effect is playing
+ Check if the sound effect is playing.
Parameters:
- Sound
+ soundID
int
- ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
+ Sound ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
@@ -365,7 +365,7 @@
IsAudioTrackPlaying(Track)
- Check if the audio track is playing
+ Check if the audio track is playing.
@@ -373,7 +373,7 @@
Track
string
- filename to check. Should be without extension and without full directory path.
+ Filename to check. Should be without extension and without full directory path.
@@ -388,8 +388,8 @@
Get current subtitle string for a voice track currently playing.
-Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track.
-Returns nil if no voice track is playing or no subtitle present.
+ Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track.
+ Returns nil if no voice track is playing or no subtitle present.
@@ -398,7 +398,7 @@ Returns nil if no voice track is playing or no subtitle present.
string
- current subtitle string
+ Current subtitle string.
diff --git a/Documentation/doc/1 modules/Strings.html b/Documentation/doc/1 modules/Strings.html
index 0dde6ad65..c3c57ea92 100644
--- a/Documentation/doc/1 modules/Strings.html
+++ b/Documentation/doc/1 modules/Strings.html
@@ -3,7 +3,7 @@
- TombEngine 1.7.2 (Developer) Lua API
+ TombEngine 1.8 Lua API
@@ -68,7 +68,7 @@
Flow.InventoryItem
Flow.LensFlare
Flow.SkyLayer
- Flow.Starfield
+ Flow.StarField
Color
Rotation
Time
diff --git a/Documentation/doc/1 modules/Util.html b/Documentation/doc/1 modules/Util.html
index 97a387d2a..6e7bf0f91 100644
--- a/Documentation/doc/1 modules/Util.html
+++ b/Documentation/doc/1 modules/Util.html
@@ -3,7 +3,7 @@
- TombEngine 1.7.2 (Developer) Lua API
+ TombEngine 1.8 Lua API
@@ -68,7 +68,7 @@
Flow.InventoryItem
Flow.LensFlare
Flow.SkyLayer
- Flow.Starfield
+ Flow.StarField
Color
Rotation
Time
diff --git a/Documentation/doc/1 modules/View.html b/Documentation/doc/1 modules/View.html
index e1bb7aa4d..45bcd0fc5 100644
--- a/Documentation/doc/1 modules/View.html
+++ b/Documentation/doc/1 modules/View.html
@@ -3,7 +3,7 @@
- TombEngine 1.7.2 (Developer) Lua API
+ TombEngine 1.8 Lua API
@@ -68,7 +68,7 @@
Flow.InventoryItem
Flow.LensFlare
Flow.SkyLayer
- Flow.Starfield
+ Flow.StarField
Color
Rotation
Time
diff --git a/Documentation/doc/2 classes/Collision.Probe.html b/Documentation/doc/2 classes/Collision.Probe.html
index 7470c4456..d897d847f 100644
--- a/Documentation/doc/2 classes/Collision.Probe.html
+++ b/Documentation/doc/2 classes/Collision.Probe.html
@@ -3,7 +3,7 @@
- TombEngine 1.7.2 (Developer) Lua API
+ TombEngine 1.8 Lua API
@@ -68,7 +68,7 @@
Flow.InventoryItem
Flow.LensFlare
Flow.SkyLayer
- Flow.Starfield
+ Flow.StarField
Color
Rotation
Time
diff --git a/Documentation/doc/2 classes/Flow.Level.html b/Documentation/doc/2 classes/Flow.Level.html
index 780c9ba38..88af887a2 100644
--- a/Documentation/doc/2 classes/Flow.Level.html
+++ b/Documentation/doc/2 classes/Flow.Level.html
@@ -3,7 +3,7 @@
- TombEngine 1.7.2 (Developer) Lua API
+ TombEngine 1.8 Lua API
@@ -68,7 +68,7 @@
Flow.InventoryItem
Flow.LensFlare
Flow.SkyLayer
- Flow.Starfield
+ Flow.StarField
Color
Rotation
Time
@@ -143,31 +143,31 @@
layer1
- (Flow.SkyLayer ) Primary sky layer
+ (Flow.SkyLayer ) Primary sky cloud layer.
layer2
- (Flow.SkyLayer ) Secondary sky layer
+ (Flow.SkyLayer ) Secondary sky cloud layer.
horizon1
(Flow.Horizon ) First horizon layer.
- horizon1
+ horizon2
(Flow.Horizon ) Second horizon layer.
- starfield
- (Flow.Starfield ) Starfield.
+ starField
+ (Flow.StarField ) Starfield in the sky.
lensFlare
- (Flow.LensFlare ) Global lens flare .
+ (Flow.LensFlare ) Global lens flare.
fog
- (Flow.Fog ) omni fog RGB color and distance.
+ (Flow.Fog ) Global distance fog, with specified RGB color and distance.
storm
@@ -199,11 +199,11 @@
objects
- (table of Flow.InventoryItem s) table of inventory object overrides
+ (table of Flow.InventoryItem s) A table of inventory object layout overrides.
secrets
- (short) Set Secrets for Level
+ (short) Set total secret count for current level.
Constants for particle animation type constants.
-
-
TombEngine 1.7.2 (Developer) scripting interface
-
Welcome to the TombEngine scripting API. This is a work in progress and some information might be wrong or outdated. Please also note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.
+
TombEngine 1.8 scripting interface
+
Welcome to the TombEngine scripting API.
-
At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website .
-
Module Hierarchy (boring but important)
-
Other than the "special tables" (GameVars, LevelVars and LevelFuncs), every module described herein is held in a master table called TEN.
+
Note that this is primarily a reference document, not a tutorial, so expect descriptions to be fairly sparse.
+At the time of writing, there is a tutorial describing the basics of Lua, as well as a number of example scripts, on the TombEngine website .
+
+
Module Hierarchy
+
Other than the "special tables" (GameVars
, LevelVars
and LevelFuncs
), every module described herein is held in a master table called TEN.
For convenience, these modules and classes are automatically put in the global table. For example, you can call GetMoveableByName either of these two ways:
local door = TEN.Objects.GetMoveableByName("door_type4_14")
local door = GetMoveableByName("door_type4_14")
Always check logs/TENLog.txt
-
If you are scripting levels, TombEngine will often kick you back to the title screen, even if errorMode
(see Flow.Settings) is set to ErrorMode.WARN
or ErrorMode.SILENT
.
+
If you are scripting levels, TombEngine will often kick you back to the title screen, even if errorMode
(see Flow.Settings ) is set to ErrorMode.WARN
or ErrorMode.SILENT
.
-
This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing end
at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless.
+
This might get annoying, but it's on purpose. If your Lua script contains a syntax error (e.g. you're missing end
at the end of a function), the Lua interpreter will not be able to continue running the script. If it tried to keep running, you'd probably see some pretty strange behaviour, and would possibly get a crash regardless. If this happens, check logs/TENLog.txt and look for an error message with the word "unrecoverable".
-
If this happens, check logs/TENLog.txt and look for an error message with the word "unrecoverable".
-
-
Enjoy.
+
Happy building!
- squidshire and the TombEngine development team.
@@ -247,7 +247,7 @@ local door = GetMoveableByName("door_type4_14")
Flow.Fog
- Distance fog.
+ Represesnts distance fog.
Flow.Horizon
@@ -266,8 +266,8 @@ local door = GetMoveableByName("door_type4_14")
Describes a layer of moving clouds.
- Flow.Starfield
- Represents a starfield in the sky.
+ Flow.StarField
+ Represents a star field in the sky.
Color
diff --git a/TombEngine/Game/effects/weather.cpp b/TombEngine/Game/effects/weather.cpp
index 472e76fe0..34a235054 100644
--- a/TombEngine/Game/effects/weather.cpp
+++ b/TombEngine/Game/effects/weather.cpp
@@ -232,52 +232,65 @@ namespace TEN::Effects::Environment
void EnvironmentController::UpdateStarfield(const ScriptInterfaceLevel& level)
{
- if (!level.GetStarfieldStarsEnabled())
+ int starCount = level.GetStarfieldStarCount();
+ if (starCount == 0)
return;
if (ResetStarField)
{
- int starCount = level.GetStarfieldStarCount();
-
Stars.clear();
- Stars.reserve(starCount);
+ ResetStarField = false;
+ }
- for (int i = 0; i < starCount; i++)
+ if (starCount != Stars.size())
+ {
+ // If starCount increased, add new stars to existing list.
+ if (starCount > Stars.size())
{
- auto starDir = Random::GenerateDirectionInCone(-Vector3::UnitY, 70.0f);
- starDir.Normalize();
+ // Reserve space for new stars if necessary.
+ Stars.reserve(starCount);
- auto star = StarParticle{};
- star.Direction = starDir;
- star.Color = Vector3(
- Random::GenerateFloat(0.6f, 1.0f),
- Random::GenerateFloat(0.6f, 1.0f),
- Random::GenerateFloat(0.6f, 1.0f));
- star.Scale = Random::GenerateFloat(0.5f, 1.5f);
-
- float cosine = Vector3::UnitY.Dot(starDir);
- float maxCosine = cos(DEG_TO_RAD(50.0f));
- float minCosine = cos(DEG_TO_RAD(70.0f));
-
- if (cosine >= minCosine && cosine <= maxCosine)
+ for (int i = (int)Stars.size(); i < starCount; i++)
{
- star.Extinction = (cosine - minCosine) / (maxCosine - minCosine);
- }
- else
- {
- star.Extinction = 1.0f;
- }
+ auto starDir = Random::GenerateDirectionInCone(-Vector3::UnitY, 70.0f);
+ starDir.Normalize();
- Stars.push_back(star);
+ auto star = StarParticle{};
+ star.Direction = starDir;
+ star.Color = Vector3(
+ Random::GenerateFloat(0.6f, 1.0f),
+ Random::GenerateFloat(0.6f, 1.0f),
+ Random::GenerateFloat(0.6f, 1.0f));
+ star.Scale = Random::GenerateFloat(0.5f, 1.5f);
+
+ float cosine = Vector3::UnitY.Dot(starDir);
+ float maxCosine = cos(DEG_TO_RAD(50.0f));
+ float minCosine = cos(DEG_TO_RAD(70.0f));
+
+ if (cosine >= minCosine && cosine <= maxCosine)
+ {
+ star.Extinction = (cosine - minCosine) / (maxCosine - minCosine);
+ }
+ else
+ {
+ star.Extinction = 1.0f;
+ }
+
+ Stars.push_back(star);
+ }
+ }
+ // If starCount decreased, resize vector without reinitializing.
+ else
+ {
+ Stars.resize(starCount);
}
- ResetStarField = false;
}
for (auto& star : Stars)
star.Blinking = Random::GenerateFloat(0.5f, 1.0f);
- if (level.GetStarfieldMeteorsEnabled())
+ if (level.GetStarfieldMeteorCount() > 0)
{
for (auto& meteor : Meteors)
{
@@ -639,7 +652,7 @@ namespace TEN::Effects::Environment
Meteors.end());
}
- if (!level.GetStarfieldMeteorsEnabled())
+ if (level.GetStarfieldMeteorCount() == 0)
return;
int density = level.GetStarfieldMeteorSpawnDensity();
diff --git a/TombEngine/Scripting/Include/ScriptInterfaceLevel.h b/TombEngine/Scripting/Include/ScriptInterfaceLevel.h
index 0bef47771..e091044b0 100644
--- a/TombEngine/Scripting/Include/ScriptInterfaceLevel.h
+++ b/TombEngine/Scripting/Include/ScriptInterfaceLevel.h
@@ -62,8 +62,6 @@ public:
virtual Color GetLensFlareColor() const = 0;
// Starfield getters
- virtual bool GetStarfieldStarsEnabled() const = 0;
- virtual bool GetStarfieldMeteorsEnabled() const = 0;
virtual int GetStarfieldStarCount() const = 0;
virtual int GetStarfieldMeteorCount() const = 0;
virtual int GetStarfieldMeteorSpawnDensity() const = 0;
diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h
index 7db33a007..c3307b918 100644
--- a/TombEngine/Scripting/Internal/ReservedScriptNames.h
+++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h
@@ -433,25 +433,6 @@ constexpr char ScriptReserved_ProbePreview[] = "Preview";
constexpr char ScriptReserved_MaterialType[] = "MaterialType";
-// ====
-// FLOW
-// ====
-
-// Horizon
-
-constexpr char ScriptReserved_Horizon[] = "Horizon";
-constexpr char ScriptReserved_HorizonGetEnabled[] = "GetEnabled";
-constexpr char ScriptReserved_HorizonGetObjectID[] = "GetObjectID";
-constexpr char ScriptReserved_HorizonGetPosition[] = "GetPosition";
-constexpr char ScriptReserved_HorizonGetRotation[] = "GetRotation";
-constexpr char ScriptReserved_HorizonGetTransparency[] = "GetTransparency";
-constexpr char ScriptReserved_HorizonSetEnabled[] = "SetEnabled";
-constexpr char ScriptReserved_HorizonSetObjectID[] = "SetObjectID";
-constexpr char ScriptReserved_HorizonSetPosition[] = "SetPosition";
-constexpr char ScriptReserved_HorizonSetRotation[] = "SetRotation";
-constexpr char ScriptReserved_HorizonSetTransparency[] = "SetTransparency";
-
-
// =======
// OBJECTS
// =======
diff --git a/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h b/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h
index d992641fa..1adae829e 100644
--- a/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h
+++ b/TombEngine/Scripting/Internal/TEN/Effects/ParticleAnimTypes.h
@@ -4,7 +4,7 @@
namespace TEN::Scripting::Effects
{
- /// Constants for particle animation type constants.
+ /// Constants for particle animation type constants. To be used with @{Effects.EmitAdvancedParticle} function.
// @enum Effects.ParticleAnimationType
// @pragma nostrip
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp
index ffc6032f9..bb7612114 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Fog/Fog.cpp
@@ -6,7 +6,7 @@
using namespace TEN::Scripting::Types;
/***
-Distance fog.
+Represesnts distance fog. To be used with @{Flow.Level.fog} property.
@tenprimitive Flow.Fog
@pragma nostrip
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp
index 52f24820d..1d4ef80a4 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Horizon/Horizon.cpp
@@ -9,7 +9,7 @@
namespace TEN::Scripting
{
- /// Represents a horizon.
+ /// Represents a horizon. To be used with @{Flow.Level.horizon1} and @{Flow.Level.horizon2} properties.
//
// @tenprimitive Flow.Horizon
// @pragma nostrip
@@ -22,22 +22,32 @@ namespace TEN::Scripting
// Register type.
parent.new_usertype(
- ScriptReserved_Horizon,
+ "Horizon",
ctors(), sol::call_constructor, ctors(),
- // Getters
- ScriptReserved_HorizonGetEnabled, &Horizon::GetEnabled,
- ScriptReserved_HorizonGetObjectID, &Horizon::GetObjectID,
- ScriptReserved_HorizonGetPosition, &Horizon::GetPosition,
- ScriptReserved_HorizonGetRotation, &Horizon::GetRotation,
- ScriptReserved_HorizonGetTransparency, &Horizon::GetTransparency,
+ /// (bool) Horizon enabled state.
+ // If set to true, horizon will be visible.
+ // @mem enabled
+ "enabled", sol::property(&Horizon::GetEnabled, &Horizon::SetEnabled),
- // Setters
- ScriptReserved_HorizonSetEnabled, &Horizon::SetEnabled,
- ScriptReserved_HorizonSetObjectID, &Horizon::SetObjectID,
- ScriptReserved_HorizonSetPosition, &Horizon::SetPosition,
- ScriptReserved_HorizonSetRotation, &Horizon::SetRotation,
- ScriptReserved_HorizonSetTransparency, &Horizon::SetTransparency);
+ /// (Objects.ObjID) Horizon object ID.
+ // @mem objectID
+ "objectID", sol::property(&Horizon::GetObjectID, &Horizon::SetObjectID),
+
+ /// (Vec3) Horizon position.
+ // Specifies an offset from the camera origin.
+ // @mem position
+ "position", sol::property(&Horizon::GetPosition, &Horizon::SetPosition),
+
+ /// (Rotation) Horizon rotation.
+ // Specifies horizon rotation.
+ // @mem rotation
+ "rotation", sol::property(&Horizon::GetRotation, &Horizon::SetRotation),
+
+ /// (float) Horizon transparency.
+ // Specifies horizon transparency on a range from 0 to 1.
+ // @mem transparency
+ "transparency", sol::property(&Horizon::GetTransparency, &Horizon::SetTransparency));
}
/// Create a horizon object.
@@ -56,89 +66,53 @@ namespace TEN::Scripting
_enabled = enabled;
}
- /// Get the horizon's enabled state.
- // @function GetEnabled
- // @treturn bool Enabled state.
bool Horizon::GetEnabled() const
{
return _enabled;
}
- /// Get the horizon's slot object ID.
- // @function GetObjectID
- // @treturn Objects.ObjID Object ID.
GAME_OBJECT_ID Horizon::GetObjectID() const
{
return _objectID;
}
- /// Get the horizon's world position.
- // @function GetPosition
- // @treturn Vec3 Position.
const Vec3 Horizon::GetPosition() const
{
return _position;
}
- /// Get the horizon's rotation.
- // @function GetRotation
- // @treturn Rotation Rotation.
const Rotation Horizon::GetRotation() const
{
return _rotation;
}
- /// Get the horizon's transparency.
- // @function GetTransparency
- // @treturn float Transparency.
const float Horizon::GetTransparency() const
{
return _transparency;
}
- /// Set the horizon's enabled state.
- // @function SetEnabled
- // @tparam bool enabled New enabled state.
void Horizon::SetEnabled(bool value)
{
_enabled = value;
}
- /// Set the horizon's object ID.
- // @function SetObjectID
- // @tparam Objects.ObjID objectID Object ID.
void Horizon::SetObjectID(GAME_OBJECT_ID objectID)
{
_objectID = objectID;
}
- /// Set the horizon's world position.
- // @function SetPosition
- // @tparam Vec3 pos New world position.
- // @tparam[opt] bool noInterpolation Disable interpolation with the previous frame's position. __default: false__
void Horizon::SetPosition(const Vec3& pos, TypeOrNil noInterpolation)
{
- bool convertedDisableInterp = ValueOr(noInterpolation, false);
-
- _prevPosition = convertedDisableInterp ? pos : _position;
+ _prevPosition = ValueOr(noInterpolation, false) ? pos : _position;
_position = pos;
}
- /// Set the horizon's rotation.
- // @function SetRotation
- // @tparam Rotation rot New rotation.
- // @tparam[opt] bool noInterpolation Disable interpolation with the previous frame's rotation. __default: false__
void Horizon::SetRotation(const Rotation& rot, TypeOrNil noInterpolation)
{
- bool convertedDisableInterp = ValueOr(noInterpolation, false);
-
- _prevRotation = convertedDisableInterp ? rot : _rotation;
+ _prevRotation = ValueOr(noInterpolation, false) ? rot : _rotation;
_rotation = rot;
}
- /// Set the horizon's transparency.
- // @function SetTransparency
- // @tparam float transparency New transparency alpha.
void Horizon::SetTransparency(float value)
{
_transparency = value;
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp
index 5037763ca..9d229fb41 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/InventoryItem/InventoryItem.cpp
@@ -4,9 +4,7 @@
#include "Scripting/Internal/ReservedScriptNames.h"
#include "Scripting/Internal/ScriptAssert.h"
-/***
-Represents the properties of an object as it appears in the inventory.
-
+/*** Represents the properties of an object as it appears in the inventory. To be used in @{Flow.Level.objects} list.
@tenprimitive Flow.InventoryItem
@pragma nostrip
*/
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp
index 30e0718a0..2db27d8db 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.cpp
@@ -8,7 +8,7 @@
using namespace TEN::Scripting::Types;
-/// Represents a global lens flare (not to be confused with the lens flare object).
+/// Represents a global lens flare (not to be confused with the lens flare object). To be used with @{Flow.Level.lensFlare} property.
//
// @tenprimitive Flow.LensFlare
// @pragma nostrip
@@ -25,16 +25,39 @@ namespace TEN::Scripting
"LensFlare",
ctors(), sol::call_constructor, ctors(),
+ /// (bool) Lens flare enabled state.
+ // If set to true, lens flare will be visible.
+ // @mem enabled
+ "enabled", sol::property(&LensFlare::GetEnabled, &LensFlare::SetEnabled),
+
+ /// (int) Lens flare's sun sprite object ID.
+ // @mem spriteID
+ "spriteID", sol::property(&LensFlare::GetSunSpriteID, &LensFlare::SetSunSpriteID),
+
+ /// (float) Lens flare's pitch (vertical) angle in degrees.
+ // @mem pitch
+ "pitch", sol::property(&LensFlare::GetPitch, &LensFlare::SetPitch),
+
+ /// (float) Lens flare's yaw (horizontal) angle in degrees.
+ // @mem yaw
+ "yaw", sol::property(&LensFlare::GetYaw, &LensFlare::SetYaw),
+
+ /// (Color) Lens flare's color.
+ // @mem color
+ "color", sol::property(&LensFlare::GetColor, &LensFlare::SetColor),
+
+ // Compatibility.
"GetSunSpriteID", &LensFlare::GetSunSpriteID,
"GetPitch", &LensFlare::GetPitch,
"GetYaw", &LensFlare::GetYaw,
"GetColor", &LensFlare::GetColor,
- "GetEnabled", &LensFlare::GetEnabledStatus,
+ "GetEnabled", &LensFlare::GetEnabled,
"SetSunSpriteID", &LensFlare::SetSunSpriteID,
"SetPitch", &LensFlare::SetPitch,
"SetYaw", &LensFlare::SetYaw,
- "SetColor", &LensFlare::SetColor);
+ "SetColor", &LensFlare::SetColor,
+ "SetEnabled", &LensFlare::SetEnabled);
}
/// Create a LensFlare object.
@@ -50,48 +73,31 @@ namespace TEN::Scripting
_rotation = Rotation(pitch, yaw, 0.0f);
}
- /// Get this lens flare's sun sprite ID.
- // @function LensFlare:GetSunSpriteID
- // @treturn int Sprite ID.
int LensFlare::GetSunSpriteID() const
{
return _sunSpriteID;
}
- /// Get this lens flare's pitch angle in degrees.
- // @function LensFlare:GetPitch
- // @treturn float Pitch angle in degrees.
float LensFlare::GetPitch() const
{
return _rotation.x;
}
- /// Get this lens flare's yaw angle in degrees.
- // @function LensFlare:GetYaw
- // @treturn float Yaw angle in degrees.
float LensFlare::GetYaw() const
{
return _rotation.y;
}
- /// Get the lens flare's color.
- // @function LensFlare:GetColor
ScriptColor LensFlare::GetColor() const
{
return _color;
}
- /// Get this lens flare's enabled status.
- // @function LensFlare:GetEnabled
- // @treturn bool Enabled status. __true: enabled__, __false: disabled__
- bool LensFlare::GetEnabledStatus() const
+ bool LensFlare::GetEnabled() const
{
return _isEnabled;
}
- /// Set this lens flare's sun sprite ID.
- // @function LensFlare:SetSunSpriteID
- // @tparam int spriteID New sun sprite ID.
void LensFlare::SetSunSpriteID(int spriteID)
{
// Sprite ID out of range; return early.
@@ -104,27 +110,23 @@ namespace TEN::Scripting
_sunSpriteID = spriteID;
}
- /// Set this lens flare's pitch angle.
- // @function LensFlare:SetPitch
- // @tparam float pitch New pitch angle in degrees.
void LensFlare::SetPitch(float pitch)
{
_rotation.x = pitch;
}
- /// Set this lens flare's yaw angle.
- // @function LensFlare:SetYaw
- // @tparam float yaw New yaw angle in degrees.
void LensFlare::SetYaw(float yaw)
{
_rotation.y = yaw;
}
-
- /// Set this lens flare's color.
- // @function LensFlare:SetColor
- // @tparam Color color New color.
+
void LensFlare::SetColor(const ScriptColor& color)
{
_color = color;
}
+
+ void LensFlare::SetEnabled(bool value)
+ {
+ _isEnabled = value;
+ }
}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h
index d1585ac5d..bbf2f1cff 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/LensFlare/LensFlare.h
@@ -39,7 +39,7 @@ namespace TEN::Scripting
float GetPitch() const;
float GetYaw() const;
ScriptColor GetColor() const;
- bool GetEnabledStatus() const;
+ bool GetEnabled() const;
// Setters
@@ -47,5 +47,6 @@ namespace TEN::Scripting
void SetPitch(float pitch);
void SetYaw(float yaw);
void SetColor(const ScriptColor& color);
+ void SetEnabled(bool value);
};
}
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp
index 837b6af77..410311789 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.cpp
@@ -15,7 +15,7 @@ These are things things which aren't present in the compiled level file itself.
/// Make a new Level object.
//@function Level
-//@treturn Level a Level object
+//@treturn Level a Level object.
void Level::Register(sol::table& parent)
{
// Register type.
@@ -49,11 +49,11 @@ void Level::Register(sol::table& parent)
//@mem ambientTrack
"ambientTrack", &Level::AmbientTrack,
-/// (@{Flow.SkyLayer}) Primary sky layer
+/// (@{Flow.SkyLayer}) Primary sky cloud layer.
//@mem layer1
"layer1", &Level::Layer1,
-/// (@{Flow.SkyLayer}) Secondary sky layer
+/// (@{Flow.SkyLayer}) Secondary sky cloud layer.
//@mem layer2
"layer2", &Level::Layer2,
@@ -63,20 +63,20 @@ void Level::Register(sol::table& parent)
"horizon", sol::property(&Level::GetHorizon1Enabled, &Level::SetHorizon1Enabled), // Compatibility.
/// (@{Flow.Horizon}) Second horizon layer.
-//@mem horizon1
+//@mem horizon2
"horizon2", &Level::Horizon2,
-/// (@{Flow.Starfield}) Starfield.
-// @mem starfield
- "starfield", &Level::Starfield,
+/// (@{Flow.StarField}) Starfield in the sky.
+// @mem starField
+ "starField", &Level::Starfield,
+ "starfield", &Level::Starfield, // Compatibility.
-/// (@{Flow.LensFlare}) Global lens flare .
+/// (@{Flow.LensFlare}) Global lens flare.
// @mem lensFlare
"lensFlare", &Level::LensFlare,
-/// (@{Flow.Fog}) omni fog RGB color and distance.
-// As seen in TR4's Desert Railroad.
-// If not provided, distance fog will be black.
+/// (@{Flow.Fog}) Global distance fog, with specified RGB color and distance.
+// If not provided, distance fog will not be visible.
//@mem fog
"fog", &Level::Fog,
@@ -126,11 +126,11 @@ e.g. `myLevel.laraType = LaraType.Divesuit`
//@mem resetHub
"resetHub", &Level::ResetHub,
-/// (table of @{Flow.InventoryItem}s) table of inventory object overrides
+/// (table of @{Flow.InventoryItem}s) A table of inventory object layout overrides.
//@mem objects
"objects", &Level::InventoryObjects,
-/// (short) Set Secrets for Level
+/// (short) Set total secret count for current level.
//@mem secrets
"secrets", sol::property(&Level::GetSecrets, &Level::SetSecrets)
);
@@ -308,7 +308,7 @@ EulerAngles Level::GetHorizonPrevOrientation(int index) const
bool Level::GetLensFlareEnabled() const
{
- return LensFlare.GetEnabledStatus();
+ return LensFlare.GetEnabled();
}
int Level::GetLensFlareSunSpriteID() const
@@ -331,16 +331,6 @@ Color Level::GetLensFlareColor() const
return LensFlare.GetColor();
}
-bool Level::GetStarfieldStarsEnabled() const
-{
- return Starfield.GetStarsEnabledStatus();
-}
-
-bool Level::GetStarfieldMeteorsEnabled() const
-{
- return Starfield.GetMeteorsEnabledStatus();
-}
-
int Level::GetStarfieldStarCount() const
{
return Starfield.GetStarCount();
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h
index d9b46a253..4abfd5c23 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Level/FlowLevel.h
@@ -93,8 +93,6 @@ struct Level : public ScriptInterfaceLevel
Color GetLensFlareColor() const override;
// Starfield getters
- bool GetStarfieldStarsEnabled() const override;
- bool GetStarfieldMeteorsEnabled() const override;
int GetStarfieldStarCount() const override;
int GetStarfieldMeteorCount() const override;
int GetStarfieldMeteorSpawnDensity() const override;
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp
index 027572219..33bf45fa1 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/SkyLayer/SkyLayer.cpp
@@ -7,9 +7,7 @@ namespace TEN::Scripting::Types { class ScriptColor; }
using namespace TEN::Scripting::Types;
-/*** Describes a layer of moving clouds.
-As seen in TR4's City of the Dead.
-
+/*** Describes a layer of moving clouds. To be used with @{Flow.Level.layer1} and @{Flow.Level.layer2} properties.
@tenprimitive Flow.SkyLayer
@pragma nostrip
*/
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp
index 5502b8d59..35c857b47 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.cpp
@@ -6,9 +6,8 @@
using namespace TEN::Effects::Environment;
-/// Represents a starfield in the sky.
-//
-// @tenprimitive Flow.Starfield
+/// Represents a star field in the sky. To be used with @{Flow.Level.starField} property.
+// @tenprimitive Flow.StarField
// @pragma nostrip
namespace TEN::Scripting
@@ -21,38 +20,55 @@ namespace TEN::Scripting
// Register type.
parent.new_usertype(
- "Starfield",
+ "StarField",
ctors(), sol::call_constructor, ctors(),
+ /// (int) Amount of visible stars.
+ // @mem starCount
+ "starCount", sol::property(&Starfield::GetStarCount, &Starfield::SetStarCount),
+
+ /// (int) Amount of visible meteors.
+ // @mem meteorCount
+ "meteorCount", sol::property(&Starfield::GetMeteorCount, &Starfield::SetMeteorCount),
+
+ /// (int) Meteor spawn density.
+ // @mem meteorSpawnDensity
+ "meteorSpawnDensity", sol::property(&Starfield::GetMeteorSpawnDensity, &Starfield::SetMeteorSpawnDensity),
+
+ /// (int) Meteor velocity.
+ // @mem meteorVelocity
+ "meteorVelocity", sol::property(&Starfield::GetMeteorVelocity, &Starfield::SetMeteorVelocity),
+
+ // Compatibility.
"GetStarCount", &Starfield::GetStarCount,
"GetMeteorCount", &Starfield::GetMeteorCount,
"GetMeteorSpawnDensity", &Starfield::GetMeteorSpawnDensity,
"GetMeteorVelocity", &Starfield::GetMeteorVelocity,
- "GetStarsEnabled", &Starfield::GetStarsEnabledStatus,
- "GetMeteorsEnabled", &Starfield::GetMeteorsEnabledStatus,
"SetStarCount", &Starfield::SetStarCount,
"SetMeteorCount", &Starfield::SetMeteorCount,
"SetMeteorSpawnDensity", &Starfield::SetMeteorSpawnDensity,
"SetMeteorVelocity", &Starfield::SetMeteorVelocity);
+
+ parent["StarField"] = parent["Starfield"];
}
/// Create a starfield object with only stars.
- // @function Starfield
+ // @function StarField
// @tparam int starCount Star count.
- // @treturn Starfield A new Starfield object.
+ // @treturn Starfield A new StarField object.
Starfield::Starfield(int starCount)
{
_starCount = starCount;
}
/// Create a starfield object with stars and meteors.
- // @function Starfield
+ // @function StarField
// @tparam int starCount Star count. __Max: 6000__
// @tparam int meteorCount Meteor count. __Max: 100__
// @tparam int meteorSpawnDensity Meteor spawn density.
// @tparam int meteorVel Meteor velocity.
- // @treturn Starfield A new Starfield object.
+ // @treturn StarField A new StarField object.
Starfield::Starfield(int starCount, int meteorCount, int meteorSpawnDensity, float meteorVel)
{
if (starCount < 0 || starCount > STAR_COUNT_MAX)
@@ -67,57 +83,26 @@ namespace TEN::Scripting
_meteorVelocity = meteorVel;
}
- /// Get this starfield's number of stars.
- // @function Starfield:GetStarCount
- // @treturn int Count.
int Starfield::GetStarCount() const
{
return _starCount;
}
- /// Get this starfield's number of meteors.
- // @function Starfield:GetMeteorCount
- // @treturn int Count.
int Starfield::GetMeteorCount() const
{
return _meteorCount;
}
- /// Get this starfield's meteor spawn density.
- // @function Starfield:GetMeteorSpawnDensity
- // @treturn int Spawn density.
int Starfield::GetMeteorSpawnDensity() const
{
return _meteorSpawnDensity;
}
- /// Get this starfield's meteor velocity.
- // @function Starfield:GetMeteorVelocity
- // @treturn float Velocity.
float Starfield::GetMeteorVelocity() const
{
return _meteorVelocity;
}
- /// Get this starfield's stars enabled status.
- // @function Starfield:GetStarsEnabled
- // @treturn bool Stars enabled status. __true: enabled__, __false: disabled__
- bool Starfield::GetStarsEnabledStatus() const
- {
- return (_starCount > 0);
- }
-
- /// Get this starfield's meteors enabled status.
- // @function Starfield:GetMeteorsEnabled
- // @treturn bool Meteors enabled status. __true: enabled__, __false: disabled__
- bool Starfield::GetMeteorsEnabledStatus() const
- {
- return (_meteorCount > 0);
- }
-
- /// Set this starfield's number of stars.
- // @function Starfield:SetStarCount
- // @tparam int count New star count.
void Starfield::SetStarCount(int count)
{
if (count < 0 || count > STAR_COUNT_MAX)
@@ -126,9 +111,6 @@ namespace TEN::Scripting
_starCount = std::clamp(count, 0, STAR_COUNT_MAX);
}
- /// Set this starfield's number of meteors.
- // @function Starfield:SetMeteorCount
- // @tparam int count New meteor count.
void Starfield::SetMeteorCount(int count)
{
if (count < 0 || count > METEOR_COUNT_MAX)
@@ -137,17 +119,11 @@ namespace TEN::Scripting
_meteorCount = std::clamp(count, 0, METEOR_COUNT_MAX);
}
- /// Set this starfield's meteor spawn density.
- // @function Starfield:SetMeteorSpawnDensity
- // @tparam int density New meteor spawn density.
void Starfield::SetMeteorSpawnDensity(int spawnDensity)
{
_meteorSpawnDensity = spawnDensity;
}
- /// Set this starfield's meteor velocity.
- // @function Starfield:SetMeteorVelocity
- // @tparam float velocity New meteor velocity.
void Starfield::SetMeteorVelocity(float vel)
{
_meteorVelocity = vel;
diff --git a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h
index 4f7045b8c..7e918e996 100644
--- a/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h
+++ b/TombEngine/Scripting/Internal/TEN/Flow/Starfield/Starfield.h
@@ -35,8 +35,6 @@ namespace TEN::Scripting
int GetMeteorCount() const;
int GetMeteorSpawnDensity() const;
float GetMeteorVelocity() const;
- bool GetStarsEnabledStatus() const;
- bool GetMeteorsEnabledStatus() const;
// Setters
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp
index 70f2ca4aa..30fd28657 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Moveable/MoveableObject.cpp
@@ -30,7 +30,7 @@ using namespace TEN::Scripting::Types;
// Examples include the player, traps, enemies, doors, and pickups. See also @{Objects.LaraObject} for player-specific features.
//
// @tenclass Objects.Moveable
-// pragma nostrip
+// @pragma nostrip
static auto IndexError = IndexErrorMaker(Moveable, ScriptReserved_Moveable);
static auto NewIndexError = NewIndexErrorMaker(Moveable, ScriptReserved_Moveable);
diff --git a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp
index dfd348284..1dc91890a 100644
--- a/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Objects/Room/RoomObject.cpp
@@ -51,7 +51,7 @@ using namespace TEN::Scripting::Types;
}
/// Get the room's number.
- // @function Room:GetRoomNumber()
+ // @function Room:GetRoomNumber
// @treturn int Room number.
int Room::GetRoomNumber() const
{
@@ -59,7 +59,7 @@ using namespace TEN::Scripting::Types;
}
/// Get the room's unique string identifier.
- // @function Room:GetName()
+ // @function Room:GetName
// @treturn string Room name.
std::string Room::GetName() const
{
@@ -67,7 +67,7 @@ using namespace TEN::Scripting::Types;
}
/// Get the room's ambient light color.
- // @function Room:GetColor()
+ // @function Room:GetColor
// @treturn Color Ambient light color.
ScriptColor Room::GetColor() const
{
@@ -75,7 +75,7 @@ using namespace TEN::Scripting::Types;
}
/// Get the room's reverb type.
- // @function Room:GetReverbType()
+ // @function Room:GetReverbType
// @treturn Objects.RoomReverb Reverb type.
ReverbType Room::GetReverbType() const
{
@@ -83,7 +83,7 @@ using namespace TEN::Scripting::Types;
}
/// Set the room's unique string identifier.
- // @function Room:SetName()
+ // @function Room:SetName
// @tparam string name New name.
void Room::SetName(const std::string& name)
{
@@ -104,7 +104,7 @@ using namespace TEN::Scripting::Types;
}
/// Set the room's reverb type.
- // @function Room:SetReverbType()
+ // @function Room:SetReverbType
// @tparam Objects.RoomReverb Reverb type.
void Room::SetReverbType(ReverbType reverb)
{
@@ -112,7 +112,7 @@ using namespace TEN::Scripting::Types;
}
/// Set the room's specified flag.
- // @function Room:SetFlag()
+ // @function Room:SetFlag
// @tparam Objects.RoomFlagID flagID Room flag ID.
// @tparam bool Boolean to set the flag to.
void Room::SetFlag(RoomEnvFlags flag, bool value)
@@ -128,7 +128,7 @@ using namespace TEN::Scripting::Types;
}
/// Get the room's specified flag value (true or false).
- // @function Room:GetFlag()
+ // @function Room:GetFlag
// @tparam Objects.RoomFlagID flagID Room flag ID.
bool Room::IsTagPresent(const std::string& tag) const
{
@@ -144,7 +144,7 @@ using namespace TEN::Scripting::Types;
}
/// Check if the specified tag is set for the room.
- // @function Room:IsTagPresent()
+ // @function Room:IsTagPresent
// @tparam string tag Text tag to check (case sensitive).
// @treturn bool Boolean of the tag's presence.
bool Room::GetActive() const
@@ -153,7 +153,7 @@ using namespace TEN::Scripting::Types;
}
/// Check if the room is active.
- // @function Room:GetActive()
+ // @function Room:GetActive
// @treturn bool Boolean of the room's active status.
bool Room::GetFlag(RoomEnvFlags flag) const
{
diff --git a/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp b/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp
index 713b7f2d5..73522ae03 100644
--- a/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Sound/SoundHandler.cpp
@@ -14,90 +14,90 @@
namespace TEN::Scripting::Sound
{
- /// Play an audio track
- //@function PlayAudioTrack
- //@tparam string name of track (without file extension) to play
- //@tparam Sound.SoundTrackType type of the audio track to play
+ /// Play an audio track. Supported formats are wav, mp3 and ogg.
+ // @function PlayAudioTrack
+ // @tparam string filename Filename of a track (without file extension) to play.
+ // @tparam Sound.SoundTrackType type Type of the audio track to play.
static void PlayAudioTrack(const std::string& trackName, TypeOrNil mode)
{
auto playMode = ValueOr(mode, SoundTrackType::OneShot);
PlaySoundTrack(trackName, playMode);
}
- /// Set and play an ambient track
+ /// Set and play an ambient track.
// @function SetAmbientTrack
- // @tparam string name of track (without file extension) to play
- // @tparam bool fromStart specifies whether ambient track should play from the start, or crossfade at a random position
+ // @tparam string name Name of track (without file extension) to play.
+ // @tparam bool fromStart Specifies whether ambient track should play from the start, or crossfade at a random position.
static void SetAmbientTrack(const std::string& trackName, TypeOrNil fromTheBeginning)
{
auto pos = ValueOr(fromTheBeginning, false) ? std::optional(0) : std::optional();
PlaySoundTrack(trackName, SoundTrackType::BGM, pos, pos.has_value() ? SOUND_XFADETIME_ONESHOT : SOUND_XFADETIME_BGM);
}
- ///Stop any audio tracks currently playing
- //@function StopAudioTracks
+ /// Stop any audio tracks currently playing.
+ // @function StopAudioTracks
static void StopAudioTracks()
{
StopSoundTracks();
}
- ///Stop audio track that is currently playing
- //@function StopAudioTrack
- //@tparam Sound.SoundTrackType type of the audio track
+ /// Stop audio track that is currently playing.
+ // @function StopAudioTrack
+ // @tparam Sound.SoundTrackType type Type of the audio track.
static void StopAudioTrack(TypeOrNil mode)
{
auto playMode = ValueOr(mode, SoundTrackType::OneShot);
StopSoundTrack(playMode, SOUND_XFADETIME_ONESHOT);
}
- ///Get current loudness level for specified track type
- //@function GetAudioTrackLoudness
- //@tparam Sound.SoundTrackType type of the audio track
- //@treturn float current loudness of a specified audio track
+ /// Get current loudness level for specified track type.
+ // @function GetAudioTrackLoudness
+ // @tparam Sound.SoundTrackType type Type of the audio track.
+ // @treturn float Current loudness of a specified audio track.
static float GetAudioTrackLoudness(TypeOrNil mode)
{
auto playMode = ValueOr(mode, SoundTrackType::OneShot);
return GetSoundTrackLoudness(playMode);
}
- /// Play sound effect
- //@function PlaySound
- //@tparam int sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
- ////@tparam[opt] Vec3 position The 3D position of the sound, i.e. where the sound "comes from". If not given, the sound will not be positional.
+ /// Play sound effect.
+ // @function PlaySound
+ // @tparam int soundID Sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
+ // @tparam[opt] Vec3 position The 3D position of the sound, i.e. where the sound "comes from". If not given, the sound will not be positional.
static void PlaySoundEffect(int soundID, sol::optional pos)
{
SoundEffect(soundID, pos.has_value() ? &Pose(pos->ToVector3i()) : nullptr, SoundEnvironment::Always);
}
- /// Stop sound effect
- //@function StopSound
- //@tparam int sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
+ /// Stop sound effect.
+ // @function StopSound
+ // @tparam int soundID Sound ID to play. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
static void StopSound(int id)
{
StopSoundEffect(id);
}
- /// Check if the sound effect is playing
- //@function IsSoundPlaying
- //@tparam int Sound ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
+ /// Check if the sound effect is playing.
+ // @function IsSoundPlaying
+ // @tparam int soundID Sound ID to check. Corresponds to the value in the sound XML file or Tomb Editor's "Sound Infos" window.
static bool IsSoundPlaying(int effectID)
{
return (Sound_EffectIsPlaying(effectID, nullptr) != SOUND_NO_CHANNEL);
}
- /// Check if the audio track is playing
- //@function IsAudioTrackPlaying
- //@tparam string Track filename to check. Should be without extension and without full directory path.
+ /// Check if the audio track is playing.
+ // @function IsAudioTrackPlaying
+ // @tparam string Track Filename to check. Should be without extension and without full directory path.
static bool IsAudioTrackPlaying(const std::string& trackName)
{
return Sound_TrackIsPlaying(trackName);
}
- ///Get current subtitle string for a voice track currently playing.
- //Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track.
- //Returns nil if no voice track is playing or no subtitle present.
- //@function GetCurrentSubtitle
- //@treturn string current subtitle string
+ /// Get current subtitle string for a voice track currently playing.
+ // Subtitle file must be in .srt format, have same filename as voice track, and be placed in same directory as voice track.
+ // Returns nil if no voice track is playing or no subtitle present.
+ // @function GetCurrentSubtitle
+ // @treturn string Current subtitle string.
static TypeOrNil GetCurrentVoiceTrackSubtitle()
{
auto& result = GetCurrentSubtitle();
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp
index 8b8b5e25f..e5d93f2e5 100644
--- a/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.cpp
@@ -25,6 +25,9 @@ namespace TEN::Scripting
// Meta functions
sol::meta_function::to_string, &Rotation::ToString,
+ sol::meta_function::equal_to, &Rotation::operator ==,
+ sol::meta_function::addition, &Rotation::operator +,
+ sol::meta_function::subtraction, &Rotation::operator -,
// Utilities
ScriptReserved_RotationLerp, &Rotation::Lerp,
@@ -108,4 +111,41 @@ namespace TEN::Scripting
{
return Vector3(x, y, z);
};
+
+ bool Rotation::operator ==(const Rotation& rot) const
+ {
+ return (rot.x == x && rot.y == y && rot.z == z);
+ }
+
+ Rotation Rotation::operator +(const Rotation& rot) const
+ {
+ return Rotation(WrapAngle(x + rot.x), WrapAngle(y + rot.y), WrapAngle(z + rot.z));
+ }
+
+ Rotation Rotation::operator -(const Rotation& rot) const
+ {
+ return Rotation(WrapAngle(x - rot.x), WrapAngle(y - rot.y), WrapAngle(z - rot.z));
+ }
+
+ Rotation& Rotation::operator +=(const Rotation& rot)
+ {
+ x = WrapAngle(x + rot.x);
+ y = WrapAngle(y + rot.y);
+ z = WrapAngle(z + rot.z);
+ return *this;
+ }
+
+ Rotation& Rotation::operator -=(const Rotation& rot)
+ {
+ x = WrapAngle(x - rot.x);
+ y = WrapAngle(y - rot.y);
+ z = WrapAngle(z - rot.z);
+ return *this;
+ }
+
+ float Rotation::WrapAngle(float angle) const
+ {
+ angle -= std::floor(angle / 360.0f) * 360.0f;
+ return ((angle < 0.0f) ? (angle + 360.0f) : angle);
+ }
}
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h
index af835a1c3..084977b4b 100644
--- a/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h
+++ b/TombEngine/Scripting/Internal/TEN/Types/Rotation/Rotation.h
@@ -40,5 +40,16 @@ namespace TEN::Scripting
// Operators
operator Vector3() const;
+
+ bool operator ==(const Rotation& rot) const;
+ Rotation operator +(const Rotation& rot) const;
+ Rotation operator -(const Rotation& rot) const;
+ Rotation& operator +=(const Rotation& rot);
+ Rotation& operator -=(const Rotation& rot);
+
+ private:
+ // Helpers
+
+ float WrapAngle(float angle) const;
};
}
diff --git a/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp b/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp
index cb99bc588..33b8caac9 100644
--- a/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp
+++ b/TombEngine/Scripting/Internal/TEN/Types/Vec2/Vec2.cpp
@@ -84,15 +84,6 @@ Vec2::Vec2(const Vector2& vector)
y = vector.y;
}*/
-/// Metafunction. Use tostring(vector).
-// @tparam Vec2 This Vec2.
-// @treturn string A string showing the X and Y components of the Vec2.
-// @function __tostring
-std::string Vec2::ToString() const
-{
- return "{" + std::to_string(x) + ", " + std::to_string(y) + "}";
-}
-
/// Get a copy of this Vec2 normalized to length 1.
// @function Vec2:Normalize
// @treturn Vec2 Normalized vector.
@@ -105,7 +96,7 @@ Vec2 Vec2::Normalize() const
}
/// Get a copy of this Vec2 translated in the input Vec2 direction by the input distance.
-// @function Translate
+// @function Vec2:Translate
// @tparam Vec2 dir Direction vector. Normalized automatically to length 1.
// @tparam float dist Distance.
// @treturn Vec2 Translated vector.
@@ -115,7 +106,7 @@ Vec2 Vec2::Translate(const Vec2& dir, float dist)
}
/// Get a copy of this Vec2 translated in the direction of the input rotation in degrees by the input distance.
-// @function Translate
+// @function Vec2:Translate
// @tparam Rotation rot Rotation in degrees defining the direction.
// @tparam float dist Distance.
// @treturn Vec2 Translated vector.
@@ -125,7 +116,7 @@ Vec2 Vec2::Translate(float rot, float dist)
}
/// Get a copy of this Vec2 translated by an offset, where the input relative offset Vec2 is rotated according to the input rotation in degrees.
-// @function Translate
+// @function Vec2:Translate
// @tparam float rot Rotation in degrees rotating the input relative offset vector.
// @tparam Vec2 relOffset Relative offset vector before rotation.
// @treturn Vec2 Translated vector.
@@ -203,6 +194,15 @@ float Vec2::Length() const
return ToVector2().Length();
}
+/// Metafunction. Use tostring(vector).
+// @tparam Vec2 This Vec2.
+// @treturn string A string showing the X and Y components of the Vec2.
+// @function __tostring
+std::string Vec2::ToString() const
+{
+ return "{" + std::to_string(x) + ", " + std::to_string(y) + "}";
+}
+
Vec2 Vec2::Add(const Vec2& vector0, const Vec2& vector1)
{
return Vec2(vector0.x + vector1.x, vector0.y + vector1.y);