Forum C# Unable to derive from Game class

Unable to derive from Game class

Postby deetmo » August 5th, 2019, 11:15 pm

Why is it impossible to derive from Game class?
When I try to make some general purpose room code in such class:
Code: Select all
public abstract class RoomPlayer : BasePlayer
{}

public abstract class Room<TRoomPlayer> : Game<TRoomPlayer>
    where TRoomPlayer : RoomPlayer, new()
{}

And then:
Code: Select all
public class SomeRoomPlayer : RoomPlayer
{}

[RoomType("SomeRoom")]
public class SomeRoom : Room<SomeRoomPlayer>
{}


SomeRoom is invisible when uploading to PlayerIO services.

What is preety strange, when I have tried making room not abstract - PlayerIO complain about missing RoomType attribute on base class becouse it is not abstract.

Seems like a bug for me...
deetmo
 
Posts: 3
Joined: May 5th, 2019, 10:30 pm

Re: Unable to derive from Game class

Postby deetmo » August 7th, 2019, 8:27 pm

I have found issue in Init method:
Code: Select all
if (this.searchHierarchy(type, (Predicate<System.Type>) (t =>
{
  if (t.BaseType != (System.Type) null && t.BaseType.BaseType != (System.Type) null && (t.BaseType.Assembly != assembly && t.BaseType.BaseType.Name == "BaseGame"))
    return t.BaseType.Namespace.StartsWith("PlayerIO.GameLibrary");
  return false;
})))


Please fix it, as it really blocks making any frameworks using rooms.
deetmo
 
Posts: 3
Joined: May 5th, 2019, 10:30 pm

Re: Unable to derive from Game class

Postby ShadowVirtues » November 22nd, 2019, 10:23 am

I am having the same issue. I've been struggling for months to come up with a reliable solution to block simultaneous sessions from one player, since PlayerIO doesn't support it natively and in our game a simultaneous session would cause total havoc to player progress in BigDB (pretty sure it would in every serious game storing player progress). So I finally came up with the clean solution that worked wonders using abstract generic room class inheriting from Game<P>, but apparently only in development server, since when uploading the code to PlayerIO, it doesn't see any rooms that derive from such generic class, exactly like OP posted. So I would also really like this to be fixed. Or at least tell us if this will NOT be getting a fix, since we will at least be sure to have to look for other solutions (probably dirty copy-pasting the code into every room class).
ShadowVirtues
 
Posts: 4
Joined: March 13th, 2018, 8:42 pm

Re: Unable to derive from Game class

Postby robscherer123 » January 9th, 2020, 4:14 pm

@shadow I'd say it's safe to say that issue will never be patched. That's had always been a major issue for my game in the past. My best solution was to mark a databaseobject as "online" for the player when they join a room, and mark it as "offline" when they exit the room. This solution has its own host of problem as I'm sure you'd see, but it's mostly the bed you can get I suppose. =/
robscherer123
Paid Member
 
Posts: 312
Joined: December 12th, 2012, 8:46 pm

Re: Unable to derive from Game class

Postby victor » February 2nd, 2020, 6:59 pm

I encountered the same issue. It works if Room<TRoomPlayer> is not generic (changed to Room), but then it's not very useful, since SomeRoom can't have a player type that extends SomeRoomPlayer.

Code: Select all
public class RoomPlayer : BasePlayer
{ }

public abstract class Room : Game<RoomPlayer>
{ }

public class SomeRoomPlayer : RoomPlayer
{ }

// not very useful, since SomeRoomPlayer can't be used
[RoomType("SomeRoom")]
public class SomeRoom : Room
{ }
victor
 
Posts: 3
Joined: October 9th, 2017, 4:42 am


Return to C#



cron