From 04b87fe82a231e2e731aac6da152f73cb41b8dcf Mon Sep 17 00:00:00 2001 From: Ne1gb Date: Thu, 19 Feb 2026 18:36:01 +0500 Subject: [PATCH] Fixes. --- Monofoxe/Monofoxe.Tiled/MapBuilder.cs | 10 +++++----- .../{Misc => Components}/ActorComponent.cs | 0 .../{Misc => Components}/PositionComponent.cs | 0 .../{Misc => Components}/TileCollisionComponent.cs | 0 Samples/Monofoxe.Samples/{Misc => Entities}/Ball.cs | 0 Samples/Monofoxe.Samples/{Misc => Entities}/Bot.cs | 0 Samples/Monofoxe.Samples/{Misc => Entities}/Player.cs | 0 Samples/Monofoxe.Samples/Game1.cs | 2 ++ Samples/Monofoxe.Samples/GameController.cs | 1 + Samples/Monofoxe.Samples/SceneSwitcher.cs | 2 +- .../Monofoxe.Samples/{Misc => }/Tiled/BotFactory.cs | 0 .../Monofoxe.Samples/{Misc => }/Tiled/PlayerFactory.cs | 0 .../{Misc => }/Tiled/SolidMapBuilder.cs | 6 +++--- .../{Misc => }/Tiled/SolidTilesetTile.cs | 0 14 files changed, 12 insertions(+), 9 deletions(-) rename Samples/Monofoxe.Samples/{Misc => Components}/ActorComponent.cs (100%) rename Samples/Monofoxe.Samples/{Misc => Components}/PositionComponent.cs (100%) rename Samples/Monofoxe.Samples/{Misc => Components}/TileCollisionComponent.cs (100%) rename Samples/Monofoxe.Samples/{Misc => Entities}/Ball.cs (100%) rename Samples/Monofoxe.Samples/{Misc => Entities}/Bot.cs (100%) rename Samples/Monofoxe.Samples/{Misc => Entities}/Player.cs (100%) rename Samples/Monofoxe.Samples/{Misc => }/Tiled/BotFactory.cs (100%) rename Samples/Monofoxe.Samples/{Misc => }/Tiled/PlayerFactory.cs (100%) rename Samples/Monofoxe.Samples/{Misc => }/Tiled/SolidMapBuilder.cs (95%) rename Samples/Monofoxe.Samples/{Misc => }/Tiled/SolidTilesetTile.cs (100%) diff --git a/Monofoxe/Monofoxe.Tiled/MapBuilder.cs b/Monofoxe/Monofoxe.Tiled/MapBuilder.cs index 965080a..90afa6d 100644 --- a/Monofoxe/Monofoxe.Tiled/MapBuilder.cs +++ b/Monofoxe/Monofoxe.Tiled/MapBuilder.cs @@ -161,11 +161,6 @@ protected Tileset GetTilesetFromTileIndex(int index) /// protected virtual List BuildLayers(List tilesets) { - if (TiledMap.GetLayers().Length != 0) - { - CreateTileLookupTable(tilesets); - } - var layers = new List(); foreach (var mapLayer in TiledMap.Layers) @@ -175,6 +170,11 @@ protected virtual List BuildLayers(List tilesets) if (mapLayer is TiledMapTileLayer) { + if (_tilesetLookupMap == null) + { + CreateTileLookupTable(tilesets); + } + BuildTileLayer((TiledMapTileLayer)mapLayer, layer); } if (mapLayer is TiledMapObjectLayer) diff --git a/Samples/Monofoxe.Samples/Misc/ActorComponent.cs b/Samples/Monofoxe.Samples/Components/ActorComponent.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/ActorComponent.cs rename to Samples/Monofoxe.Samples/Components/ActorComponent.cs diff --git a/Samples/Monofoxe.Samples/Misc/PositionComponent.cs b/Samples/Monofoxe.Samples/Components/PositionComponent.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/PositionComponent.cs rename to Samples/Monofoxe.Samples/Components/PositionComponent.cs diff --git a/Samples/Monofoxe.Samples/Misc/TileCollisionComponent.cs b/Samples/Monofoxe.Samples/Components/TileCollisionComponent.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/TileCollisionComponent.cs rename to Samples/Monofoxe.Samples/Components/TileCollisionComponent.cs diff --git a/Samples/Monofoxe.Samples/Misc/Ball.cs b/Samples/Monofoxe.Samples/Entities/Ball.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/Ball.cs rename to Samples/Monofoxe.Samples/Entities/Ball.cs diff --git a/Samples/Monofoxe.Samples/Misc/Bot.cs b/Samples/Monofoxe.Samples/Entities/Bot.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/Bot.cs rename to Samples/Monofoxe.Samples/Entities/Bot.cs diff --git a/Samples/Monofoxe.Samples/Misc/Player.cs b/Samples/Monofoxe.Samples/Entities/Player.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/Player.cs rename to Samples/Monofoxe.Samples/Entities/Player.cs diff --git a/Samples/Monofoxe.Samples/Game1.cs b/Samples/Monofoxe.Samples/Game1.cs index f8e9432..115712a 100644 --- a/Samples/Monofoxe.Samples/Game1.cs +++ b/Samples/Monofoxe.Samples/Game1.cs @@ -44,6 +44,8 @@ protected override void Initialize() GraphicsMgr.VertexBatch.DepthStencilState = depth; + InactiveSleepTime = new System.TimeSpan(0); // Makes game not drop frames when window is inactive. + new GameController(); } diff --git a/Samples/Monofoxe.Samples/GameController.cs b/Samples/Monofoxe.Samples/GameController.cs index fab4371..2297c12 100644 --- a/Samples/Monofoxe.Samples/GameController.cs +++ b/Samples/Monofoxe.Samples/GameController.cs @@ -21,6 +21,7 @@ public class GameController : Entity private Stopwatch _stopwatch = new Stopwatch(); + // It is recommended to reuse random objects. public static RandomExt Random = new RandomExt(); public GameController() : base(SceneMgr.GetScene("default")["default"]) diff --git a/Samples/Monofoxe.Samples/SceneSwitcher.cs b/Samples/Monofoxe.Samples/SceneSwitcher.cs index 14e9bde..f8cef08 100644 --- a/Samples/Monofoxe.Samples/SceneSwitcher.cs +++ b/Samples/Monofoxe.Samples/SceneSwitcher.cs @@ -22,7 +22,7 @@ public class SceneSwitcher : Entity new SceneFactory(typeof(ECDemo), ECDemo.Description), new SceneFactory(typeof(SceneSystemDemo), SceneSystemDemo.Description), new SceneFactory(typeof(UtilsDemo)), - new SceneFactory(typeof(TiledDemo)), + new SceneFactory(typeof(TiledDemo), TiledDemo.Description), new SceneFactory(typeof(VertexBatchDemo)), new SceneFactory(typeof(CoroutinesDemo)), new SceneFactory(typeof(CollisionsDemo)), diff --git a/Samples/Monofoxe.Samples/Misc/Tiled/BotFactory.cs b/Samples/Monofoxe.Samples/Tiled/BotFactory.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/Tiled/BotFactory.cs rename to Samples/Monofoxe.Samples/Tiled/BotFactory.cs diff --git a/Samples/Monofoxe.Samples/Misc/Tiled/PlayerFactory.cs b/Samples/Monofoxe.Samples/Tiled/PlayerFactory.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/Tiled/PlayerFactory.cs rename to Samples/Monofoxe.Samples/Tiled/PlayerFactory.cs diff --git a/Samples/Monofoxe.Samples/Misc/Tiled/SolidMapBuilder.cs b/Samples/Monofoxe.Samples/Tiled/SolidMapBuilder.cs similarity index 95% rename from Samples/Monofoxe.Samples/Misc/Tiled/SolidMapBuilder.cs rename to Samples/Monofoxe.Samples/Tiled/SolidMapBuilder.cs index 167f09b..ad3bff6 100644 --- a/Samples/Monofoxe.Samples/Misc/Tiled/SolidMapBuilder.cs +++ b/Samples/Monofoxe.Samples/Tiled/SolidMapBuilder.cs @@ -14,7 +14,7 @@ namespace Monofoxe.Samples.Misc.Tiled public class SolidMapBuilder : MapBuilder { - public SolidMapBuilder(TiledMap tiledMap) : base(tiledMap) {} + public SolidMapBuilder(TiledMap tiledMap) : base(tiledMap) { } public override void Build() { @@ -63,11 +63,11 @@ ITilesetTile[] ConvertTiles(TiledMapTileset tiledTileset, Tileset tileset) // Getting solid property from the tile. var solid = false; - try + + if (tiledTile.Properties.ContainsKey("Solid")) { solid = bool.Parse(tiledTile.Properties["Solid"]); } - catch (Exception) {} // Getting solid property from the tile. SolidTilesetTile tilesetTile; diff --git a/Samples/Monofoxe.Samples/Misc/Tiled/SolidTilesetTile.cs b/Samples/Monofoxe.Samples/Tiled/SolidTilesetTile.cs similarity index 100% rename from Samples/Monofoxe.Samples/Misc/Tiled/SolidTilesetTile.cs rename to Samples/Monofoxe.Samples/Tiled/SolidTilesetTile.cs