From 87d961584533396573c4e1e03bcb0ac84dbb8d66 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Mon, 7 Mar 2022 10:58:05 -0800 Subject: [PATCH] initial commit --- .gitignore | 347 ++++++++++++++++++++++++++++++++++++ .gitmodules | 6 + .vscode/launch.json | 16 ++ .vscode/tasks.json | 118 ++++++++++++ Content/README.md | 1 + CopyMoonlibs.targets | 43 +++++ MoonWorksECSTest.csproj | 33 ++++ MoonWorksECSTest.sln | 49 +++++ README.md | 40 +++++ lib/MoonTools.ECS | 1 + lib/MoonWorks | 1 + src/InputMessage.cs | 9 + src/InputSystem.cs | 28 +++ src/MoonWorksECSTestGame.cs | 51 ++++++ src/PositionComponent.cs | 9 + src/PositionSystem.cs | 24 +++ src/Program.cs | 34 ++++ 17 files changed, 810 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 Content/README.md create mode 100644 CopyMoonlibs.targets create mode 100644 MoonWorksECSTest.csproj create mode 100644 MoonWorksECSTest.sln create mode 100644 README.md create mode 160000 lib/MoonTools.ECS create mode 160000 lib/MoonWorks create mode 100644 src/InputMessage.cs create mode 100644 src/InputSystem.cs create mode 100644 src/MoonWorksECSTestGame.cs create mode 100644 src/PositionComponent.cs create mode 100644 src/PositionSystem.cs create mode 100644 src/Program.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b57d8dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,347 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +moonlibs/ + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*[.json, .xml, .info] + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e00fe46 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "lib/MoonWorks"] + path = lib/MoonWorks + url = https://gitea.moonside.games/MoonsideGames/MoonWorks.git +[submodule "lib/MoonTools.ECS"] + path = lib/MoonTools.ECS + url = https://gitea.moonside.games/MoonsideGames/MoonTools.ECS.git diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..36eb4b2 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to .NET 6 Debugger", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "Build: .NET 6 Debug", + "program": "${workspaceFolder}/bin/x64/Debug/net6.0/MoonWorksECSTest.dll", + "args": [], + "cwd": "${workspaceFolder}/bin/x64/Debug/net6.0", + "console": "integratedTerminal", + "internalConsoleOptions": "neverOpen" + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..d042884 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,118 @@ +{ + "version": "2.0.0", + "options": { + "cwd": "${workspaceRoot}" + }, + "windows": { + "options": { + "shell": { + "executable": "cmd.exe", + "args": [ + "/d", + "/c" + ] + } + } + }, + "presentation": { + "reveal": "always", + "focus": true, + "panel": "shared" + }, + "tasks": [ + { + "label": "Build & Run: .NET 6 Debug", + "type": "shell", + "dependsOrder": "sequence", + "dependsOn": [ + "Build: .NET 6 Debug", + "Run: .NET 6 Debug" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build: .NET 6 Debug", + "command": "dotnet", + "args": [ + "build", + "./MoonWorksECSTest.csproj", + "-p:SolutionDir=${workspaceFolder}/", + "-p:Platform=x64" + ], + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Run: .NET 6 Debug", + "command": "dotnet", + "args": [ + "./MoonWorksECSTest.dll" + ], + "options": { + "cwd": "${workspaceFolder}/bin/x64/Debug/net6.0" + }, + "type": "process", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build: .NET 6 Release", + "command": "dotnet", + "args": [ + "build", + "./MoonWorksECSTest.csproj", + "--configuration", + "Release", + "-p:SolutionDir=${workspaceFolder}/", + "-p:Platform=x64" + ], + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Run: .NET 5 Release", + "command": "dotnet", + "args": [ + "./MoonWorksECSTest.dll" + ], + "options": { + "cwd": "${workspaceFolder}/bin/x64/Release/net6.0" + }, + "type": "process", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + }, + { + "label": "Build & Run: .NET 6 Release", + "dependsOrder": "sequence", + "dependsOn": [ + "Build: .NET 6 Release", + "Run: .NET 6 Release" + ], + "type": "shell", + "group": { + "kind": "build", + "isDefault": true + }, + "problemMatcher": [] + } + ] +} diff --git a/Content/README.md b/Content/README.md new file mode 100644 index 0000000..d05e474 --- /dev/null +++ b/Content/README.md @@ -0,0 +1 @@ +Insert your content files here (sprites, sound, etc) diff --git a/CopyMoonlibs.targets b/CopyMoonlibs.targets new file mode 100644 index 0000000..50cd87a --- /dev/null +++ b/CopyMoonlibs.targets @@ -0,0 +1,43 @@ + + + + + + + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + + %(RecursiveDir)%(Filename)%(Extension) + PreserveNewest + + + + diff --git a/MoonWorksECSTest.csproj b/MoonWorksECSTest.csproj new file mode 100644 index 0000000..88d5515 --- /dev/null +++ b/MoonWorksECSTest.csproj @@ -0,0 +1,33 @@ + + + Exe + net6.0 + MoonWorksECSTest + false + false + 8.0 + MoonWorksECSTest.Program + MoonWorksECSTest + MoonWorksECSTest + true + true + + + + + + Always + + + + + $(DefaultItemExcludes);lib\**\* + + + + + + + + + diff --git a/MoonWorksECSTest.sln b/MoonWorksECSTest.sln new file mode 100644 index 0000000..d8d712c --- /dev/null +++ b/MoonWorksECSTest.sln @@ -0,0 +1,49 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30717.126 +MinimumVisualStudioVersion = 15.0.26124.0 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoonWorksECSTest.Core", "MoonWorksECSTest\MoonWorksECSTest.Core.csproj", "{4589302C-174A-4173-9654-CAA6CA1B5220}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonWorksECSTest", "MoonWorksECSTest.csproj", "{E39DD871-69CE-4A7E-B37B-801CEF0EB529}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lib", "lib", "{CD3F5B84-554B-4F6C-B5A7-D17115489A69}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonWorks", "lib\MoonWorks\MoonWorks.csproj", "{0E99B8AC-F867-4F4E-8596-2918CAE9B6C1}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoonTools.ECS", "lib\MoonTools.ECS\MoonTools.ECS.csproj", "{5046E711-F861-4836-B06A-22325AA557A8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.ActiveCfg = Debug|x64 + {4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.Build.0 = Debug|x64 + {4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.ActiveCfg = Release|x64 + {4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.Build.0 = Release|x64 + {E39DD871-69CE-4A7E-B37B-801CEF0EB529}.Debug|x64.ActiveCfg = Debug|Any CPU + {E39DD871-69CE-4A7E-B37B-801CEF0EB529}.Debug|x64.Build.0 = Debug|Any CPU + {E39DD871-69CE-4A7E-B37B-801CEF0EB529}.Release|x64.ActiveCfg = Release|Any CPU + {E39DD871-69CE-4A7E-B37B-801CEF0EB529}.Release|x64.Build.0 = Release|Any CPU + {0E99B8AC-F867-4F4E-8596-2918CAE9B6C1}.Debug|x64.ActiveCfg = Debug|x64 + {0E99B8AC-F867-4F4E-8596-2918CAE9B6C1}.Debug|x64.Build.0 = Debug|x64 + {0E99B8AC-F867-4F4E-8596-2918CAE9B6C1}.Release|x64.ActiveCfg = Release|x64 + {0E99B8AC-F867-4F4E-8596-2918CAE9B6C1}.Release|x64.Build.0 = Release|x64 + {5046E711-F861-4836-B06A-22325AA557A8}.Debug|x64.ActiveCfg = Debug|Any CPU + {5046E711-F861-4836-B06A-22325AA557A8}.Debug|x64.Build.0 = Debug|Any CPU + {5046E711-F861-4836-B06A-22325AA557A8}.Release|x64.ActiveCfg = Release|Any CPU + {5046E711-F861-4836-B06A-22325AA557A8}.Release|x64.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {70247DA8-9C19-4FC5-B4BC-68E1262B9F4B} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0E99B8AC-F867-4F4E-8596-2918CAE9B6C1} = {CD3F5B84-554B-4F6C-B5A7-D17115489A69} + {5046E711-F861-4836-B06A-22325AA557A8} = {CD3F5B84-554B-4F6C-B5A7-D17115489A69} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..c60fc21 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# MoonWorksTemplate + +Template and build tasks for developing a cross-platform multi-target .NET 6 MoonWorks project in VSCode. + +The generated solution file will also work in regular Visual Studio. + +NOTE: OSX is broken right now because I need to set up MoltenVK. + +## Features + +- Project boilerplate code +- VSCode build tasks +- VSCode debugger integration + +## Requirements + +- [Git](https://git-scm.com/) or [Git for Windows](https://gitforwindows.org/) on Windows +- [.NET 6 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) +- [Build Tools for Visual Studio 2019](https://visualstudio.microsoft.com/downloads/) on Windows +- [Visual Studio Code](https://code.visualstudio.com/) +- [VSCode C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) + +## Installation + +- Make sure you have Git Bash from Git for Windows if you are on Windows +- Download this repository +- Run `install.sh` +- Move the newly created project directory wherever you want +- On Windows, add `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin` to your system environment PATH variable after installing Build Tools for VS 2019 + +## Usage + +- Open the project directory in VSCode +- Press Ctrl-Shift-B to open the build tasks menu +- Tasks use .NET 6.0 to build and run +- Press F5 to build and debug + +## Acknowledgments + +Thanks to Andrew Russell and Caleb Cornett's FNA templates for a starting point for this template. diff --git a/lib/MoonTools.ECS b/lib/MoonTools.ECS new file mode 160000 index 0000000..229a065 --- /dev/null +++ b/lib/MoonTools.ECS @@ -0,0 +1 @@ +Subproject commit 229a0651bdaac5918b4550866cdca9122bf0d78b diff --git a/lib/MoonWorks b/lib/MoonWorks new file mode 160000 index 0000000..8f9aaf6 --- /dev/null +++ b/lib/MoonWorks @@ -0,0 +1 @@ +Subproject commit 8f9aaf6d612b97d77ff5013e758846894777089a diff --git a/src/InputMessage.cs b/src/InputMessage.cs new file mode 100644 index 0000000..ef7df5b --- /dev/null +++ b/src/InputMessage.cs @@ -0,0 +1,9 @@ +namespace MoonWorksECSTest +{ + public struct InputMessage + { + public int PlayerIndex; + + public MoonWorks.Input.ButtonState DpadUp; + } +} diff --git a/src/InputSystem.cs b/src/InputSystem.cs new file mode 100644 index 0000000..d792fd9 --- /dev/null +++ b/src/InputSystem.cs @@ -0,0 +1,28 @@ +using System; +using MoonTools.ECS; + +namespace MoonWorksECSTest +{ + public class InputSystem : MoonTools.ECS.System + { + MoonWorks.Input.Inputs Inputs; + + public InputSystem(MoonWorks.Input.Inputs inputs) + { + Inputs = inputs; + } + + public override void Update(TimeSpan delta) + { + var dpadUp = Inputs.Keyboard.ButtonState(MoonWorks.Input.Keycode.Up); + + var inputMessage = new InputMessage + { + PlayerIndex = 0, + DpadUp = dpadUp + }; + + Send(inputMessage); + } + } +} diff --git a/src/MoonWorksECSTestGame.cs b/src/MoonWorksECSTestGame.cs new file mode 100644 index 0000000..1c1ba50 --- /dev/null +++ b/src/MoonWorksECSTestGame.cs @@ -0,0 +1,51 @@ +using MoonWorks.Graphics; +using MoonWorks; +using MoonTools.ECS; + +namespace MoonWorksECSTest +{ + class MoonWorksECSTestGame : Game + { + World world; + + public MoonWorksECSTestGame( + WindowCreateInfo windowCreateInfo, + PresentMode presentMode, + bool debugMode + ) : base(windowCreateInfo, presentMode, 60, debugMode) + { + var worldBuilder = new WorldBuilder(); + worldBuilder.AddSystem(new InputSystem(Inputs)); + worldBuilder.AddSystem(new PositionSystem()); + + var entity = worldBuilder.CreateEntity(); + worldBuilder.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(200, 200) }); + + world = worldBuilder.Build(); + } + + protected override void Update(System.TimeSpan dt) + { + world.Update(dt); + } + + protected override void Draw(System.TimeSpan dt, double alpha) + { + var commandBuffer = GraphicsDevice.AcquireCommandBuffer(); + var swapchainTexture = commandBuffer.AcquireSwapchainTexture(Window); + + commandBuffer.BeginRenderPass( + new ColorAttachmentInfo(swapchainTexture, Color.CornflowerBlue) + ); + + commandBuffer.EndRenderPass(); + + GraphicsDevice.Submit(commandBuffer); + } + + protected override void OnDestroy() + { + + } + } +} diff --git a/src/PositionComponent.cs b/src/PositionComponent.cs new file mode 100644 index 0000000..eaf0aef --- /dev/null +++ b/src/PositionComponent.cs @@ -0,0 +1,9 @@ +using MoonWorks.Math; + +namespace MoonWorksECSTest +{ + public struct PositionComponent + { + public Vector2 Position; + } +} diff --git a/src/PositionSystem.cs b/src/PositionSystem.cs new file mode 100644 index 0000000..ff79268 --- /dev/null +++ b/src/PositionSystem.cs @@ -0,0 +1,24 @@ +using System; +using MoonTools.ECS; + +namespace MoonWorksECSTest +{ + public class PositionSystem : MoonTools.ECS.System + { + public override void Update(TimeSpan delta) + { + foreach (var entity in ReadEntities()) + { + foreach (var inputMessage in ReadMessages()) + { + if (inputMessage.DpadUp.IsPressed) + { + var positionComponent = Get(entity); + Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(positionComponent.Position.X + 10, positionComponent.Position.Y)}); + Console.WriteLine("Position: " + Get(entity).Position); + } + } + } + } + } +} diff --git a/src/Program.cs b/src/Program.cs new file mode 100644 index 0000000..517bf2e --- /dev/null +++ b/src/Program.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Runtime.InteropServices; +using MoonWorks; + +namespace MoonWorksECSTest +{ + class Program + { + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + [return: MarshalAs(UnmanagedType.Bool)] + static extern bool SetDllDirectory(string lpPathName); + + + static void Main(string[] args) + { + WindowCreateInfo windowCreateInfo = new WindowCreateInfo + { + WindowWidth = 1280, + WindowHeight = 720, + WindowTitle = "MoonWorksECSTest", + ScreenMode = ScreenMode.Windowed + }; + + MoonWorksECSTestGame game = new MoonWorksECSTestGame( + windowCreateInfo, + MoonWorks.Graphics.PresentMode.FIFORelaxed, + true + ); + + game.Run(); + } + } +}