commit 9907aebe36247d9fa175466c60c5416a325173ad Author: Syntriax Date: Tue Aug 5 14:42:26 2025 +0300 initial commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..104b544 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,484 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[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 +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# 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 +*.tlog +*.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 +coverage*.xml +coverage*.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 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# 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/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# 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/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e57f18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,484 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[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 +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# 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 +*.tlog +*.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 +coverage*.xml +coverage*.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 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# 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/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# 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/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..e8a1898 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Engine"] + path = Engine + url = git@git.syntriax.com:Syntriax/Syntriax.Engine.git diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0780f96 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,80 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Launch (Client) 1", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build-client", + "program": "${workspaceFolder}/Platforms/Desktop/bin/Debug/net9.0/MyUniverse.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "internalConsole", + "justMyCode": false, + "logging": { + "moduleLoad": false, + "programOutput": true + } + }, + { + "name": ".NET Launch (Client) 2", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build-client", + "program": "${workspaceFolder}/Platforms/Desktop/bin/Debug/net9.0/MyUniverse.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "internalConsole", + "justMyCode": false, + "logging": { + "moduleLoad": false, + "programOutput": true + } + }, + { + "name": ".NET Launch (Server)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build-server", + "program": "${workspaceFolder}/Platforms/Server/bin/Debug/net9.0/Server.dll", + "args": [], + "env": { + "PORT": "8888", + }, + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "internalConsole", + "justMyCode": false, + "logging": { + "moduleLoad": false, + "programOutput": true + } + } + ], + "compounds": [ + { + "name": ".NET Launch Client & Server", + "configurations": [ + ".NET Launch (Server)", + ".NET Launch (Client) 1" + ] + }, + { + "name": ".NET Launch 2 Client & 1 Server", + "configurations": [ + ".NET Launch (Server)", + ".NET Launch (Client) 1", + ".NET Launch (Client) 2" + ] + }, + { + "name": ".NET Launch 2 Clients", + "configurations": [ + ".NET Launch (Client) 1", + ".NET Launch (Client) 2" + ] + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..85504ad --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build-client", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Platforms/Desktop" + ], + "problemMatcher": "$msCompile", + "group": { + "kind": "build", + "isDefault": true + } + }, + { + "label": "build-server", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/Platforms/Server" + ], + "problemMatcher": "$msCompile", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fc413f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build + +WORKDIR /App +COPY . ./ + +RUN dotnet restore +RUN dotnet publish Platforms/Server -c Release -r linux-musl-x64 --self-contained true -o out + +FROM alpine:latest + +WORKDIR /App +COPY --from=build /App/out . + +RUN apk add --no-cache icu-libs + +ENTRYPOINT ["./Server"] diff --git a/Engine b/Engine new file mode 160000 index 0000000..d78c42a --- /dev/null +++ b/Engine @@ -0,0 +1 @@ +Subproject commit d78c42a65327a5889636da1a8d99e57513e20098 diff --git a/Platforms/Desktop/.config/dotnet-tools.json b/Platforms/Desktop/.config/dotnet-tools.json new file mode 100644 index 0000000..84ff03d --- /dev/null +++ b/Platforms/Desktop/.config/dotnet-tools.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-mgcb": { + "version": "3.8.2.1105", + "commands": [ + "mgcb" + ] + }, + "dotnet-mgcb-editor": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor" + ] + }, + "dotnet-mgcb-editor-linux": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor-linux" + ] + }, + "dotnet-mgcb-editor-windows": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor-windows" + ] + }, + "dotnet-mgcb-editor-mac": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor-mac" + ] + } + } +} \ No newline at end of file diff --git a/Platforms/Desktop/Desktop.csproj b/Platforms/Desktop/Desktop.csproj new file mode 100644 index 0000000..ba4e7ad --- /dev/null +++ b/Platforms/Desktop/Desktop.csproj @@ -0,0 +1,91 @@ + + + WinExe + net9.0 + Major + false + false + enable + MyUniverse.Platforms.Desktop + MyUniverse + + + app.manifest + Icon.ico + + + + + + + + Icon.ico + + + Icon.bmp + + + + + + + + + + + + + + + Content/Content.mgcb + + + + + + + + + + + + + False + + ../Libraries + ./Libraries + + + SDL2.dll + + hostfxr;hostpolicy;*.deps.json;*.runtimeconfig*.json + + False + + False + + False + + auto + + False + + + + True + + + + + + + + + + + Info + + + + + diff --git a/Platforms/Desktop/Icon.bmp b/Platforms/Desktop/Icon.bmp new file mode 100644 index 0000000..f57550d Binary files /dev/null and b/Platforms/Desktop/Icon.bmp differ diff --git a/Platforms/Desktop/Icon.ico b/Platforms/Desktop/Icon.ico new file mode 100644 index 0000000..f24dc66 Binary files /dev/null and b/Platforms/Desktop/Icon.ico differ diff --git a/Platforms/Desktop/Icon.png b/Platforms/Desktop/Icon.png new file mode 100644 index 0000000..d883939 Binary files /dev/null and b/Platforms/Desktop/Icon.png differ diff --git a/Platforms/Desktop/Program.cs b/Platforms/Desktop/Program.cs new file mode 100644 index 0000000..235827f --- /dev/null +++ b/Platforms/Desktop/Program.cs @@ -0,0 +1,44 @@ +using System; + +using Microsoft.Xna.Framework.Graphics; + +using Engine.Core; +using Engine.Core.Debug; +using Engine.Core.Serialization; +using Engine.Integration.MonoGame; +using Engine.Serializers.Yaml; +using Engine.Systems.Network; + +Universe universe = new(); + +ISerializer serializer = new YamlSerializer(); + +ILogger logger = new FileLogger($"Logs/{DateTime.UtcNow:yyyy-MM-dd_HH-mm-ss-ffffff}.log"); + +#if DEBUG +logger = new LoggerWrapper(logger, new ConsoleLogger()); +#endif + +universe.InstantiateUniverseObject().SetUniverseObject("Logger") + .BehaviourController.AddBehaviour().Logger = ILogger.Shared = logger; + +universe.InstantiateUniverseObject().SetUniverseObject("Desktop Inputs") + .BehaviourController.AddBehaviour(); + +universe.InstantiateUniverseObject().SetUniverseObject("Visual Managers") + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour(); + +/* For Networking +LiteNetLibClient client = universe.InstantiateUniverseObject().SetUniverseObject("Client").BehaviourController.AddBehaviour(); +client.BehaviourController.AddBehaviour(); +universe.OnPreUpdate.AddOneTimeListener((_, _) => client.Connect("localhost", 8888)); +*/ + +MyUniverse.Shared.UniverseSource.ApplyUniverse(universe); + +using MonoGameWindow monoGameWindow = new(universe); + +monoGameWindow.Graphics.GraphicsProfile = GraphicsProfile.HiDef; + +monoGameWindow.Run(); diff --git a/Platforms/Desktop/app.manifest b/Platforms/Desktop/app.manifest new file mode 100644 index 0000000..ede0b4e --- /dev/null +++ b/Platforms/Desktop/app.manifest @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true/pm + permonitorv2,permonitor + + + + diff --git a/Platforms/Desktop/icon.svg b/Platforms/Desktop/icon.svg new file mode 100644 index 0000000..4d69e30 --- /dev/null +++ b/Platforms/Desktop/icon.svg @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Platforms/Server/Endpoints.cs b/Platforms/Server/Endpoints.cs new file mode 100644 index 0000000..d51a259 --- /dev/null +++ b/Platforms/Server/Endpoints.cs @@ -0,0 +1,40 @@ + +using System; +using System.Threading.Tasks; + +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; + +using Engine.Core; +using Engine.Systems.Network; + +namespace Server; + +public class Endpoints : Behaviour, IFirstFrameUpdate +{ + private INetworkCommunicatorServer? server = null!; + + public Endpoints() + { + Task.Run(() => + { + WebApplicationBuilder builder = WebApplication.CreateBuilder(); + + builder.Services.AddHealthChecks(); + + WebApplication app = builder.Build(); + + app.MapHealthChecks("/health"); + + app.MapGet("/stats", GetStats); + + app.Run($"http://0.0.0.0:{Environment.GetEnvironmentVariable("PORT") ?? "8888"}"); + }); + } + + private IResult GetStats() => Results.Json(new { Count = server?.Connections.Count ?? 0 }); + + public void FirstActiveFrame() => server = Universe.FindRequiredBehaviour(); + protected override void OnExitedUniverse(IUniverse universe) => server = null; +} diff --git a/Platforms/Server/Program.cs b/Platforms/Server/Program.cs new file mode 100644 index 0000000..78119b8 --- /dev/null +++ b/Platforms/Server/Program.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading; + +using Engine.Core; +using Engine.Core.Debug; +using Engine.Systems.Network; + +Universe universe = new(); + +FileLogger fileLogger = new($"Logs/{DateTime.UtcNow:yyyy-MM-dd_HH-mm-ss-ffffff}.log"); +universe.InstantiateUniverseObject().SetUniverseObject("Logger").BehaviourController + .AddBehaviour().Logger = ILogger.Shared = new LoggerWrapper(fileLogger, new ConsoleLogger()); + +LiteNetLibServer server = universe.InstantiateUniverseObject().SetUniverseObject("Server").BehaviourController.AddBehaviour(); +server.BehaviourController.AddBehaviour(); +universe.OnPreUpdate.AddOneTimeListener((_, _) => server.Start(8888, 2)); + +MyUniverse.Shared.UniverseSource.ApplyUniverse(universe); + +DateTime lastRun = DateTime.UtcNow; +TimeSpan interval = new(0, 0, 0, 0, 16); +TimeSpan timeSinceStart = new(0); + +universe.Initialize(); + +while (true) +{ + if (lastRun + interval <= DateTime.UtcNow) + { + lastRun += interval; + timeSinceStart += interval; + universe.Update(new(timeSinceStart, interval)); + } + Thread.Sleep(1); +} diff --git a/Platforms/Server/Server.csproj b/Platforms/Server/Server.csproj new file mode 100644 index 0000000..f527caa --- /dev/null +++ b/Platforms/Server/Server.csproj @@ -0,0 +1,23 @@ + + + + Exe + net9.0 + disable + enable + MyUniverse.Platforms.Server + MyUniverse + + + + + + + + + + + + + + diff --git a/Project.sln b/Project.sln new file mode 100644 index 0000000..ed57f5b --- /dev/null +++ b/Project.sln @@ -0,0 +1,177 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine", "Engine", "{F7F62670-237A-4C93-A30E-CE661C6FC401}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Core", "Engine\Engine.Core\Engine.Core.csproj", "{990CA10C-1EBB-4395-A43A-456B7029D8C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Physics2D", "Engine\Engine.Physics2D\Engine.Physics2D.csproj", "{0D97F83C-B043-48B1-B155-7354C4E84FC0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine", "Engine\Engine\Engine.csproj", "{2F6B1E26-1217-4EFD-874C-05ADEE4C7969}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Platforms", "Platforms", "{FECFFD54-338F-4060-9161-1E5770D1DC33}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Desktop", "Platforms\Desktop\Desktop.csproj", "{2B627F66-5A61-4F69-B479-62EEAB603D01}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Systems", "Engine\Engine.Systems\Engine.Systems.csproj", "{8863A1BA-2E83-419F-BACB-D4A4156EC71C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Engine.Integration", "Engine.Integration", "{9059393F-4073-9273-0EEC-2B1BA61B620B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Integration.MonoGame", "Engine\Engine.Integration\Engine.Integration.MonoGame\Engine.Integration.MonoGame.csproj", "{7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Platforms\Server\Server.csproj", "{A15263DB-DF65-4A07-8CA1-33A2919501A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Integration.Yaml", "Engine\Engine.Integration\Engine.Integration.Yaml\Engine.Integration.Yaml.csproj", "{79F870AB-249E-4CA0-9DF0-F265514581DF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine.Integration.LiteNetLib", "Engine\Engine.Integration\Engine.Integration.LiteNetLib\Engine.Integration.LiteNetLib.csproj", "{7AA22306-772F-45F4-8F30-97EBD1FC124D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|x64.ActiveCfg = Debug|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|x64.Build.0 = Debug|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Debug|x86.Build.0 = Debug|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|Any CPU.Build.0 = Release|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|x64.ActiveCfg = Release|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|x64.Build.0 = Release|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|x86.ActiveCfg = Release|Any CPU + {990CA10C-1EBB-4395-A43A-456B7029D8C9}.Release|x86.Build.0 = Release|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|x64.ActiveCfg = Debug|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|x64.Build.0 = Debug|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|x86.ActiveCfg = Debug|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Debug|x86.Build.0 = Debug|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|Any CPU.Build.0 = Release|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|x64.ActiveCfg = Release|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|x64.Build.0 = Release|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|x86.ActiveCfg = Release|Any CPU + {0D97F83C-B043-48B1-B155-7354C4E84FC0}.Release|x86.Build.0 = Release|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|x64.ActiveCfg = Debug|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|x64.Build.0 = Debug|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|x86.ActiveCfg = Debug|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Debug|x86.Build.0 = Debug|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|Any CPU.Build.0 = Release|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|x64.ActiveCfg = Release|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|x64.Build.0 = Release|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|x86.ActiveCfg = Release|Any CPU + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969}.Release|x86.Build.0 = Release|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|x64.ActiveCfg = Debug|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|x64.Build.0 = Debug|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|x86.ActiveCfg = Debug|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Debug|x86.Build.0 = Debug|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|Any CPU.Build.0 = Release|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|x64.ActiveCfg = Release|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|x64.Build.0 = Release|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|x86.ActiveCfg = Release|Any CPU + {590E392E-9FB3-49FA-B4DA-6C8F7126FFE5}.Release|x86.Build.0 = Release|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|x64.ActiveCfg = Debug|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|x64.Build.0 = Debug|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|x86.ActiveCfg = Debug|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Debug|x86.Build.0 = Debug|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|Any CPU.Build.0 = Release|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|x64.ActiveCfg = Release|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|x64.Build.0 = Release|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|x86.ActiveCfg = Release|Any CPU + {2B627F66-5A61-4F69-B479-62EEAB603D01}.Release|x86.Build.0 = Release|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|x64.ActiveCfg = Debug|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|x64.Build.0 = Debug|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|x86.ActiveCfg = Debug|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Debug|x86.Build.0 = Debug|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|Any CPU.Build.0 = Release|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|x64.ActiveCfg = Release|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|x64.Build.0 = Release|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|x86.ActiveCfg = Release|Any CPU + {8863A1BA-2E83-419F-BACB-D4A4156EC71C}.Release|x86.Build.0 = Release|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Debug|x64.ActiveCfg = Debug|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Debug|x64.Build.0 = Debug|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Debug|x86.ActiveCfg = Debug|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Debug|x86.Build.0 = Debug|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Release|Any CPU.Build.0 = Release|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Release|x64.ActiveCfg = Release|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Release|x64.Build.0 = Release|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Release|x86.ActiveCfg = Release|Any CPU + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283}.Release|x86.Build.0 = Release|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Debug|x64.ActiveCfg = Debug|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Debug|x64.Build.0 = Debug|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Debug|x86.ActiveCfg = Debug|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Debug|x86.Build.0 = Debug|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|Any CPU.Build.0 = Release|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x64.ActiveCfg = Release|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x64.Build.0 = Release|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x86.ActiveCfg = Release|Any CPU + {A15263DB-DF65-4A07-8CA1-33A2919501A0}.Release|x86.Build.0 = Release|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x64.ActiveCfg = Debug|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x64.Build.0 = Debug|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x86.ActiveCfg = Debug|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Debug|x86.Build.0 = Debug|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|Any CPU.Build.0 = Release|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x64.ActiveCfg = Release|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x64.Build.0 = Release|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x86.ActiveCfg = Release|Any CPU + {79F870AB-249E-4CA0-9DF0-F265514581DF}.Release|x86.Build.0 = Release|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Debug|x64.ActiveCfg = Debug|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Debug|x64.Build.0 = Debug|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Debug|x86.ActiveCfg = Debug|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Debug|x86.Build.0 = Debug|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Release|Any CPU.Build.0 = Release|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Release|x64.ActiveCfg = Release|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Release|x64.Build.0 = Release|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Release|x86.ActiveCfg = Release|Any CPU + {7AA22306-772F-45F4-8F30-97EBD1FC124D}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {990CA10C-1EBB-4395-A43A-456B7029D8C9} = {F7F62670-237A-4C93-A30E-CE661C6FC401} + {0D97F83C-B043-48B1-B155-7354C4E84FC0} = {F7F62670-237A-4C93-A30E-CE661C6FC401} + {2F6B1E26-1217-4EFD-874C-05ADEE4C7969} = {F7F62670-237A-4C93-A30E-CE661C6FC401} + {2B627F66-5A61-4F69-B479-62EEAB603D01} = {FECFFD54-338F-4060-9161-1E5770D1DC33} + {8863A1BA-2E83-419F-BACB-D4A4156EC71C} = {F7F62670-237A-4C93-A30E-CE661C6FC401} + {9059393F-4073-9273-0EEC-2B1BA61B620B} = {F7F62670-237A-4C93-A30E-CE661C6FC401} + {7CC31BC4-38EE-40F4-BBBA-9FC2F4CF6283} = {9059393F-4073-9273-0EEC-2B1BA61B620B} + {A15263DB-DF65-4A07-8CA1-33A2919501A0} = {FECFFD54-338F-4060-9161-1E5770D1DC33} + {7AA22306-772F-45F4-8F30-97EBD1FC124D} = {9059393F-4073-9273-0EEC-2B1BA61B620B} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5a0fa8 --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# C# Game Project Template + +> A modular template for building games using my C# game engine. + +--- + +## 📦 About + +This repository provides a starting point for developing games using my C# game engine. It is structured to separate shared game logic from platform-specific implementations. I mostly use it for my own projects. + +## ✨ Uses + +- [MonoGame](https://monogame.net/) Integration, for it's windowing, audio, packaging etc. You might wanna get familiar with it since most stuff is not abstracted yet like audio. +- [Yaml](https://yaml.org/) Integration, for serialization +- [LiteNetLib](https://revenantx.github.io/LiteNetLib/index.html) Integration, for networking + +## 🧱 Project Structure + +```txt +📁 Root/ +├── Shared/ # Game logic +├── Platforms/ +│ ├── Desktop/ # Desktop build target (Windows/Linux/macOS) +│ └── Server/ # Headless/server build target +├── Engine/ # Game engine (as a Git submodule) +└── README.md +``` + +## 🚀 Getting Started + +### 1. Clone the Repository (with Submodules) + +```bash +git clone --recursive https://git.syntriax.com/Syntriax/Engine-Template.git +``` + +⚠️ Make sure to use --recursive to initialize all submodules correctly. + +If you've already cloned the repo without submodules, run: + +```bash +git submodule update --init --recursive +``` + +### 2. Write Your Logic Code + +All your universe logic should go inside the Shared/ folder. + +This structure allows your code to be reused across multiple platform targets like Desktop and Server. + +```txt +📁 Root/ +└── Shared/ + └── Behaviours/ + ├── Movement.cs + └── Jump.cs +``` + +### 3. Add Your Objects to Your Universe + +`Shared/UniverseSource.cs` is set up to be your main shared entry point where you can define your universe objects and their behaviours, add systems you see fit etc. + +```txt +📁 Root/ +└── Shared/ + └── UniverseSource.cs +``` + +### 4. Set Project Names (Optional) + +Update every mention of the `MyUniverse` to reflect your project's name and namespace. For example: + +```csharp +MyUniverse.Shared.UniverseSource.ApplyUniverse(universe); +``` + +## 🛠 Requirements + +- .NET SDK (version 9) diff --git a/Shared/.config/dotnet-tools.json b/Shared/.config/dotnet-tools.json new file mode 100644 index 0000000..84ff03d --- /dev/null +++ b/Shared/.config/dotnet-tools.json @@ -0,0 +1,36 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-mgcb": { + "version": "3.8.2.1105", + "commands": [ + "mgcb" + ] + }, + "dotnet-mgcb-editor": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor" + ] + }, + "dotnet-mgcb-editor-linux": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor-linux" + ] + }, + "dotnet-mgcb-editor-windows": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor-windows" + ] + }, + "dotnet-mgcb-editor-mac": { + "version": "3.8.2.1105", + "commands": [ + "mgcb-editor-mac" + ] + } + } +} \ No newline at end of file diff --git a/Shared/Behaviours/ExampleBehaviour.cs b/Shared/Behaviours/ExampleBehaviour.cs new file mode 100644 index 0000000..6450303 --- /dev/null +++ b/Shared/Behaviours/ExampleBehaviour.cs @@ -0,0 +1,27 @@ + +using Engine.Core; +using Engine.Core.Debug; + +namespace MyUniverse.Shared.Behaviours; + +public class ExampleBehaviour : Behaviour, IFirstFrameUpdate, ILastFrameUpdate, IUpdate +{ + private ILogger logger = null!; + + public void FirstActiveFrame() + { + logger = Universe.FindRequiredBehaviour(); + + logger.Log(this, "First Frame"); + } + + public void LastActiveFrame() + { + logger.Log(this, $"Last Frame"); + } + + public void Update() + { + logger.Log(this, "Frame"); + } +} diff --git a/Shared/Behaviours/IRotator.cs b/Shared/Behaviours/IRotator.cs new file mode 100644 index 0000000..5614dcd --- /dev/null +++ b/Shared/Behaviours/IRotator.cs @@ -0,0 +1,5 @@ +using Engine.Core; + +namespace MyUniverse.Shared.Behaviours; + +public interface IRotator : IBehaviour; diff --git a/Shared/Behaviours/LinearRotator.cs b/Shared/Behaviours/LinearRotator.cs new file mode 100644 index 0000000..30570f4 --- /dev/null +++ b/Shared/Behaviours/LinearRotator.cs @@ -0,0 +1,13 @@ +using Engine.Core; + +namespace MyUniverse.Shared.Behaviours; + +public class LinearRotator : Behaviour2D, IRotator, IUpdate +{ + private float speed = 20f; + + public void Update() + { + Transform.Rotation += Universe.Time.DeltaTime * speed; + } +} diff --git a/Shared/Behaviours/RotatorToggler.cs b/Shared/Behaviours/RotatorToggler.cs new file mode 100644 index 0000000..8084b81 --- /dev/null +++ b/Shared/Behaviours/RotatorToggler.cs @@ -0,0 +1,31 @@ +using System; +using Engine.Core; +using Engine.Integration.MonoGame; +using Engine.Systems.Input; +using Microsoft.Xna.Framework.Input; + +namespace MyUniverse.Shared.Behaviours; + +public class RotatorToggler : Behaviour2D, IFirstFrameUpdate, ILastFrameUpdate +{ + private IRotator rotator = null!; + private KeyboardInputs inputs = null!; + + public void FirstActiveFrame() + { + rotator = BehaviourController.GetRequiredBehaviour(); + inputs = Universe.FindRequiredBehaviour(); + + inputs.RegisterOnPress(Keys.Space, ToggleRotator); + } + + private void ToggleRotator(IButtonInputs sender, IButtonInputs.ButtonCallbackArguments args) + { + rotator.StateEnable.Enabled = !rotator.StateEnable.Enabled; + } + + public void LastActiveFrame() + { + inputs.UnregisterOnPress(Keys.Space, ToggleRotator); + } +} diff --git a/Shared/Behaviours/TweenRotator.cs b/Shared/Behaviours/TweenRotator.cs new file mode 100644 index 0000000..db49f1c --- /dev/null +++ b/Shared/Behaviours/TweenRotator.cs @@ -0,0 +1,35 @@ +using Engine.Core; +using Engine.Systems.Tween; + +namespace MyUniverse.Shared.Behaviours; + +public class TweenRotator : Behaviour2D, IRotator, IFirstFrameUpdate, ILastFrameUpdate +{ + private float duration = 5f; + private float angle = 180; + private IEasing easeMethod = EaseInOutQuad.Instance; + private ITweenManager tweenManager = null!; + private ITween tween = null!; + + public void FirstActiveFrame() + { + tweenManager = Universe.FindRequiredBehaviour(); + + TweenRotation(); + } + + private void TweenRotation() + { + if (Transform.Rotation >= 360f) + Transform.Rotation -= 360f; + + tween = Transform.TweenRotation(tweenManager, duration, Transform.Rotation + angle) + .Ease(easeMethod) + .OnComplete(TweenRotation); + } + + public void LastActiveFrame() + { + tweenManager.CancelTween(tween); + } +} diff --git a/Shared/Content/Content.mgcb b/Shared/Content/Content.mgcb new file mode 100644 index 0000000..ddc4c36 --- /dev/null +++ b/Shared/Content/Content.mgcb @@ -0,0 +1,15 @@ + +#----------------------------- Global Properties ----------------------------# + +/outputDir:bin/$(Platform) +/intermediateDir:obj/$(Platform) +/platform:DesktopGL +/config: +/profile:Reach +/compress:False + +#-------------------------------- References --------------------------------# + + +#---------------------------------- Content ---------------------------------# + diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj new file mode 100644 index 0000000..eeeea19 --- /dev/null +++ b/Shared/Shared.csproj @@ -0,0 +1,17 @@ + + + net9.0 + enable + MyUniverse.Shared + MyUniverse.Shared + + + + All + + + + + + + diff --git a/Shared/UniverseSource.cs b/Shared/UniverseSource.cs new file mode 100644 index 0000000..54149b8 --- /dev/null +++ b/Shared/UniverseSource.cs @@ -0,0 +1,61 @@ + +using MyUniverse.Shared.Behaviours; + +using Engine.Core; +using Engine.Integration.MonoGame; +using Engine.Systems.Tween; + +namespace MyUniverse.Shared; + +public static class UniverseSource +{ + public static void ApplyCore(IUniverse universe) + { + universe.InstantiateUniverseObject().SetUniverseObject("Core Managers") + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour(); + + MonoGameCamera2D camera = universe.InstantiateUniverseObject().SetUniverseObject("Camera") + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour(); + + camera.Zoom = 20f; + } + + public static void ApplyUniverse(IUniverse universe) + { + ApplyCore(universe); + + IUniverseObject exampleObject = universe.InstantiateUniverseObject().SetUniverseObject("Example Object"); + ExampleBehaviour exampleBehaviour = exampleObject.BehaviourController.AddBehaviour(); + + universe.InstantiateUniverseObject() + .SetUniverseObject("Rotating Triangle") + .BehaviourController.AddBehaviour().SetTransform(position: new(10f, 6f), scale: Vector2D.One * 5) + .BehaviourController.AddBehaviour(Shape2D.Triangle, new ColorRGB(0, 128, 128)) + .BehaviourController.AddBehaviour(); + + universe.InstantiateUniverseObject() + .SetUniverseObject("Rotating Pentagon") + .BehaviourController.AddBehaviour().SetTransform(position: new(10f, -6f), scale: Vector2D.One * 5) + .BehaviourController.AddBehaviour(Shape2D.Pentagon, new ColorRGB(128, 0, 128)) + .BehaviourController.AddBehaviour(); + universe.InstantiateUniverseObject() + .SetUniverseObject("Rotating Triangle") + .BehaviourController.AddBehaviour().SetTransform(position: new(-10f, 6f), scale: Vector2D.One * 5) + .BehaviourController.AddBehaviour(Shape2D.Triangle, new ColorRGB(0, 128, 128)) + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour(); + + universe.InstantiateUniverseObject() + .SetUniverseObject("Rotating Pentagon") + .BehaviourController.AddBehaviour().SetTransform(position: new(-10f, -6f), scale: Vector2D.One * 5) + .BehaviourController.AddBehaviour(Shape2D.Pentagon, new ColorRGB(128, 0, 128)) + .BehaviourController.AddBehaviour() + .BehaviourController.AddBehaviour(); + } +}