Skip to content

Commit fed5984

Browse files
committed
sneak in CanEnterOrbit
1 parent f17c34f commit fed5984

File tree

3 files changed

+37
-15
lines changed

3 files changed

+37
-15
lines changed

Source/Entities/ACraft.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ void ACraft::Clear() {
201201
m_DeliveryState = FALL;
202202
m_AltitudeMoveState = HOVER;
203203
m_AltitudeControl = 0;
204+
m_CanEnterOrbit = true;
204205
m_MaxPassengers = -1;
205206

206207
m_DeliveryDelayMultiplier = 1.0;
@@ -251,6 +252,7 @@ int ACraft::Create(const ACraft& reference) {
251252
m_DeliveryState = reference.m_DeliveryState;
252253
m_AltitudeMoveState = reference.m_AltitudeMoveState;
253254
m_AltitudeControl = reference.m_AltitudeControl;
255+
m_CanEnterOrbit = reference.m_CanEnterOrbit;
254256
m_MaxPassengers = reference.m_MaxPassengers;
255257

256258
m_DeliveryDelayMultiplier = reference.m_DeliveryDelayMultiplier;
@@ -285,6 +287,7 @@ int ACraft::ReadProperty(const std::string_view& propName, Reader& reader) {
285287
MatchProperty("DeliveryDelayMultiplier", { reader >> m_DeliveryDelayMultiplier; });
286288
MatchProperty("ExitInterval", { reader >> m_ExitInterval; });
287289
MatchProperty("CanLand", { reader >> m_LandingCraft; });
290+
MatchProperty("CanEnterOrbit", { reader >> m_CanEnterOrbit; });
288291
MatchProperty("MaxPassengers", { reader >> m_MaxPassengers; });
289292
MatchProperty("ScuttleIfFlippedTime", { reader >> m_ScuttleIfFlippedTime; });
290293
MatchProperty("ScuttleOnDeath", { reader >> m_ScuttleOnDeath; });
@@ -314,7 +317,10 @@ int ACraft::Save(Writer& writer) const {
314317

315318
writer.NewProperty("CrashSound");
316319
writer << m_CrashSound;
317-
320+
321+
writer.NewProperty("CanEnterOrbit");
322+
writer << m_CanEnterOrbit;
323+
318324
writer.NewProperty("MaxPassengers");
319325
writer << m_MaxPassengers;
320326
writer.NewProperty("ScuttleIfFlippedTime");
@@ -698,23 +704,26 @@ void ACraft::Update() {
698704
/////////////////////////////////////////
699705
// Check for having gone into orbit
700706

701-
if (m_Pos.m_Y < -m_CharHeight || m_Pos.m_Y > g_SceneMan.GetSceneHeight() + m_CharHeight) {
702-
g_ActivityMan.GetActivity()->HandleCraftEnteringOrbit(this);
703-
// Play fading away thruster sound
704-
// if (m_pMThruster && m_pMThruster->IsEmitting())
705-
// m_pMThruster->(pTargetBitmap, targetPos, mode, onlyPhysical);
706-
m_ToDelete = true;
707-
}
707+
if (m_CanEnterOrbit) {
708+
if (m_Pos.m_Y < -m_CharHeight || m_Pos.m_Y > g_SceneMan.GetSceneHeight() + m_CharHeight) {
709+
g_ActivityMan.GetActivity()->HandleCraftEnteringOrbit(this);
710+
// Play fading away thruster sound
711+
// if (m_pMThruster && m_pMThruster->IsEmitting())
712+
// m_pMThruster->(pTargetBitmap, targetPos, mode, onlyPhysical);
713+
m_ToDelete = true;
714+
}
708715

709-
if (g_ActivityMan.GetActivity()->GetCraftOrbitAtTheEdge()) {
710-
if (g_SceneMan.GetScene() && !g_SceneMan.GetScene()->WrapsX()) {
711-
if (m_Pos.m_X < -GetSpriteWidth() || m_Pos.m_X > g_SceneMan.GetSceneWidth() + GetSpriteWidth()) {
712-
g_ActivityMan.GetActivity()->HandleCraftEnteringOrbit(this);
713-
m_ToDelete = true;
716+
// Horizontal orbiting, if scene doesn't wrap
717+
if (g_ActivityMan.GetActivity()->GetCraftOrbitAtTheEdge()) {
718+
if (g_SceneMan.GetScene() && !g_SceneMan.GetScene()->WrapsX()) {
719+
if (m_Pos.m_X < -GetSpriteWidth() || m_Pos.m_X > g_SceneMan.GetSceneWidth() + GetSpriteWidth()) {
720+
g_ActivityMan.GetActivity()->HandleCraftEnteringOrbit(this);
721+
m_ToDelete = true;
722+
}
714723
}
715-
}
724+
}
716725
}
717-
726+
718727
if (m_Status == DEAD) {
719728
if (m_ScuttleOnDeath || m_AIMode == AIMODE_SCUTTLE) {
720729
GibThis();

Source/Entities/ACraft.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ namespace RTE {
254254
/// get drawn etc.
255255
void DrawHUD(BITMAP* pTargetBitmap, const Vector& targetPos = Vector(), int whichScreen = 0, bool playerControlled = false) override;
256256

257+
/// Gets whether this craft can enter orbit and refund the owning team when out of the map. If false,
258+
/// only default out-of-bounds deletion logic applies.
259+
/// @return Whether this craft can enter orbit or not.
260+
bool GetCanEnterOrbit() const { return m_CanEnterOrbit; }
261+
262+
/// Sets whether this craft can enter orbit and refund the owning team when out of the map. If false,
263+
/// only default out-of-bounds deletion logic applies.
264+
/// @param canEnterOrbit Whether this craft can enter orbit or not.
265+
void SetCanEnterOrbit(bool canEnterOrbit) { m_CanEnterOrbit = canEnterOrbit; }
266+
257267
/// The recomended, not absolute, maximum number of actors that fit in the
258268
/// invetory. Used by the activity AI.
259269
/// @return An integer with the recomended number of actors that fit in the craft.
@@ -354,6 +364,8 @@ namespace RTE {
354364
Timer m_CrashTimer;
355365
// Crash sound
356366
SoundContainer* m_CrashSound;
367+
// Whether this can enter orbit and refund the owning team. If false, will use default out-of-bounds deletion behavior.
368+
bool m_CanEnterOrbit;
357369
// The maximum number of actors that fit in the inventory
358370
int m_MaxPassengers;
359371
int m_ScuttleIfFlippedTime; //!< The time after which the craft will scuttle automatically, if tipped over.

Source/Lua/LuaBindingsEntities.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ LuaBindingRegisterFunctionDefinitionForType(EntityLuaBindings, ACraft) {
117117
.property("HatchOpenSound", &ACraft::GetHatchOpenSound, &LuaAdaptersPropertyOwnershipSafetyFaker::ACraftSetHatchOpenSound)
118118
.property("HatchCloseSound", &ACraft::GetHatchCloseSound, &LuaAdaptersPropertyOwnershipSafetyFaker::ACraftSetHatchCloseSound)
119119
.property("CrashSound", &ACraft::GetCrashSound, &LuaAdaptersPropertyOwnershipSafetyFaker::ACraftSetCrashSound)
120+
.property("CanEnterOrbit", &ACraft::GetCanEnterOrbit, &ACraft::SetCanEnterOrbit)
120121
.property("MaxPassengers", &ACraft::GetMaxPassengers)
121122
.property("DeliveryDelayMultiplier", &ACraft::GetDeliveryDelayMultiplier)
122123
.property("ScuttleOnDeath", &ACraft::GetScuttleOnDeath, &ACraft::SetScuttleOnDeath)

0 commit comments

Comments
 (0)