Skip to content

Game state loader

This module provides infrastructure to enable game loading, periodic updates and processing of actions issued by the user.

Configuration

This module is configured through a GameConfig object:

  • ServerAddress: The game server URL (scheme, host, port).
  • UserAuth: User authentication token or password for alpha servers.
  • UserId: The user account id.
  • GameId: The game id.
  • GameStateUpdateInterval: The game state polling interval in seconds (optional, default is 60 seconds).

Issue user actions

When the user interacts with the game in a way that it affects the state then the server needs to process and verify this "user action" sending an updated game state in response. Specific types of these user actions need to be implemented as a subclass of Stratkit.ServerCommunication.ServerCommand. To issue these commands create a command using the corresponding builder and create a new entity with a ServerCommandRequest component wrapping the command. The commands will then be sent to the game server along with a request to update the game state.

Issue user action example

    IddqdCommand command = new IddqdCommandBuilder()
        .WithValue(666)
        .Build();

    entityCommandBuffer.AddComponent(
        entityCommandBuffer.CreateEntity(),
        new ServerCommandRequest { Value = command }
    );