Skip to content
This repository was archived by the owner on Dec 5, 2018. It is now read-only.

Commit 185d8f5

Browse files
Added example component with write-access to example entity
Workers will not check any entities out unless they have write-access to at least one component on an entity, which is handled by the Name component added as an example
1 parent f117384 commit 185d8f5

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
package improbable.player;
1+
package improbable.player;
2+
3+
component Name {
4+
// Schema file ID, unique within the project
5+
id = 1001;
6+
7+
string entity_name = 1;
8+
}

snapshots/initial_world.snapshot

28 Bytes
Binary file not shown.

workers/unity/Assets/EntityTemplates/ExampleEntityTemplate.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Improbable.General;
22
using Improbable.Worker;
33
using Improbable.Math;
4+
using Improbable.Player;
45
using Improbable.Unity.Core.Acls;
56
using UnityEngine;
67

@@ -16,9 +17,16 @@ public static SnapshotEntity GenerateExampleSnapshotEntityTemplate()
1617

1718
// Define components attached to snapshot entity
1819
exampleEntity.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(-5, 10, 0))));
20+
exampleEntity.Add(new Name.Data(new NameData("your_example_entity")));
21+
22+
var acl = Acl.Build()
23+
// Both FSim (server) workers and client workers granted read access over all states
24+
.SetReadAccess(CommonPredicates.PhysicsOrVisual)
25+
// Only FSim workers granted write access over WorldTransform component
26+
.SetWriteAccess<WorldTransform>(CommonPredicates.PhysicsOnly)
27+
// Only client workers granted write access over Name component
28+
.SetWriteAccess<Name>(CommonPredicates.VisualOnly);
1929

20-
// Grant FSim (server-side) workers write-access over all of this entity's components, read-access for visual (e.g. client) workers
21-
var acl = Acl.GenerateServerAuthoritativeAcl(exampleEntity);
2230
exampleEntity.SetAcl(acl);
2331

2432
return exampleEntity;

0 commit comments

Comments
 (0)