Packages
solecs
Index

Solidity API

BareComponent

Components are a key-value store from entity id to component value. They are registered in the World and register updates to their state in the World. They have an owner, who can grant write access to more addresses. (Systems that want to write to a component need to be given write access first.) Everyone has read access.

BareComponent__NotImplemented

error BareComponent__NotImplemented()

world

address world

Reference to the World contract this component is registered in

entityToValue

mapping(uint256 => bytes) entityToValue

Mapping from entity id to value in this component

id

uint256 id

Public identifier of this component

constructor

constructor(address _world, uint256 _id) internal

registerWorld

function registerWorld(address _world) public

Register this component in the given world.

NameTypeDescription
_worldaddressAddress of the World contract.

set

function set(uint256 entity, bytes value) public

Set the given component value for the given entity. Registers the update in the World contract. Can only be called by addresses with write access to this component.

NameTypeDescription
entityuint256Entity to set the value for.
valuebytesValue to set for the given entity.

remove

function remove(uint256 entity) public

Remove the given entity from this component. Registers the update in the World contract. Can only be called by addresses with write access to this component.

NameTypeDescription
entityuint256Entity to remove from this component.

has

function has(uint256 entity) public view virtual returns (bool)

Check whether the given entity has a value in this component.

NameTypeDescription
entityuint256Entity to check whether it has a value in this component for.

getRawValue

function getRawValue(uint256 entity) public view virtual returns (bytes)

Get the raw (abi-encoded) value of the given entity in this component.

NameTypeDescription
entityuint256Entity to get the raw value in this component for.

getEntities

function getEntities() public view virtual returns (uint256[])

Not implemented in BareComponent

getEntitiesWithValue

function getEntitiesWithValue(bytes) public view virtual returns (uint256[])

Not implemented in BareComponent

registerIndexer

function registerIndexer(address) external virtual

Not implemented in BareComponent

_set

function _set(uint256 entity, bytes value) internal virtual

Set the given component value for the given entity. Registers the update in the World contract. Can only be called internally (by the component or contracts deriving from it), without requiring explicit write access.

NameTypeDescription
entityuint256Entity to set the value for.
valuebytesValue to set for the given entity.

_remove

function _remove(uint256 entity) internal virtual

Remove the given entity from this component. Registers the update in the World contract. Can only be called internally (by the component or contracts deriving from it), without requiring explicit write access.

NameTypeDescription
entityuint256Entity to remove from this component.

Component

Components are a key-value store from entity id to component value. They are registered in the World and register updates to their state in the World. They have an owner, who can grant write access to more addresses. (Systems that want to write to a component need to be given write access first.) Everyone has read access.

entities

contract Set entities

Set of entities with values in this component

valueToEntities

contract MapSet valueToEntities

Reverse mapping from value to set of entities

indexers

contract IEntityIndexer[] indexers

List of indexers to be updated when a component value changes

constructor

constructor(address _world, uint256 _id) internal

has

function has(uint256 entity) public view virtual returns (bool)

Check whether the given entity has a value in this component.

NameTypeDescription
entityuint256Entity to check whether it has a value in this component for.

getEntities

function getEntities() public view virtual returns (uint256[])

Get a list of all entities that have a value in this component.

getEntitiesWithValue

function getEntitiesWithValue(bytes value) public view virtual returns (uint256[])

Get a list of all entities that have the specified value in this component.

NameTypeDescription
valuebytesAbi-encoded value to get the list of entities with this value for.

registerIndexer

function registerIndexer(address indexer) external virtual

Register a new indexer that gets notified when a component value is set.

NameTypeDescription
indexeraddressAddress of the indexer to notify when a component value is set.

_set

function _set(uint256 entity, bytes value) internal virtual

Set the given component value for the given entity. Registers the update in the World contract. Can only be called internally (by the component or contracts deriving from it), without requiring explicit write access.

NameTypeDescription
entityuint256Entity to set the value for.
valuebytesValue to set for the given entity.

_remove

function _remove(uint256 entity) internal virtual

Remove the given entity from this component. Registers the update in the World contract. Can only be called internally (by the component or contracts deriving from it), without requiring explicit write access.

NameTypeDescription
entityuint256Entity to remove from this component.

Indexer

entities

contract Set entities

valueToEntities

mapping(bytes => address) valueToEntities

entityToValue

mapping(uint256 => bytes) entityToValue

components

contract Component[] components

trackValueForComponent

