Liberi Developer Guide: Devices

From EQUIS Lab Wiki

Jump to: navigation, search

Contents

About

"Devices" in Liberi are permanent, client-side objects that provide some kind of service for the game. They can be selectively enabled/disabled. The exact definition of "service" here is fairly abstract, and can really be anything, but the most common role of a device is to provide some subset of player input, like actions, direction, or heart rate. See the Heart article and the Controls article for more info about heart rate and controls injection.

Implementation

To implement a device, all you have to do is write a regular Unity script in such a way that it only performs its required duties if it is enabled. This is most likely going to be a given, since the Update method is not called on disabled scripts. It is possible to write multiple scripts which are intended to run simultaneously as the same "device". See the Scripts/Devices folder of the Liberi Unity project for source code of existing devices.

Management

API

The DeviceManager class is used to enumerate, enable and disable devices. However, unless you plan to programmatically enable/disable devices on-the-fly, this is all automated for you through the use of configuration files.

Scene

Under the "client" scene, you will find a "device_manager" object under the "game_client" object. Under that, you will see an array of different device objects. If you want to add a new device, simply create a uniquely named object here, and attach the device script(s) you wrote. Whether or not a device is enabled is reflected by whether or not this object is active. Your device object is activated by default, which means your device is enabled unless explicitly disabled. If you deactivate your device object in the client scene, then your device will be disabled unless explicitly enabled.

Configuration

Liberi creates a Config/Devices.ini file to configure device states. It contains a UJeli dictionary where the keys are device IDs (the names of device objects in the client scene), and the values are booleans representing whether the device is enabled. This configuration file overrides the default device states in the client scene.