-
Notifications
You must be signed in to change notification settings - Fork 5
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
17 changed files
with
311 additions
and
76 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ export_presets.cfg | |
# Mono-specific ignores | ||
.mono/ | ||
data_*/ | ||
mono_crash* |
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
Binary file not shown.
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,7 @@ | ||
[gd_resource type="DynamicFont" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://assets/Fonts/RedHatText-Regular.ttf" type="DynamicFontData" id=1] | ||
|
||
[resource] | ||
size = 30 | ||
font_data = ExtResource( 1 ) |
Binary file not shown.
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 @@ | ||
[gd_resource type="DynamicFont" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://assets/Fonts/RedHatText-Italic.ttf" type="DynamicFontData" id=1] | ||
|
||
[resource] | ||
font_data = ExtResource( 1 ) |
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 @@ | ||
[gd_resource type="Theme" load_steps=2 format=2] | ||
|
||
[ext_resource path="res://Assets/Fonts/RedHatText-Regular.tres" type="DynamicFont" id=1] | ||
|
||
[resource] | ||
default_font = ExtResource( 1 ) |
This file was deleted.
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,136 @@ | ||
using Godot; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Amqp; | ||
using Amqp.Framing; | ||
using Amqp.Types; | ||
using ProtoBuf; | ||
using redhatgamedev.srt; | ||
|
||
// NOTE: This is an autoloaded singleton class | ||
// We use this class to represent a remote connection to the game servers | ||
public class ServerConnection : Node | ||
{ | ||
CSLogger cslogger; | ||
|
||
// AMQ Broker connection details | ||
String url = "amqp://127.0.0.1:5672"; | ||
bool disableCertValidation = true; | ||
String commandsQueue = "COMMAND.IN"; | ||
String gameEventsTopic = "GAME.EVENT.OUT"; | ||
ConnectionFactory factory; | ||
Connection amqpConnection; | ||
Session amqpSession; | ||
SenderLink commandsSender; | ||
ReceiverLink gameEventsReceiver; | ||
|
||
public override void _Ready() | ||
{ | ||
cslogger = GetNode<CSLogger>("/root/CSLogger"); | ||
cslogger.Info("Space Ring Things (SRT) Game Client v???"); | ||
|
||
var clientConfig = new ConfigFile(); | ||
Godot.Error err = clientConfig.Load("res://Resources/client.cfg"); | ||
if (err == Godot.Error.Ok) | ||
{ | ||
cslogger.Info("Successfully loaded the AMQ config from 'res://Resources/client.cfg'"); | ||
url = (String) clientConfig.GetValue("amqp","server_string", "amqp://127.0.0.1:5672"); | ||
cslogger.Verbose("config file: setting url to " + url); | ||
disableCertValidation = (bool) clientConfig.GetValue("amqp", "disable_cert_validation", true); | ||
cslogger.Verbose("config file: setting cert validation to " + disableCertValidation); | ||
} | ||
|
||
InitializeAMQP(); | ||
} | ||
|
||
public void ConnectToServer() | ||
{ | ||
cslogger.Debug("connecting to server"); | ||
} | ||
|
||
private void OnConnectSuccess() | ||
{ | ||
// TODO | ||
cslogger.Debug("connected to server"); | ||
} | ||
|
||
private void OnConnectFailed() | ||
{ | ||
// TODO | ||
cslogger.Error("failed to connect server - TBD why"); | ||
} | ||
|
||
public void RemovePlayer(String UUID) | ||
{ | ||
// TODO do we need this anymore? Delete and remove references to it | ||
} | ||
|
||
private void GameEventReceived(IReceiverLink receiver, Message message) | ||
{ | ||
cslogger.Verbose("Game Event received!"); | ||
receiver.Accept(message); | ||
byte[] binaryBody = (byte[])message.Body; | ||
MemoryStream st = new MemoryStream(binaryBody, false); | ||
CommandBuffer commandBuffer; | ||
commandBuffer = Serializer.Deserialize<CommandBuffer>(st); | ||
EmitSignal("ProcessGameEvent", commandBuffer); // TODO: create signal handler | ||
} | ||
|
||
public void SendCommand(CommandBuffer CommandBuffer) | ||
{ | ||
cslogger.Verbose("ServerConnection: Sending command"); | ||
MemoryStream st = new MemoryStream(); | ||
Serializer.Serialize<CommandBuffer>(st, CommandBuffer); | ||
byte[] msgBytes = st.ToArray(); | ||
Message msg = new Message(msgBytes); | ||
commandsSender.Send(msg, null, null); // don't care about the ack on our message being received | ||
} | ||
|
||
async void InitializeAMQP() | ||
{ | ||
cslogger.Debug("Initializing AMQP connection"); | ||
Connection.DisableServerCertValidation = disableCertValidation; | ||
try | ||
{ | ||
//Trace.TraceLevel = TraceLevel.Frame; | ||
//Trace.TraceListener = (l, f, a) => Console.WriteLine(DateTime.Now.ToString("[hh:mm:ss.fff]") + " " + string.Format(f, a)); | ||
factory = new ConnectionFactory(); | ||
cslogger.Debug("connecting to " + url); | ||
Address address = new Address(url); | ||
amqpConnection = await factory.CreateAsync(address); | ||
amqpSession = new Session(amqpConnection); | ||
} | ||
catch (Exception es) | ||
{ | ||
cslogger.Error("AMQP connection/session failed for " + url); | ||
// TODO: let player know | ||
return; | ||
} | ||
|
||
cslogger.Debug("Creating AMQ receiver for game events"); | ||
Source eventInSource = new Source | ||
{ | ||
Address = gameEventsTopic, | ||
Capabilities = new Symbol[] { new Symbol("topic") } | ||
}; | ||
gameEventsReceiver = new ReceiverLink(amqpSession, "srt-game-client-receiver", eventInSource, null); | ||
gameEventsReceiver.Start(10, GameEventReceived); | ||
|
||
cslogger.Debug("Creating AMQ sender for player commands"); | ||
Target commandOutTarget = new Target | ||
{ | ||
Address = commandsQueue, | ||
Capabilities = new Symbol[] { new Symbol("queue") } | ||
}; | ||
commandsSender = new SenderLink(amqpSession, "srt-game-client-command-sender", commandOutTarget, null); | ||
|
||
cslogger.Debug("Finished initializing AMQP connection"); | ||
} | ||
|
||
// // Called every frame. 'delta' is the elapsed time since the previous frame. | ||
// public override void _Process(float delta) | ||
// { | ||
// | ||
// } | ||
} |
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 |
---|---|---|
@@ -1,2 +1,43 @@ | ||
# srt-godot-client | ||
Space Rings Thing Game Client (for Red Hat Gaming) | ||
# Space Rings Thing Game Client (for Red Hat Gaming) | ||
This is the player side source code for the SRT game. A multiplayer space game written in Godot. | ||
|
||
### How Can I Play This Game | ||
Everything in currently in development. To play you'll need to roll up your sleves and do a little bit of build/operations work. | ||
|
||
## Architecture | ||
TBD | ||
|
||
## Development Notes | ||
### Networking Code Gen (Protobuf) | ||
After making changes to the protocol buffer definitions, they need to be compiled to C# code. | ||
You will need the `dotnet` command line tool (or equivalent) in order to do this. | ||
|
||
Intstall the Protogen tooling: | ||
``` | ||
dotnet tool install --global protobuf-net.Protogen --version 3.0.101 | ||
``` | ||
|
||
Then, in the `proto` folder: | ||
``` | ||
protogen --csharp_out=. *.proto | ||
``` | ||
|
||
### Building | ||
TBD | ||
|
||
### Running Your Own Server / Testing Locally | ||
You will need to run the game server, the AMQ messaging server, and this game (client-side). | ||
|
||
To run AMQ locally (in a container via podman/docker): | ||
`podman run --name artemis -it -p 8161:8161 -p 5672:5672 --ip 10.88.0.2 -e AMQ_USER=admin -e AMQ_PASSWORD=admin -e AMQ_ALLOW_ANONYMOUS=true quay.io/artemiscloud/activemq-artemis-broker:latest` | ||
|
||
In order to get a specific IP for a local container running Artemis, you will need to do this as the root system user. | ||
Above command puts AMQ serving on IP address 10.88.0.2 with ports 8161 (the management console) and 5672 (the AMQP port). | ||
|
||
Find/follow instructions for the [game server here](https://github.com/redhat-gamedev/srt-godot-server). | ||
|
||
This repo is the player game client. | ||
|
||
If you are debugging the Godot server and Godot client on the same machine you will want to do one of the following | ||
Option 1. Goto `Editor->Editor Settings...` and search for the `Remote Port` setting (it's under `Network->Debug'). Change the port so that the client and server use different ports. | ||
Option 2. In the Server project, goto `Project->Export...` and export to your platform, then run the exported server. |
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,3 @@ | ||
[amqp] | ||
server_string="amqp://127.0.0.1:5672" | ||
disable_cert_validation=true |
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
[gd_scene format=2] | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://Scenes/MainScenes/MapOverlay.tscn" type="PackedScene" id=1] | ||
|
||
[node name="Map" type="Node"] | ||
|
||
[node name="MapOverlay" parent="." instance=ExtResource( 1 )] |
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 @@ | ||
[gd_scene load_steps=2 format=2] | ||
|
||
[ext_resource path="res://Assets/UIElements/MainTheme.tres" type="Theme" id=1] | ||
|
||
[node name="MapOverlay" type="Control"] | ||
anchor_right = 1.0 | ||
anchor_bottom = 1.0 | ||
margin_right = 896.0 | ||
margin_bottom = 480.0 | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="SectorLabelTextureRect" type="TextureRect" parent="."] | ||
margin_left = 850.0 | ||
margin_top = 20.0 | ||
margin_right = 1050.0 | ||
margin_bottom = 70.0 | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} | ||
|
||
[node name="SectorLabel" type="Label" parent="."] | ||
use_parent_material = true | ||
margin_left = 850.0 | ||
margin_top = 25.0 | ||
margin_right = 1050.0 | ||
margin_bottom = 65.0 | ||
theme = ExtResource( 1 ) | ||
text = "SECTOR - X" | ||
align = 1 | ||
valign = 1 | ||
__meta__ = { | ||
"_edit_use_anchors_": false | ||
} |
Oops, something went wrong.