bool[] trackValueForComponent

constructor

constructor(contract Component[] _components, bool[] _trackValueForComponent) public

update

function update(uint256 entity, bytes value) external

remove

function remove(uint256 entity) external

supportsInterface

function supportsInterface(bytes4 interfaceId) external view returns (bool)

query whether contract has registered support for given interface

NameTypeDescription
interfaceIdbytes4interface id
NameTypeDescription
[0]boolbool whether interface is supported

getEntities

function getEntities() external view returns (uint256[])

getEntitiesWithValue

function getEntitiesWithValue(bytes value) external view returns (uint256[])

has

function has(uint256 entity) public view returns (bool)

_set

function _set(uint256 entity, bytes[] newValues) internal

Uint256Node

struct Uint256Node {
  uint256 value;
  uint256 next;
}

freeFunction

freeFunction pointer(struct Uint256Node a) internal pure returns (bytes32 ptr)

freeFunction

freeFunction fromPointer(bytes32 ptr) internal pure returns (struct Uint256Node a)

freeFunction

freeFunction isPositiveFragment(struct QueryFragment fragment) internal pure returns (bool)

freeFunction

freeFunction isNegativeFragment(struct QueryFragment fragment) internal pure returns (bool)

freeFunction

freeFunction isSettingFragment(struct QueryFragment fragment) internal pure returns (bool)

freeFunction

freeFunction isEntityFragment(struct QueryFragment fragment) internal pure returns (bool)

freeFunction

freeFunction passesQueryFragment(uint256 entity, struct QueryFragment fragment) internal view returns (bool)

freeFunction

freeFunction passesQueryFragmentProxy(uint256 entity, struct QueryFragment fragment, struct QueryFragment proxyRead) internal view returns (bool passes, bool proxyFound)

freeFunction

freeFunction isBreakingPassState(bool passes, struct QueryFragment fragment) internal pure returns (bool)

For positive fragments (Has/HasValue) we need to find any passing entity up the proxy chain so as soon as passes is true, we can early return. For negative fragments (Not/NotValue) every entity up the proxy chain must pass, so we can early return if we find one that doesn't pass.

QueryVars

struct QueryVars {
  LinkedList entities;
  uint256 numEntities;
  struct QueryFragment proxyRead;
  struct QueryFragment proxyExpand;
  bool initialFragment;
}

LibQuery

query

function query(struct QueryFragment[] fragments) internal view returns (uint256[])

Execute the given query and return a list of entity ids

NameTypeDescription
fragmentsstruct QueryFragment[]List of query fragments to execute
NameTypeDescription
[0]uint256[]entities List of entities matching the query

_processProxyRead

function _processProxyRead(struct QueryVars v, struct QueryFragment fragment, uint256 entity, bool passes) internal view returns (bool)

_processProxyExpand

function _processProxyExpand(struct QueryVars v, struct QueryFragment fragment, uint256 entity, LinkedList nextEntities, uint256 nextNumEntities) internal view returns (LinkedList, uint256)

getChildEntities

function getChildEntities(uint256 entity, contract IComponent component, uint256 depth) internal view returns (uint256[])

Recursively computes all direct and indirect child entities up to the specified depth

NameTypeDescription
entityuint256Entity to get all child entities up to the specified depth
componentcontract IComponentEntity reference component
depthuint256Depth up to which the recursion should be applied
NameTypeDescription
[0]uint256[]Set of entities that are child entities of the given entity via the given component

getValueWithProxy

function getValueWithProxy(contract IComponent component, uint256 entity, contract IComponent proxyComponent, uint256 depth) internal view returns (bytes value, bool found)

listToArray

function listToArray(LinkedList list, uint256 length) public pure returns (uint256[] array)

Helper function to turn a linked list into an array

arrayToList

function arrayToList(uint256[] array) public pure returns (LinkedList list)

Helper function to turn an array into a linked list

LibTypes

Enum of supported schema types

SchemaValue

enum SchemaValue {
  BOOL,
  INT8,
  INT16,
  INT32,
  INT64,
  INT128,
  INT256,
  INT,
  UINT8,
  UINT16,
  UINT32,
  UINT64,
  UINT128,
  UINT256,
  BYTES,
  STRING,
  ADDRESS,
  BYTES4,
  BOOL_ARRAY,
  INT8_ARRAY,
  INT16_ARRAY,
  INT32_ARRAY,
  INT64_ARRAY,
  INT128_ARRAY,
  INT256_ARRAY,
  INT_ARRAY,
  UINT8_ARRAY,
  UINT16_ARRAY,
  UINT32_ARRAY,
  UINT64_ARRAY,
  UINT128_ARRAY,
  UINT256_ARRAY,
  BYTES_ARRAY,
  STRING_ARRAY
}

