Patrick Square
Patrick Square
Explore posts from servers
CC#
Created by Patrick Square on 7/8/2023 in #help
❔ need some advice
private async Task<Result> ReceiveStartCommands()
{
var commands = new List<IInputCommand>();

foreach (var trainer in Scene.Trainers)
{
var command = await InputProvider.GetInput(trainer.Id);
commands.Add(command);
}

// ReSharper disable once ConvertIfStatementToReturnStatement
if (!commands.All(command => command is BattleStartCommand))
{
return new InvalidOperationError("Failed to start battle because Start Commands were not received from all trainers.");
}

return Result.FromSuccess();
}
private async Task<Result> ReceiveStartCommands()
{
var commands = new List<IInputCommand>();

foreach (var trainer in Scene.Trainers)
{
var command = await InputProvider.GetInput(trainer.Id);
commands.Add(command);
}

// ReSharper disable once ConvertIfStatementToReturnStatement
if (!commands.All(command => command is BattleStartCommand))
{
return new InvalidOperationError("Failed to start battle because Start Commands were not received from all trainers.");
}

return Result.FromSuccess();
}
I have this code that receives the start commands from every player using an input provider. However, this means that the second player must wait for the first to send their command. What is the best practice so can I make it so these commands can be received from both players without having to wait
6 replies
CC#
Created by Patrick Square on 7/2/2023 in #help
❔ ASP.NET Core Custom Font Not Applied
8 replies
CC#
Created by Patrick Square on 6/21/2023 in #help
❔ Can't find .NET 6 runtime when running EF Core migration
When I do dotnet ef migrations add Initial
Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80
131040)
Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80
131040)
6 replies
CC#
Created by Patrick Square on 6/10/2023 in #help
❔ Can't run MAUI app on Android Emulator
9 replies
CC#
Created by Patrick Square on 4/26/2023 in #help
❔ OpenGL / Silk.NET - uniform not found on shader
// Here we specify the version of our shader.
#version 330 core

// These lines specify the location and type of our attributes,
// the attributes here are prefixed with a "v" as they are our inputs to the vertex shader
// this isn't strictly necessary though, but a good habit.
layout (location = 0) in vec3 vPos;
layout (location = 1) in vec4 vColor;

// This is how we declare a uniform, they can be used in all our shaders and share the same name.
// This is prefixed with a u as it's our uniform.
uniform float uBlue;
uniform float uOffset;

// This is our output variable, notice that this is prefixed with an f as it's the input of our fragment shader.
out vec4 fColor;

void main()
{
// gl_Position, is a built-in variable on all vertex shaders that will specify the position of our vertex.
gl_Position = vec4(uOffset + vPos.x, vPos.y, vPos.z, 1.0);
gl_Position = vec4(vPos, 1.0);

// R G B A
// 1 0 0 1

// The rest of this code looks like plain old C (almost C#)
vec4 color = vec4(vColor.r, vColor.g, uBlue, vColor.a);
fColor = color;
}
// Here we specify the version of our shader.
#version 330 core

// These lines specify the location and type of our attributes,
// the attributes here are prefixed with a "v" as they are our inputs to the vertex shader
// this isn't strictly necessary though, but a good habit.
layout (location = 0) in vec3 vPos;
layout (location = 1) in vec4 vColor;

// This is how we declare a uniform, they can be used in all our shaders and share the same name.
// This is prefixed with a u as it's our uniform.
uniform float uBlue;
uniform float uOffset;

// This is our output variable, notice that this is prefixed with an f as it's the input of our fragment shader.
out vec4 fColor;

void main()
{
// gl_Position, is a built-in variable on all vertex shaders that will specify the position of our vertex.
gl_Position = vec4(uOffset + vPos.x, vPos.y, vPos.z, 1.0);
gl_Position = vec4(vPos, 1.0);

// R G B A
// 1 0 0 1

// The rest of this code looks like plain old C (almost C#)
vec4 color = vec4(vColor.r, vColor.g, uBlue, vColor.a);
fColor = color;
}
public void SetUniform(string name, float value)
{
var location = _gl.GetUniformLocation(_handle, name);
if (location == -1)
{
throw new Exception($"{name} uniform not found on shader.");
}

_gl.Uniform1(location, value);
}
public void SetUniform(string name, float value)
{
var location = _gl.GetUniformLocation(_handle, name);
if (location == -1)
{
throw new Exception($"{name} uniform not found on shader.");
}

_gl.Uniform1(location, value);
}
var value = (float) Math.Sin(DateTime.Now.Millisecond / 1000f * Math.PI);
_shader.SetUniform("uBlue", value);
_shader.SetUniform("uOffset", value);
var value = (float) Math.Sin(DateTime.Now.Millisecond / 1000f * Math.PI);
_shader.SetUniform("uBlue", value);
_shader.SetUniform("uOffset", value);
It seems to work fine for the uBlue shader am I missing something stupid
Unhandled exception. System.Exception: uOffset uniform not found on shader.
at Graphics.Shader.SetUniform(String name, Single value) in C:\Users\mdabr\RiderProjects\2023\Graphics\Graphics\Shader.cs:line 149
Unhandled exception. System.Exception: uOffset uniform not found on shader.
at Graphics.Shader.SetUniform(String name, Single value) in C:\Users\mdabr\RiderProjects\2023\Graphics\Graphics\Shader.cs:line 149
4 replies
CC#
Created by Patrick Square on 4/25/2023 in #help
❔ JWT still being accepted after it expires in web API
6 replies
CC#
Created by Patrick Square on 4/23/2023 in #help
❔ Game development advice: networking or api to interface client with server?
I am making a multiplayer game. It is not like a real-time FPS or anything. The information exchanged between the server and client is minimal. In fact, the backend game is just one pretty straightforward state machine. I was wondering that because of this simplicity, is it perhaps better for me to just consider using a web api to connect the client and server, rather than going all-in with a networking library such as Riptide
4 replies