Gorilla.Arena.User Unit Reference

Overview

The Gorilla.Arena.User unit provides TGorillaArenaUser, the entity that represents one participant, and TGorillaArenaUserList, the map the manager keeps them in. A user is an entity with a colour, a position and a list of items of its own.

Class Hierarchy

TJSONWrapObject
  └── TGorillaArenaEntity
        └── TGorillaArenaUser         implements IGorillaArenaUser

TDictionary<TGUID, IGorillaArenaUser>
  └── TGorillaArenaUserList

TGorillaArenaUserClass = class of TGorillaArenaUser

Constants

Constant Value
ARENA_USER_FIELD_COLOR Color
ARENA_USER_FIELD_POSITION Position

Enumerations

TArenaUserState

Reported by TGorillaArenaManager.OnStatusChanged.

Value Description
None Not in a group
Pending Joining
Joined In

TArenaUserAction

Reported by TGorillaArenaManager.OnUserEvent.

Value Description
Added A user appeared
Remove A user is gone
Update A user's data changed

IGorillaArenaUser

GUID {419101A0-C303-4E91-8568-2AFBEFF162B2}, descends IGorillaArenaEntity.

Member Type Description
Color TAlphaColorF The participant's colour
Position TPoint3D Where they are
Items TJSONWrapObjectList Whatever they carry

Everything from IGorillaArenaEntity — Id, Group, GUID, GUIDStr, SourceProfile, BeginUpdate, Submit — applies as well. The session layer uses Id for the display name and GUIDStr as the member id.

TGorillaArenaUser

Constructor

constructor Create(const AProfile : TObject; const AId : String);
  reintroduce; virtual;

Wrapped in BeginUpdate / EndUpdate, so creating a user produces no traffic of its own. The colour starts at opaque red.

Published Properties

Property Type Description
Color TAlphaColorF Stored as a string; red and blue are swapped on Windows on the way in and out
Position TPoint3D Stored as a string

Public Properties

Property Type Description
Items TJSONWrapObjectList The user's items. Owned by the user

TGorillaArenaUserList

A TDictionary<TGUID, IGorillaArenaUser> with one addition:

Method Description
ToJSON() : String The whole map as a JSON object, keyed by GUID string

That is what the manager serves as the UserList resource.

Using a Class of Your Own

type
  TMyUser = class(TGorillaArenaUser)
    protected
      function  GetTeam() : Integer;
      procedure SetTeam(const AValue : Integer);
    published
      property Team : Integer read GetTeam write SetTeam;
  end;

FManager.SetUserClass(TMyUser);   // before Join()

SetUserClass must be called before joining — otherwise the users have already been created from the default class. Both CreateMyself and AddRemoteUser honour it.

See Also