MapSet

Key value store with uint256 key and uint256 Set value

items

mapping(uint256 => uint256[]) items

itemToIndex

mapping(uint256 => mapping(uint256 => uint256)) itemToIndex

add

function add(uint256 setKey, uint256 item) public

remove

function remove(uint256 setKey, uint256 item) public

has

function has(uint256 setKey, uint256 item) public view returns (bool)

getItems

function getItems(uint256 setKey) public view returns (uint256[])

size

function size(uint256 setKey) public view returns (uint256)

Ownable

IERC173 implementation

constructor

constructor() public

OwnableWritable

Ownable with authorized writers

OwnableWritable__NotWriter

error OwnableWritable__NotWriter()

writeAccess

function writeAccess(address operator) public view virtual returns (bool)

Whether given operator has write access

onlyWriter

modifier onlyWriter()

Revert if caller does not have write access to this component

authorizeWriter

function authorizeWriter(address writer) public virtual

Grant write access to the given address. Can only be called by the owner.

NameTypeDescription
writeraddressAddress to grant write access to.

unauthorizeWriter

function unauthorizeWriter(address writer) public virtual

Revoke write access from the given address. Can only be called by the owner.

NameTypeDescription
writeraddressAddress to revoke write access.

OwnableWritableStorage

Layout

struct Layout {
  mapping(address => bool) writeAccess;
}

STORAGE_SLOT

bytes32 STORAGE_SLOT

layout

function layout() internal pure returns (struct OwnableWritableStorage.Layout l)

PayableSystem

System base contract

components

contract IUint256Component components

world

contract IWorld world

constructor

constructor(contract IWorld _world, address _components) internal

Set

Set of unique uint256

items

uint256[] items

itemToIndex

mapping(uint256 => uint256) itemToIndex

add

function add(uint256 item) public

remove

function remove(uint256 item) public

getIndex

function getIndex(uint256 item) public view returns (bool, uint256)

has

function has(uint256 item) public view returns (bool)

getItems

function getItems() public view returns (uint256[])

size

function size() public view returns (uint256)

System

System base contract

components

contract IUint256Component components

world

contract IWorld world

constructor

constructor(contract IWorld _world, address _components) internal

SystemStorage

Systems contain the address of the components registry and world contract as state variables. SystemStorage ensures that these addresses are stored at deterministic locations in a System contract's storage. Developers can read/write components and access world utilities from any library called by a System. Warning: Library must be initialized (init) by a contract that can access components + world contracts before use. The intialization is done automatically for any contract inheriting System or MudTest.

Layout

struct Layout {
  contract IUint256Component components;
  contract IWorld world;
}

STORAGE_SLOT

bytes32 STORAGE_SLOT

Location in memory where the Layout struct will be stored

layout

function layout() internal pure returns (struct SystemStorage.Layout l)

Utility for accessing the STORAGE_SLOT location in the contract's storage

NameTypeDescription
lstruct SystemStorage.LayoutLayout struct at storage position l

init

function init(contract IWorld _world, contract IUint256Component _components) internal

Register this component in the given world.

This function must be called at the start of any contract that expects libraries to access SystemStorage!

NameTypeDescription
_worldcontract IWorldAddress of the World contract.
_componentscontract IUint256ComponentAddress of the Components registry contract.

components

function components() public view returns (contract IUint256Component)
NameTypeDescription
[0]contract IUint256ComponentComponent registry contract

world

function world() public view returns (contract IWorld)
NameTypeDescription
[0]contract IWorldWorld contract

system

function system(uint256 systemID) internal view returns (address)
NameTypeDescription
systemIDuint256ID for a system
NameTypeDescription
[0]addressaddress of the System contract from the components registry

component

function component(uint256 componentID) internal view returns (address)
NameTypeDescription
componentIDuint256ID for a component
NameTypeDescription
[0]addressaddress of the Component contract from the components registry

World

The World contract is at the core of every on-chain world. Entities, components and systems are registered in the World. Components register updates to their state via the registerComponentValueSet and registerComponentValueRemoved methods, which emit the ComponentValueSet and ComponentValueRemoved events respectively.

