/redgrin

A lidgren wrapper that creates an opinionated API to make network multiplayer easier. Intended for FlatRedBall game engine but compatible with MonoGame, Unity and other C# engines.

Primary LanguageC#MIT LicenseMIT

README

RedGrin is an opinionated wrapper for Lidgren that attempts to simplify multiplayer networking for small indie games. Redgrin was written specifically for the FlatRedBall game engine but should be compatible with any C# game engine including MonoGame and Unity.

What does Redgrin do that Lidgren doesn't?

Redgrin defines an architecture and communication pattern that abstracts away many of the complex details of networking. Redgrin takes care of:

  • Choosing the right message type
  • Serializing and deserializing transfer messages
  • Giving entities unique identifiers across all clients
  • Keeping track of an instance role (Client or Server)
  • Allowing role-based logic
  • Performing dead reckoning
  • Client-server architecture

Redgrin does not do partitioning, input prediction, physics interpolation, cheating detection or other logic that tends to be game-specific. The interfaces provide methods and arguments allowing developers to determine how their game should handle entity ownership, latency, and other multiplayer details.

How does Redgrin Work?

At a high level, Redgrin works like this:

  1. Define transfer classes for each entity that describes its state so it can be synced across the network. Defining transfer types up front allows automatic serialization of transfer objects into network messages.
  2. Create a NetworkConfiguration instance that defines app name, port numbers, and lists the transfer class types.
  3. Each entity that needs to sync across the network should implement the INetworkEntity interface.
  4. Your game level/screen/arena should implement the INetworkArena interface.
  5. Call NetworkManager.Self.Update() in your game loop to run the networking processes.
  6. Call NetworkManager.Self.Initialize with your NetworkConfiguration object and an optional logger to initialize the network.
  7. Call NetworkManager.Self.Start to start the network in a role (Client or Server).
  8. Call Connect with an IP address to connect to a server.
  9. The NetworkManager has methods to create, delete and update entities. It will automatically call methods on INetworkEntity objects and the INetworkArena to manage the synchronization of objects across the network.

How do I learn more?

These whitepapers/articles have been helpful for me:

Who do I talk to?

https://twitter.com/profexorgeek