-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a bunch of WIP content to readme
- Loading branch information
Showing
1 changed file
with
63 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
# MatterReplication | ||
|
||
This package exposes the components and system building blocks necessary to create replicated entities in [Matter](https://eryn.io/matter/). | ||
[![CI](https://github.com/vocksel/matter-replication/actions/workflows/ci.yml/badge.svg)](https://github.com/vocksel/matter-replication/actions/workflows/ci.yml) | ||
[![Docs](https://img.shields.io/badge/docs-website-brightgreen)](https://vocksel.github.io/matter-replication) | ||
|
||
This package exposes the building blocks necessary to create replicated entities in [Matter](https://eryn.io/matter/). | ||
|
||
## What it does | ||
|
||
1. Allows you to specify the components you want to replicate to all clients when changes occur on the server | ||
2. Attaches a `ServerEntity` component to all entities that get replicated to make it easy to query on the client for any server-owned entities | ||
2. Attaches a `ServerEntity` component to all replicated entities so the client can query for server-owned entities | ||
|
||
## Installation | ||
|
||
### Wally (Recommended) | ||
|
||
MatterReplication can be installed with Wally by including it as a dependency in your `wally.toml` file. | ||
|
||
```toml | ||
[dependencies] | ||
MatterReplication = "vocksel/[email protected]" | ||
``` | ||
|
||
### Roblox Studio | ||
|
||
Download a copy of the rbxm from the [latest release](https://github.com/vocksel/matter-replication/releases/latest) under the Assets section, then drag and drop the file into Roblox Studio to add it to your experience. | ||
|
||
## Usage | ||
|
||
```lua | ||
local MatterReplication = require(ReplicatedStorage.Packages.MatterReplication) | ||
|
||
local Foo = require(ReplicatedStorage.Components.Foo) | ||
local Bar = require(ReplicatedStorage.Components.Bar) | ||
local Baz = require(ReplicatedStorage.Components.Baz) | ||
|
||
return MatterReplication.createReplicationSystem({ | ||
Foo, | ||
Bar, | ||
Baz | ||
}) | ||
``` | ||
|
||
## API | ||
|
||
|
@@ -16,8 +50,8 @@ This is a Matter component that gets automatically assigned to any entity that g | |
The following example is a client-side system that uses the `ServerEntity` component to apply a `ServerEntityId` Attribute to the common `Model` component paradigm. | ||
|
||
```lua | ||
local MatterReplication = require(Path.To.MatterReplication) | ||
local Model = require(Path.To.Components.Model) | ||
local MatterReplication = require(ReplicatedStorage.Packages.MatterReplication) | ||
local Model = require(ReplicatedStorage.Components.Model) | ||
|
||
local ServerEntity = MatterReplication.ServerEntity | ||
|
||
|
@@ -37,19 +71,30 @@ return updateEntityIdAttributes | |
Creates the replication system for use in your Matter loop. | ||
|
||
```lua | ||
-- src/systems/replication.lua | ||
local MatterReplication = require(Path.To.MatterReplication) | ||
|
||
local REPLICATED_COMPONENTS = { | ||
Path.To.Components.Foo, | ||
Path.To.Components.Bar, | ||
Path.To.Components.Baz, | ||
} | ||
|
||
local replicatedComponents = {} | ||
for _, component in REPLICATED_COMPONENTS do | ||
replicatedComponents[component.name] = require(component) | ||
end | ||
local MatterReplication = require(ReplicatedStorage.Packages.MatterReplication) | ||
|
||
local Foo = require(ReplicatedStorage.Components.Foo) | ||
local Bar = require(ReplicatedStorage.Components.Bar) | ||
local Baz = require(ReplicatedStorage.Components.Baz) | ||
|
||
return MatterReplication.createReplicationSystem({ | ||
-- The components you want to replicate go here | ||
Foo, | ||
Bar, | ||
Baz | ||
}) | ||
``` | ||
|
||
**`resolveServerId(world: World, serverId: number): number?`** | ||
|
||
Get the client ID associated with a `ServerEntity`. | ||
|
||
The entity IDs sent to the client from the server are typically server IDs. This function As such, this function can be used to resolve a server ID to the client ID for an entity. | ||
|
||
For a non-replicated component there will not be a client ID to work with, so in those cases this function returns `nil`. | ||
|
||
```lua | ||
local MatterReplication = require(ReplicatedStorage.Packages.MatterReplication) | ||
|
||
return MatterReplication.createReplicationSystem(replicatedComponents) | ||
-- TODO | ||
``` |