Clients can reconstruct the entire state (of all components) by listening to these two events, instead of having to add a separate getter or event listener for every type of data. (Have a look at the MUD network package for a TypeScript implementation of contract/client state sync.)

The World is an ownerless and permissionless contract. Anyone can register new components and systems in the world (via the registerComponent and registerSystem methods). Clients decide which components and systems they care about.

entities

contract Set entities

_components

contract Uint256Component _components

_systems

contract Uint256Component _systems

register

contract RegisterSystem register

ComponentValueSet

event ComponentValueSet(uint256 componentId, address component, uint256 entity, bytes data)

ComponentValueRemoved

event ComponentValueRemoved(uint256 componentId, address component, uint256 entity)

constructor

constructor() public

init

function init() public

Initialize the World. Separated from the constructor to prevent circular dependencies.

components

function components() public view returns (contract IUint256Component)

Get the component registry Uint256Component (mapping from component address to component id)

systems

function systems() public view returns (contract IUint256Component)

Get the system registry Uint256Component (mapping from system address to system id)

registerComponent

function registerComponent(address componentAddr, uint256 id) public

Register a new component in this World. ID must be unique.

registerSystem

function registerSystem(address systemAddr, uint256 id) public

Register a new system in this World. ID must be unique.

requireComponentRegistered

modifier requireComponentRegistered(address component)

Reverts if the component is not registered in this World.

registerComponentValueSet

function registerComponentValueSet(address component, uint256 entity, bytes data) public

Deprecated - use registerComponentValueSet(entity, data) instead Register a component value update. Emits the ComponentValueSet event for clients to reconstruct the state.

registerComponentValueSet

function registerComponentValueSet(uint256 entity, bytes data) public

Register a component value update. Emits the ComponentValueSet event for clients to reconstruct the state.

registerComponentValueRemoved

function registerComponentValueRemoved(address component, uint256 entity) public

Deprecated - use registerComponentValueRemoved(entity) instead Register a component value removal. Emits the ComponentValueRemoved event for clients to reconstruct the state.

registerComponentValueRemoved

function registerComponentValueRemoved(uint256 entity) public

Register a component value removal. Emits the ComponentValueRemoved event for clients to reconstruct the state.

getComponent

function getComponent(uint256 id) external view returns (address)

Deprecated, but left here for backward compatibility. TODO: refactor all consumers.

getComponentIdFromAddress

function getComponentIdFromAddress(address componentAddr) external view returns (uint256)

Deprecated, but left here for backward compatibility. TODO: refactor all consumers.

getSystemAddress

function getSystemAddress(uint256 systemId) external view returns (address)

Deprecated, but left here for backward compatibility. TODO: refactor all consumers.

getNumEntities

function getNumEntities() public view returns (uint256)

query

function query(struct WorldQueryFragment[] worldQueryFragments) public view returns (uint256[])

Helper function to execute a query with query fragments referring to a component ID instead of a component address.

hasEntity

function hasEntity(uint256 entity) public view returns (bool)

Check whether an entity exists in this world.

getUniqueEntityId

function getUniqueEntityId() public view returns (uint256)

Get a new unique entity ID.

Uint256Component

Reference implementation of a component storing a uint256 value for each entity.

constructor

constructor(address world, uint256 id) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, uint256 value) public virtual

getValue

function getValue(uint256 entity) public view virtual returns (uint256)

getEntitiesWithValue

function getEntitiesWithValue(uint256 value) public view virtual returns (uint256[])

componentsComponentId

uint256 componentsComponentId

systemsComponentId

uint256 systemsComponentId

IComponent

getSchema

function getSchema() external pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, bytes value) external

remove

function remove(uint256 entity) external

has

function has(uint256 entity) external view returns (bool)

getRawValue

function getRawValue(uint256 entity) external view returns (bytes)

getEntities

function getEntities() external view returns (uint256[])

getEntitiesWithValue

function getEntitiesWithValue(bytes value) external view returns (uint256[])

registerIndexer

function registerIndexer(address indexer) external

world

function world() external view returns (address)

IEntityContainer

has

function has(uint256 entity) external view returns (bool)

getEntities

function getEntities() external view returns (uint256[])

getEntitiesWithValue

function getEntitiesWithValue(bytes value) external view returns (uint256[])

IEntityIndexer

update

function update(uint256 entity, bytes value) external

remove

function remove(uint256 entity) external

IOwnableWritable

authorizeWriter

