diff --git a/isometric-park-fna/Components/NameComponent.cs b/isometric-park-fna/Components/NameComponent.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Components/NameComponent.cs @@ -0,0 +1,10 @@ + +using Encompass; + +namespace isometricparkfna.Components +{ + public struct NameComponent : IComponent + { + public string DisplayName; + } +} \ No newline at end of file diff --git a/isometric-park-fna/Engines/Spawners/ContractSpawner.cs b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Engines/Spawners/ContractSpawner.cs @@ -0,0 +1,22 @@ + +using Encompass; + +using isometricparkfna.Messages; +using isometricparkfna.Components; + +namespace isometricparkfna.Spawners { + + [Receives(typeof(SpawnContractMessage))] + class ContractSpawner : Spawner + { + + protected override void Spawn(in SpawnContractMessage message) + { + var contract = CreateEntity(); + // AddComponent + AddComponent(contract, new AreaComponent{squares = message.squares}); + AddComponent(contract, new NameComponent{DisplayName = message.name}); + + } + } +} \ No newline at end of file diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -20,6 +20,8 @@ using isometricparkfna.Engines; using isometricparkfna.Components; using isometricparkfna.Renderers; +using isometricparkfna.Messages; +using isometricparkfna.Spawners; using ImGuiNET.SampleProgram.XNA; using ImGuiNET; @@ -196,13 +198,16 @@ WorldBuilder.AddEngine(new CameraBridgeEngine(this.camera)); this.imGuiWindowBridgeEngine = new ImGuiWindowBridgeEngine(); WorldBuilder.AddEngine(this.imGuiWindowBridgeEngine); + WorldBuilder.AddEngine(new ContractSpawner()); // var budgetWindow = WorldBuilder.CreateEntity(); // WorldBuilder.SetComponent(budgetWindow, new VisibilityComponent{visible = true}); // WorldBuilder.SetComponent(budgetWindow, new BudgetComponent()); var area = WorldBuilder.CreateEntity(); - WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}}); + // WorldBuilder.SetComponent(area, new AreaComponent{squares = new[] {new Vector2(4,4), new Vector2(5,4)}}); + WorldBuilder.SendMessage(new SpawnContractMessage{squares = new[] {new Vector2(4,4), new Vector2(5,4)}, + name = "Contract"}); World = WorldBuilder.Build(); diff --git a/isometric-park-fna/Messages/SpawnContractMessage.cs b/isometric-park-fna/Messages/SpawnContractMessage.cs new file mode 100644 --- /dev/null +++ b/isometric-park-fna/Messages/SpawnContractMessage.cs @@ -0,0 +1,11 @@ + +using Microsoft.Xna.Framework; +using Encompass; + +namespace isometricparkfna.Messages { + public struct SpawnContractMessage : IMessage + { + public Vector2[] squares; + public string name; + } +} \ No newline at end of file diff --git a/isometric-park-fna/isometric-park-fna.csproj b/isometric-park-fna/isometric-park-fna.csproj --- a/isometric-park-fna/isometric-park-fna.csproj +++ b/isometric-park-fna/isometric-park-fna.csproj @@ -46,6 +46,7 @@ +