Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
AssetsFileEntry.cs
1using Microsoft.Extensions.Logging;
2
3namespace Gondwana.Assets;
4
11public sealed class AssetsFileEntry : IEquatable<AssetsFileEntry>
12{
16 public AssetTypes AssetType { get; set; }
17
21 public string AssetName { get; set; } = string.Empty;
22
28 public override string ToString() => $"{AssetType}_{AssetName.ToLowerInvariant()}";
29
39 internal static AssetsFileEntry? FromString(string entry)
40 {
41 if (string.IsNullOrWhiteSpace(entry))
42 {
43 Engine.Logger.LogWarning("Attempted to parse an empty or null entry string.");
44 return null;
45 }
46
47 var parts = entry.Split('_', 2);
48 if (parts.Length != 2)
49 {
50 Engine.Logger.LogWarning("Invalid entry format: {Entry}. Expected format is 'AssetType_AssetName'.", entry);
51 return null;
52 }
53
54 if (!Enum.TryParse<AssetTypes>(parts[0], ignoreCase: true, out var assetType))
55 {
56 Engine.Logger.LogWarning("Invalid asset type: {AssetType}. Valid types are: {ValidTypes}.",
57 parts[0], string.Join(", ", Enum.GetNames(typeof(AssetTypes))));
58 return null;
59 }
60
61 return new AssetsFileEntry
62 {
63 AssetType = assetType,
64 AssetName = parts[1]
65 };
66 }
67
74 public bool Equals(AssetsFileEntry? other)
75 {
76 if (other is null) return false;
77 return AssetType == other.AssetType &&
78 string.Equals(AssetName, other.AssetName, StringComparison.OrdinalIgnoreCase);
79 }
80
86 public override bool Equals(object? obj) => Equals(obj as AssetsFileEntry);
87
93 public override int GetHashCode() => HashCode.Combine(AssetType, AssetName.ToLowerInvariant());
94}
Represents an entry for an engine asset file, including its type and name.
override string ToString()
Returns a string representation of the asset, combining the asset type and name.
override bool Equals(object? obj)
Determines whether the specified object is equal to the current AssetsFileEntry.
override int GetHashCode()
Returns the hash code for the current AssetsFileEntry.
bool Equals(AssetsFileEntry? other)
Determines whether the current AssetsFileEntry is equal to another AssetsFileEntry
string AssetName
Gets or sets the name of the asset.
AssetTypes AssetType
Gets or sets the type of asset associated with the engine.
Represents the core game engine singleton responsible for managing the main update loop,...
Definition Engine.cs:36
static ILogger< Engine > Logger
Gets the logger instance used by the engine for diagnostic and informational messages.
Definition Engine.cs:59
AssetTypes
Defines the types of assets that can be stored and managed by the engine.
Definition AssetTypes.cs:8