mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-14 02:09:08 +01:00
29 lines
795 B
C#
29 lines
795 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.JSInterop;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Input;
|
|
using MLEM.Misc;
|
|
|
|
namespace Demos.Web.Pages;
|
|
|
|
public partial class Index {
|
|
|
|
private Game game;
|
|
|
|
protected override async Task OnAfterRenderAsync(bool firstRender) {
|
|
await base.OnAfterRenderAsync(firstRender);
|
|
if (firstRender)
|
|
await this.JsRuntime.InvokeAsync<object>("initRenderJS", DotNetObjectReference.Create(this));
|
|
}
|
|
|
|
[JSInvokable]
|
|
public void TickDotNet() {
|
|
if (this.game == null) {
|
|
MlemPlatform.Current = new MlemPlatform.DesktopGl<TextInputEventArgs>((w, c) => w.TextInput += c);
|
|
this.game = new GameImpl();
|
|
this.game.Run();
|
|
}
|
|
this.game.Tick();
|
|
}
|
|
|
|
}
|