-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
169 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Scellecs.Morpeh; | ||
|
||
namespace Systems; | ||
|
||
public class TriggerSystem : IFixedSystem | ||
{ | ||
public World World { get; set; } | ||
private bool _entered; | ||
|
||
public TriggerSystem(World world, CollisionSystem collisionSystem) | ||
{ | ||
World = world; | ||
collisionSystem.RaiseTriggerEntered += HandleTriggerEntered; | ||
} | ||
|
||
private void HandleTriggerEntered(Entity sender, CustomEventArgs e) | ||
{ | ||
if (_entered) return; | ||
|
||
Console.WriteLine(e.Message); | ||
_entered = true; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
|
||
public void OnAwake() | ||
{ | ||
} | ||
|
||
public void OnUpdate(float deltaTime) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Myra.Graphics2D.UI; | ||
using Scellecs.Morpeh; | ||
using Systems; | ||
|
||
namespace UI; | ||
|
||
// TODO: Use factory method, reactive update, divide on more UI components, use DI | ||
public class TestElement | ||
{ | ||
public readonly Panel Panel; | ||
public readonly Label Counter; | ||
public readonly Label Version; | ||
private int _counter; | ||
|
||
public TestElement(Panel panel, Label counter, Label version, CollisionSystem collisionSystem) | ||
{ | ||
Panel = panel; | ||
Counter = counter; | ||
Version = version; | ||
|
||
collisionSystem.RaiseTriggerEntered += HandleTriggerEntered; | ||
} | ||
|
||
public TestElement AddCounterLabel() | ||
{ | ||
Panel.Widgets.Add(Counter); | ||
|
||
UpdateCounterText(); | ||
|
||
return this; | ||
} | ||
|
||
public TestElement AddVersionLabel() | ||
{ | ||
Panel.Widgets.Add(Version); | ||
return this; | ||
} | ||
|
||
private void HandleTriggerEntered(Entity sender, CustomEventArgs args) | ||
{ | ||
++_counter; | ||
UpdateCounterText(); | ||
} | ||
|
||
private void UpdateCounterText() => Counter.Text = $"Counter: {_counter}"; | ||
// public TestElement() | ||
// { | ||
// Panel.Widgets.Add(Label); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Myra" Version="1.5.3"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Systems\Systems.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |