Velcer
Velcer
CC#
Created by Velcer on 7/12/2023 in #help
❔ Trouble with C# certificates
Greetings, In a local environment I have no issues at all. When I push my Game Server (the client) to a hosted environment, I get an error saying the following: {"Type":"InvalidAuth","Message":"This server requires client certificate for authentication, but none was provided by the client. Did you forget to install the certificate?"} I contacted Ravendb support and they said the following: Basically it's about the X509 certificate's private key. In a lot of platform you need to allow the app to load that certificate explicitly e.g. by providing its thumbprint. My assumption of this response is that I need to first install the certificate on said machine before I can use it. The problem is that I don't have permissions to install a certificate on that machine. I am wondering what can be done. The following code is what I am using:
using Raven.Client.Documents;
using Raven.Client.Documents.Conventions;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;

public static class DocumentStoreHolder
{
private const string CERTIFICATE_PASSWORD = "B8ABC07EA75BC5B18DB92386A726F93A";
private static string CERTIFICATE_PATH = Path.GetFullPath("certificate.pfx");

public static X509Certificate2 GetCertificate()
{
return new X509Certificate2(CERTIFICATE_PATH, CERTIFICATE_PASSWORD);
}
public static void Initialize()
{
var certificate = GetCertificate();

LazyStore = new Lazy<IDocumentStore>(() =>
{
var store = new DocumentStore
{
Urls = new[] { "https://a.free.starmmo.ravendb.cloud" },
Database = "StarMMO",
Certificate = certificate,


};
return store.Initialize();
});

}

private static Lazy<IDocumentStore> LazyStore;

public static IDocumentStore Store => LazyStore.Value;
}
using Raven.Client.Documents;
using Raven.Client.Documents.Conventions;
using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;

public static class DocumentStoreHolder
{
private const string CERTIFICATE_PASSWORD = "B8ABC07EA75BC5B18DB92386A726F93A";
private static string CERTIFICATE_PATH = Path.GetFullPath("certificate.pfx");

public static X509Certificate2 GetCertificate()
{
return new X509Certificate2(CERTIFICATE_PATH, CERTIFICATE_PASSWORD);
}
public static void Initialize()
{
var certificate = GetCertificate();

LazyStore = new Lazy<IDocumentStore>(() =>
{
var store = new DocumentStore
{
Urls = new[] { "https://a.free.starmmo.ravendb.cloud" },
Database = "StarMMO",
Certificate = certificate,


};
return store.Initialize();
});

}

private static Lazy<IDocumentStore> LazyStore;

public static IDocumentStore Store => LazyStore.Value;
}
4 replies
CC#
Created by Velcer on 3/11/2023 in #help
❔ Flip Board not working properly
Hello, I'm working on a level editor for my game. My board is not flipping properly. I've attached a video. Here is my code:
public void FlipBoard()
{
foreach (var boardObject in _placedObjects)
{
if (boardObject.buildable.Category == LevelEditorCategory.BoardTile || boardObject.buildable.Category == LevelEditorCategory.Piece || boardObject.buildable.Category == LevelEditorCategory.ActionTile)
{
var pos = boardObject.Position;
var newRotation = new Vector2(pos.x, pos.y);


newRotation = newRotation.Rotate(180);
newRotation.x += _levelBounds.max.x;
newRotation.y += _levelBounds.max.y;




boardObject.transform.position = newRotation;
boardObject.Position = new Vector2Int((int)newRotation.x, (int)newRotation.y);
}

}


isFlipped = !isFlipped;
}
public void FlipBoard()
{
foreach (var boardObject in _placedObjects)
{
if (boardObject.buildable.Category == LevelEditorCategory.BoardTile || boardObject.buildable.Category == LevelEditorCategory.Piece || boardObject.buildable.Category == LevelEditorCategory.ActionTile)
{
var pos = boardObject.Position;
var newRotation = new Vector2(pos.x, pos.y);


newRotation = newRotation.Rotate(180);
newRotation.x += _levelBounds.max.x;
newRotation.y += _levelBounds.max.y;




boardObject.transform.position = newRotation;
boardObject.Position = new Vector2Int((int)newRotation.x, (int)newRotation.y);
}

}


isFlipped = !isFlipped;
}
public static Vector2 Rotate(this Vector2 v, float degrees)
{
return v.RotateRadians(degrees * Mathf.Deg2Rad);
}

public static Vector2 RotateRadians(this Vector2 v, float radians)
{
var ca = Mathf.Cos(radians);
var sa = Mathf.Sin(radians);
return new Vector2(ca * v.x - sa * v.y, sa * v.x + ca * v.y);
}
public static Vector2 Rotate(this Vector2 v, float degrees)
{
return v.RotateRadians(degrees * Mathf.Deg2Rad);
}

public static Vector2 RotateRadians(this Vector2 v, float radians)
{
var ca = Mathf.Cos(radians);
var sa = Mathf.Sin(radians);
return new Vector2(ca * v.x - sa * v.y, sa * v.x + ca * v.y);
}
17 replies
CC#
Created by Velcer on 3/4/2023 in #help
❔ How can I find all the whole number vectors between two points?
Vector2(-8, -8) Vector2(8, 8) How can I find all the whole number vectors between two points?
20 replies
CC#
Created by Velcer on 2/25/2023 in #help
❔ Continue a switch statement
The switch statement is very convenient for managing my types. I would like to instead of just having one of these hit, for it to hit any that meet criteria.
switch (kinematic)
{
case PlayerShip playerShip:
playerShipsEnteredProximityOfEntity.Add(new KeyValuePair<ushort, ushort> (kinematic.KinematicId, collision.Id));
break;
case BaseEntity entity:
if (!entity.EntitiesInProximity.Contains(collision.Id))
entity.EntitiesInProximity.Add(collision.Id);
break;
}
switch (kinematic)
{
case PlayerShip playerShip:
playerShipsEnteredProximityOfEntity.Add(new KeyValuePair<ushort, ushort> (kinematic.KinematicId, collision.Id));
break;
case BaseEntity entity:
if (!entity.EntitiesInProximity.Contains(collision.Id))
entity.EntitiesInProximity.Add(collision.Id);
break;
}
10 replies
CC#
Created by Velcer on 2/25/2023 in #help
❔ Get collection of a groupBy based on key.
I have a list of KeyValuePairs <ushort, ushort> I am attempting to group the list by the key,
so myNewCollection = list.OrderBy(k => k.key);

now we step into a foreach loop
foreach (var player in players)
{
// TO DO : Get all items from myNewCollection where key is player.Id
// Iterate new collection
}
so myNewCollection = list.OrderBy(k => k.key);

now we step into a foreach loop
foreach (var player in players)
{
// TO DO : Get all items from myNewCollection where key is player.Id
// Iterate new collection
}
csharp What I am having trouble with is understanding the proper, efficient way to get all items of myNewCollection where the key is my playerId.
17 replies
CC#
Created by Velcer on 2/21/2023 in #help
❔ Any Danger to using Actions in this way?
public class Entity
{
public event Action<int> OnUpdateFrame;

internal void OnNewTick(int tick)
{
OnUpdateFrame?.Invoke(tick);
}
}

public class Frog : Entity
{
public Frog()
{
OnUpdateFrame += Frog_OnUpdateFrame;
}

private void Frog_OnUpdateFrame(int obj)
{
throw new NotImplementedException();
}
}

public class SuperFrog : Frog
{
public SuperFrog() : base()
{
OnUpdateFrame += SuperFrog_OnUpdateFrame;
}

private void SuperFrog_OnUpdateFrame(int obj)
{
throw new NotImplementedException();
}
}
public class Entity
{
public event Action<int> OnUpdateFrame;

internal void OnNewTick(int tick)
{
OnUpdateFrame?.Invoke(tick);
}
}

public class Frog : Entity
{
public Frog()
{
OnUpdateFrame += Frog_OnUpdateFrame;
}

private void Frog_OnUpdateFrame(int obj)
{
throw new NotImplementedException();
}
}

public class SuperFrog : Frog
{
public SuperFrog() : base()
{
OnUpdateFrame += SuperFrog_OnUpdateFrame;
}

private void SuperFrog_OnUpdateFrame(int obj)
{
throw new NotImplementedException();
}
}
9 replies
CC#
Created by Velcer on 10/18/2022 in #help
Imported a package, but using statement isn't working?
1 replies
CC#
Created by Velcer on 10/17/2022 in #help
Does anyone have experience with maps?
I'm building a winforms replica of an online map, as seen here: https://wiki.albiononline.com/wiki/World_Map I'm trying to take this data, and rebuild this into a winforms application, so that I can utilize it and provide more data to the map. It uses a library called Leaflet. I'm trying to use syncfusions map, but they take a shapefile, and all I have is png files from this world map.
1 replies