Liberi Developer Guide: World Data

From EQUIS Lab Wiki

Revision as of 14:09, 27 August 2015 by Moran (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Overview

World data is used to store persistent data or configuration settings about the game world in a way such that it can easily modified by non-technical staff, without needing to recompile the game. Examples of such data include: the number of rounds that a match of Gekku Race should have, enemy difficulty multipliers, shop item prices, minigame availabilities, special event dates, etc.

Storage

World data is stored on the world server under the World directory in Jeli documents called "pages". Pages are saved in plain-text with a "*.dat" extension, and can be organized into subdirectories. The "name" of a world data page is the extension-less form of its path relative to the World folder. For example, the name of the page located at World/Misc/blah.dat would be: "Misc/blah". However, most world data pages are saved directly under the World directory, so their names are simply their extension-less filenames. Browse the World directory of an existing world server build to see real examples of world data pages.

Access

Reading

World data can be read by any server or client. The following methods exist in both the GameClient and the GameServer classes. As such, they may also be accessed through the agnostic Game class.

  • PullWorldData
This sends a request to the world server for the contents of a single world data page. You provide the name of the page to pull, and a callback method to invoke when the page arrives.
  • GetCachedWorldData
This gets the local cached copy of a world page. The difference between this method and PullWorldData is that this method returns the page immediately if available, and returns null otherwise, whereas PullWorldData waits for a response from the world server and invokes a callback.

Writing

Changes to world data may only be pushed to the world server by servers, for security reasons. Although, in practice, we don't push any changes to world data at all. Nevertheless, the following method is available in case we ever need it.

  • GameServer.PushWorldData
Use this to push the new contents of one world data page to the world server.

Map Settings

Any field of a component on a synced object belonging to the server can make use of the MapSetting attribute. The attribute will automatically fill the field in with a value set in a text file that is stored on the WorldServer.

For example, if we create a minigame called my_minigame , in MyMinigameLogic you could define the following:

[MapSetting]
public int MyVariable;

Then in the "World" folder of the World Server, we would create a file called "my_minigame_settings.dat" and inside it define MyVariable = 10. Then, whenever the map is loaded, this MyVariable will be initialized to 10. If this value is left unset, then it will use whatever value you set in the Inspector for that component. The value you set in the Inspector will always be overwritten if you define it as a map setting and it is present in the settings.dat file for that scene.