function authorizeWriter(address writer) external

unauthorizeWriter

function unauthorizeWriter(address writer) external

IPayableSystem

execute

function execute(bytes args) external payable returns (bytes)

ISystem

execute

function execute(bytes args) external returns (bytes)

IUint256Component

set

function set(uint256 entity, uint256 value) external

getValue

function getValue(uint256 entity) external view returns (uint256)

getEntitiesWithValue

function getEntitiesWithValue(uint256 value) external view returns (uint256[])

WorldQueryFragment

struct WorldQueryFragment {
  enum QueryType queryType;
  uint256 componentId;
  bytes value;
}

IWorld

components

function components() external view returns (contract IUint256Component)

systems

function systems() external view returns (contract IUint256Component)

registerComponent

function registerComponent(address componentAddr, uint256 id) external

getComponent

function getComponent(uint256 id) external view returns (address)

getComponentIdFromAddress

function getComponentIdFromAddress(address componentAddr) external view returns (uint256)

registerSystem

function registerSystem(address systemAddr, uint256 id) external

registerComponentValueSet

function registerComponentValueSet(address component, uint256 entity, bytes data) external

registerComponentValueSet

function registerComponentValueSet(uint256 entity, bytes data) external

registerComponentValueRemoved

function registerComponentValueRemoved(address component, uint256 entity) external

registerComponentValueRemoved

function registerComponentValueRemoved(uint256 entity) external

getNumEntities

function getNumEntities() external view returns (uint256)

hasEntity

function hasEntity(uint256 entity) external view returns (bool)

getUniqueEntityId

function getUniqueEntityId() external view returns (uint256)

query

function query(struct WorldQueryFragment[] worldQueryFragments) external view returns (uint256[])

init

function init() external

QueryType

enum QueryType {
  Has,
  Not,
  HasValue,
  NotValue,
  ProxyRead,
  ProxyExpand
}

QueryFragment

struct QueryFragment {
  enum QueryType queryType;
  contract IComponent component;
  bytes value;
}

RegisterType

enum RegisterType {
  Component,
  System
}

ID

uint256 ID

RegisterSystem

constructor

constructor(contract IWorld _world, address _components) public

requirement

function requirement(bytes args) public view returns (bytes)

execute

function execute(address msgSender, enum RegisterType registerType, address addr, uint256 id) public returns (bytes)

execute

function execute(bytes args) public returns (bytes)

ComponentTest

vm

contract Vm vm

users

address payable[] users

component

contract TestComponent component

setUp

function setUp() public

testSetAndGetValue

function testSetAndGetValue() public

testRemove

function testRemove() public

testGetEntities

function testGetEntities() public

testGetEntitiesWithValue

function testGetEntitiesWithValue() public

IndexerTest

vm

contract Vm vm

position

contract PositionComponent position

damage

contract DamageComponent damage

regionCreatures

contract Indexer regionCreatures

setUp

function setUp() public

testSetAndGetEntitiesWithValue

function testSetAndGetEntitiesWithValue() public

testUpdate

function testUpdate() public

testRemove

function testRemove() public

testGetEntities

function testGetEntities() public

LibQueryTest

vm

contract Vm vm

users

address payable[] users

component1

contract TestComponent1 component1

component2

contract TestComponent2 component2

component3

contract TestComponent3 component3

prototypeTag

contract PrototypeTagComponent prototypeTag

fromPrototype

contract FromPrototypeComponent fromPrototype

ownedByEntity

contract OwnedByEntityComponent ownedByEntity

setUp

function setUp() public

testHasQuery

function testHasQuery() public

testHasValueQuery

function testHasValueQuery() public

testCombinedHasQuery

function testCombinedHasQuery() public

testCombinedHasValueQuery

function testCombinedHasValueQuery() public

testCombinedHasHasValueQuery

function testCombinedHasHasValueQuery() public

testCombinedHasNotQuery

function testCombinedHasNotQuery() public

testCombinedHasValueNotQuery

function testCombinedHasValueNotQuery() public

testCombinedHasHasValueNotQuery

function testCombinedHasHasValueNotQuery() public

testNotValueQuery

function testNotValueQuery() public

testInitialProxyExpand

function testInitialProxyExpand() public

testDeepProxyExpand

function testDeepProxyExpand() public

testProxyRead

function testProxyRead() public

testDeepProxyRead

function testDeepProxyRead() public

testGetValueWithProxy

