コード例 #1
0
        public static EntityTemplate CreatePlayerEntityTemplate(string workerId, Improbable.Vector3f position)
        {
            var clientAttribute = $"workerId:{workerId}";

            var playerInput = PlayerInput.Component.CreateSchemaComponentData(0, 0, false);
            var launcher    = Launcher.Component.CreateSchemaComponentData(100, 0);

            var score       = Score.Component.CreateSchemaComponentData(0);
            var cubeSpawner = CubeSpawner.Component.CreateSchemaComponentData(new List <EntityId>());

            var entityBuilder = EntityBuilder.Begin()
                                .AddPosition(0, 0, 0, clientAttribute)
                                .AddMetadata("Character", WorkerUtils.UnityGameLogic)
                                .SetPersistence(false)
                                .SetReadAcl(WorkerUtils.AllWorkerAttributes)
                                .SetEntityAclComponentWriteAccess(WorkerUtils.UnityGameLogic)
                                .AddComponent(playerInput, clientAttribute)
                                .AddComponent(launcher, WorkerUtils.UnityGameLogic)
                                .AddComponent(score, WorkerUtils.UnityGameLogic)
                                .AddComponent(cubeSpawner, WorkerUtils.UnityGameLogic)
                                .AddTransformSynchronizationComponents(clientAttribute)
                                .AddPlayerLifecycleComponents(workerId, clientAttribute, WorkerUtils.UnityGameLogic);

            return(entityBuilder.Build());
        }
コード例 #2
0
        public static Entity CreatePlayerEntityTemplate(List <string> clientAttributeSet,
                                                        Improbable.Vector3f position)
        {
            var clientAttribute = clientAttributeSet.First(attribute => attribute != WorkerUtils.UnityClient);

            if (clientAttribute == null)
            {
                throw new InvalidOperationException(
                          $"Expected an attribute that is not \"{WorkerUtils.UnityClient}\" but none was found.");
            }

            var playerInput = PlayerInput.Component.CreateSchemaComponentData(0, 0, false);
            var launcher    = Launcher.Component.CreateSchemaComponentData(100, 0);

            var score       = Score.Component.CreateSchemaComponentData(0);
            var cubeSpawner = CubeSpawner.Component.CreateSchemaComponentData(new List <EntityId>());

            var entityBuilder = EntityBuilder.Begin()
                                .AddPosition(0, 0, 0, WorkerUtils.UnityGameLogic)
                                .AddMetadata("Character", WorkerUtils.UnityGameLogic)
                                .SetPersistence(false)
                                .SetReadAcl(WorkerUtils.AllWorkerAttributes)
                                .SetEntityAclComponentWriteAccess(WorkerUtils.UnityGameLogic)
                                .AddComponent(playerInput, clientAttribute)
                                .AddComponent(launcher, WorkerUtils.UnityGameLogic)
                                .AddComponent(score, WorkerUtils.UnityGameLogic)
                                .AddComponent(cubeSpawner, WorkerUtils.UnityGameLogic)
                                .AddTransformSynchronizationComponents(clientAttribute)
                                .AddPlayerLifecycleComponents(clientAttribute, WorkerUtils.UnityGameLogic);

            return(entityBuilder.Build());
        }
コード例 #3
0
        private static EntityTemplate CreatePlayerEntityTemplate(string workerId, Improbable.Vector3f position)
        {
            var clientAttribute = $"workerId:{workerId}";
            var serverAttribute = WorkerType;

            var entityBuilder = EntityBuilder.Begin()
                                .AddPosition(0, 0, 0, serverAttribute)
                                .AddMetadata("Player", serverAttribute)
                                .SetPersistence(false)
                                .SetReadAcl(AllWorkerAttributes)
                                .SetEntityAclComponentWriteAccess(serverAttribute)
                                .AddPlayerLifecycleComponents(workerId, clientAttribute, serverAttribute)
                                .AddTransformSynchronizationComponents(clientAttribute);

            return(entityBuilder.Build());
        }
コード例 #4
0
        public static Entity CreatePlayerEntityTemplate(List <string> clientAttributeSet,
                                                        Improbable.Vector3f position)
        {
            var clientAttribute = clientAttributeSet.First(attribute => attribute != WorkerUtils.UnityClient);

            if (clientAttribute == null)
            {
                throw new InvalidOperationException(
                          $"Expected an attribute that is not \"{WorkerUtils.UnityClient}\" but none was found.");
            }

            var transform =
                TransformInternal.Component.CreateSchemaComponentData(new Location(),
                                                                      new Quaternion {
                W = 1, X = 0, Y = 0, Z = 0
            }, new Velocity(0.0f, 0.0f, 0.0f), 0, 0.0f);
            var playerInput     = PlayerInput.Component.CreateSchemaComponentData(0, 0, false);
            var launcher        = Launcher.Component.CreateSchemaComponentData(100, 0);
            var clientHeartbeat = PlayerHeartbeatClient.Component.CreateSchemaComponentData();
            var serverHeartbeat = PlayerHeartbeatServer.Component.CreateSchemaComponentData();
            var score           = Score.Component.CreateSchemaComponentData(0);
            var cubeSpawner     = CubeSpawner.Component.CreateSchemaComponentData(new List <EntityId>());

            var entityBuilder = EntityBuilder.Begin()
                                .AddPosition(0, 0, 0, WorkerUtils.UnityGameLogic)
                                .AddMetadata("Character", WorkerUtils.UnityGameLogic)
                                .SetPersistence(false)
                                .SetReadAcl(WorkerUtils.AllWorkerAttributes)
                                .SetEntityAclComponentWriteAccess(WorkerUtils.UnityGameLogic)
                                .AddComponent(transform, clientAttribute)
                                .AddComponent(playerInput, clientAttribute)
                                .AddComponent(launcher, WorkerUtils.UnityGameLogic)
                                .AddComponent(clientHeartbeat, clientAttribute)
                                .AddComponent(serverHeartbeat, WorkerUtils.UnityGameLogic)
                                .AddComponent(score, WorkerUtils.UnityGameLogic)
                                .AddComponent(cubeSpawner, WorkerUtils.UnityGameLogic);

            return(entityBuilder.Build());
        }