-
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.
Merge pull request #3 from liquidiert/develop
C# rewrite
- Loading branch information
Showing
33 changed files
with
2,799 additions
and
203 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,36 @@ | ||
{ | ||
// Use IntelliSense to find out which attributes exist for C# debugging | ||
// Use hover for the description of the existing attributes | ||
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": ".NET Core Launch (web)", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build", | ||
// If you have changed target frameworks, make sure to update the program path. | ||
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/pactheman-server.dll", | ||
"args": [], | ||
"cwd": "${workspaceFolder}", | ||
"stopAtEntry": false, | ||
// Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser | ||
"serverReadyAction": { | ||
"action": "openExternally", | ||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)" | ||
}, | ||
"env": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"sourceFileMap": { | ||
"/Views": "${workspaceFolder}/Views" | ||
} | ||
}, | ||
{ | ||
"name": ".NET Core Attach", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}" | ||
} | ||
] | ||
} |
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 |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
"files.associations": { | ||
"*.tcc": "cpp" | ||
}, | ||
"python.pythonPath": "env/bin/python" | ||
|
||
} |
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,42 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"build", | ||
"${workspaceFolder}/pactheman-server.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"publish", | ||
"${workspaceFolder}/pactheman-server.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "watch", | ||
"command": "dotnet", | ||
"type": "process", | ||
"args": [ | ||
"watch", | ||
"run", | ||
"${workspaceFolder}/pactheman-server.csproj", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"problemMatcher": "$msCompile" | ||
} | ||
] | ||
} |
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,4 @@ | ||
struct GhostState { | ||
map[string, Position] targets; | ||
map[string, bool] clearTargets; | ||
} |
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,9 @@ | ||
struct InitState { | ||
map[string, Position] ghostInitPositions; | ||
map[string, Position] ghostInitVelocities; | ||
map[string, uint32] ghostInitDelays; | ||
map[guid, Position] playerInitPositions; | ||
map[guid, uint32] playerInitScores; | ||
map[guid, uint32] playerInitLives; | ||
Position[] scorePointsInitPositions; | ||
} |
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,6 @@ | ||
[opcode(0x1)] | ||
struct PlayerState { | ||
Session session; | ||
map[string, Position] ghostPositions; | ||
map[guid, Position] playerPositions; | ||
} |
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,4 @@ | ||
[opcode(0x4)] | ||
struct Error { | ||
string errorMessage; | ||
} |
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,5 @@ | ||
[opcode(0x3)] | ||
struct Exit { | ||
Session session; | ||
guid clientId; | ||
} |
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,4 @@ | ||
[opcode(0x2)] | ||
message Join { | ||
1 -> Session session; | ||
} |
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,5 @@ | ||
message NetworkMessage { | ||
1 -> uint32 incomingOpCode; | ||
2 -> byte[] playerState; | ||
3 -> byte[] joinMsg; | ||
} |
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,4 @@ | ||
struct Position { | ||
uint32 x; | ||
uint32 y; | ||
} |
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,4 @@ | ||
message Session { | ||
1 -> guid sessionId; | ||
2 -> guid clientId; | ||
} |
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,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace pactheman_server.Controllers | ||
{ | ||
[ApiController] | ||
[Route("weather")] | ||
public class WeatherForecastController : ControllerBase | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
private readonly ILogger<WeatherForecastController> _logger; | ||
|
||
public WeatherForecastController(ILogger<WeatherForecastController> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
[HttpGet] | ||
public IEnumerable<WeatherForecast> Get() | ||
{ | ||
var rng = new Random(); | ||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = DateTime.Now.AddDays(index), | ||
TemperatureC = rng.Next(-20, 55), | ||
Summary = Summaries[rng.Next(Summaries.Length)] | ||
}) | ||
.ToArray(); | ||
} | ||
} | ||
} |
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,40 @@ | ||
using Bebop.Runtime; | ||
using System; | ||
using System.IO; | ||
using System.Net; | ||
using System.Linq; | ||
using PacTheMan.Models; | ||
using System.Net.Sockets; | ||
|
||
namespace pactheman_server { | ||
public class MultiplayerListener : TcpListener { | ||
|
||
MultiplayerListener(IPAddress _ip, Int32 _port = 8083) : base(_ip, _port) {} | ||
|
||
public void Listen() { | ||
Start(); | ||
|
||
Byte[] buffer = new Byte[256]; | ||
|
||
try { | ||
while(true) { | ||
AcceptTcpClientAsync().ContinueWith(client => { | ||
NetworkStream stream = client.Result.GetStream(); | ||
|
||
while(stream.Read(buffer, 0, buffer.Length) != 0) { | ||
var message = NetworkMessage.Decode(buffer); | ||
BebopMirror.HandleRecord(BebopMirror.GetRecordFromOpCode(message.IncomingOpCode ?? 0), message.PlayerState.ToArray(), client.Result); | ||
} | ||
|
||
}); | ||
} | ||
} catch(SocketException ex) { | ||
Console.WriteLine("SocketException: {0}", ex); | ||
} finally { | ||
Stop(); | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
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,40 @@ | ||
using Bebop.Runtime; | ||
using System; | ||
using System.IO; | ||
using System.Net; | ||
using System.Linq; | ||
using PacTheMan.Models; | ||
using System.Net.Sockets; | ||
|
||
namespace pactheman_server { | ||
public class SingleplayerListener : TcpListener { | ||
|
||
SingleplayerListener(IPAddress _ip, Int32 _port = 8082) : base(_ip, _port) {} | ||
|
||
public void Listen() { | ||
Start(); | ||
|
||
Byte[] buffer = new Byte[256]; | ||
|
||
try { | ||
while(true) { | ||
AcceptTcpClientAsync().ContinueWith(client => { | ||
NetworkStream stream = client.Result.GetStream(); | ||
|
||
while(stream.Read(buffer, 0, buffer.Length) != 0) { | ||
var message = NetworkMessage.Decode(buffer); | ||
BebopMirror.HandleRecord(BebopMirror.GetRecordFromOpCode(message.IncomingOpCode ?? 0), message.PlayerState.ToArray(), client.Result); | ||
} | ||
|
||
}); | ||
} | ||
} catch(SocketException ex) { | ||
Console.WriteLine("SocketException: {0}", ex); | ||
} finally { | ||
Stop(); | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
Oops, something went wrong.