function testGetValueWithProxy() public

SetTest

vm

contract Vm vm

users

address payable[] users

set

contract Set set

setUp

function setUp() public

testAdd

function testAdd() public

testAddDuplicate

function testAddDuplicate() public

testRemove

function testRemove() public

testGetItems

function testGetItems() public

testSize

function testSize() public

testHas

function testHas() public

SampleSystem

constructor

constructor(contract IWorld _world, address _components) public

execute

function execute(bytes arguments) public returns (bytes)

executeTyped

function executeTyped() external returns (bytes)

getWorld

function getWorld() public view returns (contract IWorld)

getComponents

function getComponents() public view returns (contract IUint256Component)

SystemTest

systems

contract IUint256Component systems

world

contract World world

components

contract IUint256Component components

system

contract SampleSystem system

setUp

function setUp() public

testSystemStorage

function testSystemStorage() public

testSystemStorageTest

function testSystemStorageTest() public

WorldTest

vm

contract Vm vm

users

address payable[] users

world

contract World world

component1

contract TestComponent1 component1

component2

contract TestComponent2 component2

component3

contract TestComponent3 component3

prototypeTag

contract PrototypeTagComponent prototypeTag

fromPrototype

contract FromPrototypeComponent fromPrototype

ownedByEntity

contract OwnedByEntityComponent ownedByEntity

setUp

function setUp() public

testQuery

function testQuery() public

ID

uint256 ID

DamageComponent

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, uint256 value) public

getValue

function getValue(uint256 entity) public view returns (uint256)

getEntitiesWithValue

function getEntitiesWithValue(uint256 value) public view returns (uint256[])

FromPrototypeComponent

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, uint256 prototypeEntity) public

getValue

function getValue(uint256 entity) public view returns (uint256)

getEntitiesWithValue

function getEntitiesWithValue(uint256 prototypeEntity) public view returns (uint256[])

OwnedByEntityComponent

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, uint256 ownedByEntity) public

getValue

function getValue(uint256 entity) public view returns (uint256)

getEntitiesWithValue

function getEntitiesWithValue(uint256 ownedByEntity) public view returns (uint256[])

Position

struct Position {
  int64 x;
  int64 y;
}

ID

uint256 ID

PositionComponent

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, struct Position value) public

getValue

function getValue(uint256 entity) public view returns (struct Position)

getEntitiesWithValue

function getEntitiesWithValue(struct Position value) public view returns (uint256[])

PrototypeTagComponent

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

set

function set(uint256 entity, bool value) public

getValue

function getValue(uint256 entity) public view returns (bool)

getEntitiesWithValue

function getEntitiesWithValue(bool value) public view returns (uint256[])

TestComponent

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

TestComponent1

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

TestComponent2

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

TestComponent3

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

TestComponent4

ID

uint256 ID

constructor

constructor(address world) public

getSchema

function getSchema() public pure returns (string[] keys, enum LibTypes.SchemaValue[] values)

Return the keys and value types of the schema of this component.

UtilsTest

testSplit

function testSplit() public

freeFunction

freeFunction entityToAddress(uint256 entity) internal pure returns (address)

Turn an entity ID into its corresponding Ethereum address.

freeFunction

freeFunction addressToEntity(address addr) internal pure returns (uint256)

Turn an Ethereum address into its corresponding entity ID.

freeFunction

freeFunction getAddressById(contract IUint256Component registry, uint256 id) internal view returns (address)

Get an Ethereum address from an address/id registry component (like _components/_systems in World.sol)

freeFunction

freeFunction getIdByAddress(contract IUint256Component registry, address addr) internal view returns (uint256)

Get an entity id from an address/id registry component (like _components/_systems in World.sol)

freeFunction

freeFunction getComponentById(contract IUint256Component components, uint256 id) internal view returns (contract IComponent)

Get a Component from an address/id registry component (like _components in World.sol)

freeFunction

freeFunction getSystemAddressById(contract IUint256Component components, uint256 id) internal view returns (address)

Get the Ethereum address of a System from an address/id component registry component in which the System registry component is registered (like _components in World.sol)

freeFunction

freeFunction getSystemById(contract IUint256Component components, uint256 id) internal view returns (contract ISystem)

Get a System from an address/id component registry component in which the System registry component is registered (like _components in World.sol)

freeFunction

freeFunction split(bytes data, uint8[] lengths) internal pure returns (bytes[])

Split a single bytes blob into an array of bytes of the given length