docs
Systems
Contracts
ContractsSystem
Architecture and Design

Overview

The Contracts System is a set of static definitions. It has three source files:

  • CoreKeyNames (static class): string constants for parameter keys.
  • CoreParamKeys (static class): typed ParamKey<T> fields built from those string constants.
  • CoreEnums (file): the Domain enum.

Design Patterns Used

  • Static constant holder: CoreKeyNames groups string constants and does not hold state.
  • Typed parameter keys: CoreParamKeys pairs each key string with a compile-time payload type through ParamKey<T>, so readers and writers of a payload agree on the type.
  • Composed key strings: Keys are built with const concatenation from a private Base value and a private nested Schema class. The result is still a compile-time constant.

Key Naming Scheme

All keys start with core.contracts. The middle segment identifies the kind of value, and the suffix is the schema segment:

  • StringValue: core.contracts.string.value
  • ObjectValue: core.contracts.object.value
  • StringKey: core.contracts.string.key
  • StringTag: core.contracts.string.tag
  • DomainContext: core.contracts.domain.domain
  • RegistrationKey: core.contracts.registration.key
  • ObjectTransform: core.contracts.object.transform
  • IDCollection: core.contracts.id.collection
  • ID: core.contracts.id
  • GameObjectCollection: core.contracts.game.object.collection
  • Duration: core.contracts.duration

Domain Routing

Domain identifies the system that owns a message. The CoreParamKeys.DomainContext key carries a Domain value so a message can name its target. The enum's remarks state that messages are routed by this value.

Data Flow

  1. A producer builds a parameter payload and writes values using CoreParamKeys fields, for example Tag, Key, or Duration.
  2. The payload may include a DomainContext value that names the target Domain.
  3. A consumer reads the same ParamKey<T> fields to retrieve values with their declared types.

The source defines the keys and the payload types. It does not show how payloads are stored or delivered.

Terminology

  • Domain: A system category identified by a Domain enum value.
  • Parameter key: A ParamKey<T> that names a value in a parameter payload.
  • Core key name: A string constant in CoreKeyNames that a parameter key is built from.
  • Object value: A ParamKey<object> for values whose concrete type varies by call site.