Skip to content

Commit

Permalink
Make IsGameVersion virtual, specify MP4/TM2020 for ghosts
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Dec 31, 2024
1 parent a7a5592 commit b52bf90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Src/GBX.NET/Engines/Game/CGameCtnGhost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,17 @@ public override string ToString()
return $"{Time.ToTmString()} ({(Speed.HasValue ? $"{Speed}km/h, " : "")}{StuntsScore} pts.)";
}
}

public override bool IsGameVersion(GameVersion version, bool strict = false)
{
if (!base.IsGameVersion(version, strict))
{
return false;
}
if (version == (GameVersion.MP4 | GameVersion.TM2020))
{
return Chunks.Any(static x => x is Chunk03092029);
}
return true;
}
}
16 changes: 15 additions & 1 deletion Src/GBX.NET/Engines/MwFoundations/CMwNod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ protected void DeepCloneChunks(IClass dest)
}
}

/// <summary>
/// The version of the game where this node should be accepted without a game crash.
/// </summary>
public GameVersion GameVersion
{
get
Expand All @@ -685,13 +688,24 @@ public GameVersion GameVersion
}
}

public bool IsGameVersion(GameVersion version, bool strict = false)
/// <summary>
/// Checks if the node is accepted in the given game version without a game crash.
/// </summary>
/// <param name="version">Game version flags.</param>
/// <param name="strict">If enabled, checks for the exact flag match (if accepted in MP4 and TM2020, only <c>MP4 | TM2020</c> will return true).</param>
/// <returns>True if matches, false if not.</returns>
public virtual bool IsGameVersion(GameVersion version, bool strict = false)
{
return strict
? GameVersion == version
: (GameVersion & version) == version;
}

/// <summary>
/// Checks if the node could be accepted in the given game version.
/// </summary>
/// <param name="version">Game version flags.</param>
/// <returns>True if matches, false if not.</returns>
public bool CanBeGameVersion(GameVersion version)
{
return (GameVersion & version) != 0;
Expand Down

0 comments on commit b52bf90

Please sign in to comment.