Example #1
0
        public static Entity CreateArmchairEntityTemplate(Improbable.Coordinates spawnPosition, float rotation)
        {
            var entityTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(spawnPosition.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.ArmchairPrefabName)
                                 .SetPersistence(true)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.Euler(0, rotation, 0).ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Grabbable.Data(new Option <CurrentGrabberInfo>()), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(entityTemplate);
        }
        private static void AddPlayerSpawner(Snapshot snapshot)
        {
            var playerCreator = PlayerCreator.Component.CreateSchemaComponentData();
            var spawner       = EntityBuilder.Begin()
                                .AddPosition(0, 0, 0, WorkerUtils.UnityGameLogic)
                                .AddMetadata("PlayerCreator", WorkerUtils.UnityGameLogic)
                                .SetPersistence(true)
                                .SetReadAcl(WorkerUtils.AllWorkerAttributes)
                                .AddComponent(playerCreator, WorkerUtils.UnityGameLogic)
                                .Build();

            snapshot.AddEntity(spawner);
        }
Example #3
0
        private static void AddPlayerSpawner(Snapshot snapshot)
        {
            var playerCreator = SpatialOSPlayerCreator.CreateSchemaComponentData();
            var spawner       = EntityBuilder.Begin()
                                .AddPosition(0, 0, 0, SystemConfig.UnityGameLogic)
                                .AddMetadata("PlayerCreator", SystemConfig.UnityGameLogic)
                                .SetPersistence(true)
                                .SetReadAcl(UnityWorkers)
                                .AddComponent(playerCreator, SystemConfig.UnityGameLogic)
                                .Build();

            snapshot.AddEntity(spawner);
        }
        // Defines the template for the PlayerCreator entity.
        public static Entity CreatePlayerCreatorTemplate()
        {
            var playerCreatorEntityTemplate = EntityBuilder.Begin()
                                              // Add components to the entity, then set the access permissions for the component on the entity relative to the client or server worker ids.
                                              .AddPositionComponent(new Vector3(-5, 0, 0), CommonRequirementSets.PhysicsOnly)
                                              .AddMetadataComponent(SimulationSettings.PlayerCreatorPrefabName)
                                              .SetPersistence(true)
                                              .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                              .AddComponent(new PlayerCreation.Data(), CommonRequirementSets.PhysicsOnly)
                                              .Build();

            return(playerCreatorEntityTemplate);
        }
        // Defines the template for the pirate ship entity
        public static Entity CreatePirateEntityTemplate(Vector3 initialPosition, uint initialRotation)
        {
            var pirateEntityTemplate = EntityBuilder.Begin()
                                       .AddPositionComponent(initialPosition, CommonRequirementSets.PhysicsOnly)
                                       .AddMetadataComponent(SimulationSettings.PirateShipPrefabName)
                                       .SetPersistence(true)
                                       .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                       .AddComponent(new Rotation.Data(initialRotation), CommonRequirementSets.PhysicsOnly)
                                       .AddComponent(new ShipControls.Data(0, 0), CommonRequirementSets.PhysicsOnly)
                                       .Build();

            return(pirateEntityTemplate);
        }
Example #6
0
    public static Entity CreateDroneTemplate(Improbable.Coordinates spawnPoint, Vector3f initialTarget, EntityId controller, float payloadWeight, float droneSpeed = SimulationSettings.MaxDroneSpeed)
    {
        var droneTemplate = EntityBuilder.Begin()
                            .AddPositionComponent(spawnPoint.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                            .AddMetadataComponent(entityType: SimulationSettings.DronePrefabName)
                            .SetPersistence(true)
                            .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                            .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                            .AddComponent(new DroneData.Data(initialTarget, Mathf.Min(SimulationSettings.MaxDroneSpeed, droneSpeed), new Vector3f(), TargetPending.REQUEST, DroneStatus.MOVE, 0, payloadWeight, new Vector3f(0, -1, 0), controller), CommonRequirementSets.PhysicsOnly)
                            .Build();

        return(droneTemplate);
    }
        public static Entity CreateNoticeTemplate(string text, Coordinates coordinates)
        {
            var noticeTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(coordinates.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.NoticePrefabName)
                                 .SetPersistence(true)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Notice.Data(text), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(noticeTemplate);
        }
        public static Entity CreatePlayerCreatorTemplate()
        {
            var playerCreatorEntityTemplate = EntityBuilder.Begin()
                                              .AddPositionComponent(Improbable.Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                              .AddMetadataComponent(entityType: SimulationSettings.PlayerCreatorPrefabName)
                                              .SetPersistence(true)
                                              .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                              .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(new PlayerCreation.Data(), CommonRequirementSets.PhysicsOnly)
                                              .Build();

            return(playerCreatorEntityTemplate);
        }
        public static Entity CreateTileTemplate(Vector3 position)
        {
            var tileTemplate = EntityBuilder.Begin()
                               .AddPositionComponent(position, CommonRequirementSets.PhysicsOnly)
                               .AddMetadataComponent(entityType: SimulationSettings.TilePrefabName)
                               .SetPersistence(true)
                               .SetReadAcl(Acl.MakeRequirementSet(CommonAttributeSets.Physics, CommonAttributeSets.Visual, Acl.MakeAttributeSet("turret_rotation")))
                               .AddComponent(new Improbable.Demo.PositionColor.Data(0), CommonRequirementSets.PhysicsOnly)
                               .AddComponent(new Improbable.Demo.CheckOutColor.Data(new List <uint>()), CommonRequirementSets.PhysicsOnly)
                               .Build();

            return(tileTemplate);
        }
        // Template definition for a LargeFish snapshot entity
        static public Entity GenerateLargeFishTemplate(Vector3 initialPosition)
        {
            var largeFishTemplate = EntityBuilder.Begin()
                                    // Add components to the entity, then set the access permissions for the component on the entity relative to the client or server worker ids.
                                    .AddPositionComponent(initialPosition, CommonRequirementSets.PhysicsOnly)
                                    .AddMetadataComponent(SimulationSettings.LargeFishPrefabName)
                                    .SetPersistence(true)
                                    .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                    .AddComponent(new Rotation.Data(0), CommonRequirementSets.PhysicsOnly)
                                    .Build();

            return(largeFishTemplate);
        }
        public static Entity CreatePlayerCreatorTemplate()
        {
            var playerCreatorEntityTemplate = EntityBuilder.Begin()
                                              .AddPositionComponent(new Improbable.Coordinates(0, SimulationSettings.PlayerSpawnHeight, 0).ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                              .AddMetadataComponent(entityType: SimulationSettings.PlayerCreatorPrefabName)
                                              .SetPersistence(true)
                                              .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                              .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(new PlayerCreation.Data(), CommonRequirementSets.PhysicsOnly)
                                              //	.AddComponent(new PlayerInput.Data(new Joystick(0, 0)), CommonRequirementSets.SpecificClientOnly(clientId))
                                              .Build();

            return(playerCreatorEntityTemplate);
        }
        public static Entity CreatePlayerSpawnerTemplate()
        {
            var template = EntityBuilder.Begin()
                           .AddPositionComponent(Vector3.zero, CommonRequirementSets.PhysicsOnly)
                           .AddMetadataComponent(SimulationSettings.PlayerSpawnerPrefabName)
                           .SetPersistence(true)
                           .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                           .AddComponent(new TransformComponent.Data(0), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new UnityWorkerAuthorityCheck.Data(), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new PlayerSpawning.Data(), CommonRequirementSets.PhysicsOnly)
                           .Build();

            return(template);
        }
Example #13
0
        public static EntityTemplate Player(string workerId, Vector3f position)
        {
            const string gameLogic = WorkerUtils.UnityGameLogic;
            var          client    = $"workerId:{workerId}";

            var(spawnPosition, spawnYaw, spawnPitch) = SpawnPoints.GetRandomSpawnPoint();

            var serverResponse = new ServerResponse
            {
                Position = spawnPosition.ToIntAbsolute()
            };

            var serverMovement     = ServerMovement.Component.CreateSchemaComponentData(serverResponse);
            var clientMovementData = new ClientRequest();
            var rotationUpdate     = new RotationUpdate
            {
                Yaw   = spawnYaw.ToInt1k(),
                Pitch = spawnPitch.ToInt1k()
            };
            var clientMovement    = ClientMovement.Component.CreateSchemaComponentData(clientMovementData);
            var clientRotation    = ClientRotation.Component.CreateSchemaComponentData(rotationUpdate);
            var shootingComponent = ShootingComponent.Component.CreateSchemaComponentData();
            var gunStateComponent = GunStateComponent.Component.CreateSchemaComponentData(false);
            var gunComponent      = GunComponent.Component.CreateSchemaComponentData(PlayerGunSettings.DefaultGunIndex);
            var maxHealth         = PlayerHealthSettings.MaxHealth;

            var healthComponent      = HealthComponent.Component.CreateSchemaComponentData(maxHealth, maxHealth);
            var healthRegenComponent = HealthRegenComponent.Component.CreateSchemaComponentData(false,
                                                                                                0,
                                                                                                PlayerHealthSettings.SpatialCooldownSyncInterval,
                                                                                                PlayerHealthSettings.RegenAfterDamageCooldown,
                                                                                                PlayerHealthSettings.RegenInterval,
                                                                                                PlayerHealthSettings.RegenAmount);

            return(EntityBuilder.Begin()
                   .AddPosition(spawnPosition.x, spawnPosition.y, spawnPosition.z, gameLogic)
                   .AddMetadata("Player", gameLogic)
                   .SetPersistence(false)
                   .SetReadAcl(AllWorkerAttributes)
                   .AddComponent(serverMovement, gameLogic)
                   .AddComponent(clientMovement, client)
                   .AddComponent(clientRotation, client)
                   .AddComponent(shootingComponent, client)
                   .AddComponent(gunComponent, gameLogic)
                   .AddComponent(gunStateComponent, client)
                   .AddComponent(healthComponent, gameLogic)
                   .AddComponent(healthRegenComponent, gameLogic)
                   .AddPlayerLifecycleComponents(workerId, client, gameLogic)
                   .Build());
        }
Example #14
0
    public static Entity CreateSchedulerTemplate(Vector3 spawnPoint, int firstController, int lastController, List <Improbable.Controller.NoFlyZone> nfzs, List <ControllerInfo> controllers)
    {
        var schedulerTemplate = EntityBuilder.Begin()
                                .AddPositionComponent(spawnPoint, CommonRequirementSets.PhysicsOnly)
                                .AddMetadataComponent(entityType: SimulationSettings.SchedulerPrefabName)
                                .SetPersistence(true)
                                .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new OrderGeneratorComponent.Data(firstController, lastController, 0, nfzs, controllers), CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new OrderGeneratorMetrics.Data(0, 0, 0), CommonRequirementSets.PhysicsOnly)
                                .Build();

        return(schedulerTemplate);
    }
        public static Entity CreatePlayerTemplate(string clientId)
        {
            var playerTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(Improbable.Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.PlayerPrefabName)
                                 .SetPersistence(false)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ClientAuthorityCheck.Data(), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(playerTemplate);
        }
Example #16
0
        public static Entity CreateAlienTemplate(Vector3 initialPosition, float rotation)
        {
            var alienTemplate = EntityBuilder.Begin()
                                .AddPositionComponent(new Improbable.Coordinates(initialPosition.x, SimulationSettings.PlayerSpawnHeight, initialPosition.z).ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                .AddMetadataComponent(entityType: SimulationSettings.AlienPrefabName)
                                .SetPersistence(true)
                                .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new PlayerInput.Data(new Joystick(xAxis: 0, yAxis: 0)), CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new PlayerRotation.Data(rotation), CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new Health.Data(1000), CommonRequirementSets.PhysicsOnly)
                                .Build();

            return(alienTemplate);
        }
Example #17
0
        private static void AddPlayerSpawner(Snapshot snapshot)
        {
            var playerCreator   = PlayerCreator.Component.CreateSchemaComponentData();
            var serverAttribute = UnityGameLogicConnector.WorkerType;

            var spawner = EntityBuilder.Begin()
                          .AddPosition(0, 0, 0, serverAttribute)
                          .AddMetadata("PlayerCreator", serverAttribute)
                          .SetPersistence(true)
                          .SetReadAcl(UnityWorkers)
                          .AddComponent(playerCreator, serverAttribute)
                          .Build();

            snapshot.AddEntity(spawner);
        }
        public static Entity CreatePlayerCreatorTemplate(IComponentData <PlatformPosition> platformPosiionData)
        {
            var playerCreatorEntityTemplate = EntityBuilder.Begin()
                                              .AddPositionComponent(Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                              .AddMetadataComponent(entityType: SimulationSettings.PlayerCreatorPrefabName)
                                              .SetPersistence(true)
                                              .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                              .AddComponent(new Rotation.Data(UnityEngine.Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(new PlayerCreation.Data(), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(new ClientEntityStore.Data(new Map <string, EntityId>()), CommonRequirementSets.PhysicsOnly)
                                              .AddComponent(platformPosiionData, CommonRequirementSets.PhysicsOnly)
                                              .Build();

            return(playerCreatorEntityTemplate);
        }
Example #19
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());
        }
Example #20
0
        // Defines the template for the PlayerShip entity.
        public static Entity CreatePlayerShipTemplate(string clientWorkerId, Vector3 initialPosition)
        {
            var playerEntityTemplate = EntityBuilder.Begin()
                                       // Add components to the entity, then set the access permissions for the component on the entity relative to the client or server worker ids.
                                       .AddPositionComponent(initialPosition, CommonRequirementSets.SpecificClientOnly(clientWorkerId))
                                       .AddMetadataComponent(SimulationSettings.PlayerShipPrefabName)
                                       .SetPersistence(false)
                                       .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                       .AddComponent(new Rotation.Data(0), CommonRequirementSets.SpecificClientOnly(clientWorkerId))
                                       .AddComponent(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout), CommonRequirementSets.PhysicsOnly)
                                       .AddComponent(new ShipControls.Data(0, 0), CommonRequirementSets.SpecificClientOnly(clientWorkerId))
                                       .AddComponent(new ClientAuthorityCheck.Data(), CommonRequirementSets.SpecificClientOnly(clientWorkerId))
                                       .Build();

            return(playerEntityTemplate);
        }
        public static Entity CreateArrowTemplate(EntityId owner, Coordinates coordinates, Coordinates angle)
        {
            var arrowTemplate = EntityBuilder.Begin()
                                .AddPositionComponent(coordinates.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                .AddMetadataComponent(entityType: SimulationSettings.ArrowPrefabName)
                                .SetPersistence(true)
                                .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                //.AddComponent(new Rotation.Data(SimulationSettings.PlayerRotation.ToNativeQuaternion()),
                                //  CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new Rotation.Data((Quaternion.Euler(angle.ToUnityVector())).ToNativeQuaternion()),
                                              CommonRequirementSets.PhysicsOnly)
                                .AddComponent(new Owner.Data(owner), CommonRequirementSets.PhysicsOnly)
                                .Build();

            return(arrowTemplate);
        }
Example #22
0
        public static Entity CreatePlayerTemplate(string clientId, Vector3 initialPosition)
        {
            var playerTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(initialPosition, CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.PlayerPrefabName)
                                 .SetPersistence(false)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ClientAuthorityCheck.Data(), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new PlayerInput.Data(new Joystick(xAxis: 0, yAxis: 0)), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new Touching.Data(), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Health.Data(100), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(playerTemplate);
        }
        public static Entity CreatePlayerTemplate(string clientId, EntityId playerCreatorId, IComponentData <PlatformPosition> platformPosiionData)
        {
            var playerTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(Coordinates.ZERO.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.PlayerPrefabName)
                                 .SetPersistence(false)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(UnityEngine.Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ClientAuthorityCheck.Data(), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout, clientId, playerCreatorId), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new WalkControls.Data(new Vector3f(0.0f, 0.0f, 0.0f)), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new PilotControls.Data(0.0f, 0.0f, false), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(platformPosiionData, CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(playerTemplate);
        }
        public static Entity CreateIslandTemplate(double x, double z, string name)
        {
            // TODO - Only one Island...
            var position = new Coordinates(x, 0.0f, z).ToUnityVector();

            var islandTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(position, CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.IslandPrefabName)
                                 .SetPersistence(true)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(UnityEngine.Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new IslandMetadata.Data(name), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new PlatformBounds.Data(-30.0f, 30.0f, -20.0f, 20.0f), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(islandTemplate);
        }
        public static Entity CreateHQTemplate(Coordinates initialPosition, uint initialRotation, uint teamId)
        {
            var template = EntityBuilder.Begin()
                           .AddPositionComponent(initialPosition.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                           .AddMetadataComponent(SimulationSettings.HQPrefabName)
                           .SetPersistence(true)
                           .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                           .AddComponent(new UnityWorkerAuthorityCheck.Data(), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new HQInfo.Data(new List <EntityId>()), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new TransformComponent.Data(initialRotation), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new Health.Data(SimulationSettings.HQMaxHealth, SimulationSettings.HQMaxHealth, true), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new TeamAssignment.Data(teamId), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new Flammable.Data(false, true, FireEffectType.BIG), CommonRequirementSets.PhysicsOnly)
                           .Build();

            return(template);
        }
        public static Entity CreateTreeTemplate(Coordinates initialPosition, uint initialRotation)
        {
            var template = EntityBuilder.Begin()
                           .AddPositionComponent(initialPosition.ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                           .AddMetadataComponent(SimulationSettings.TreePrefabName)
                           .SetPersistence(true)
                           .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                           .AddComponent(new UnityWorkerAuthorityCheck.Data(), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new TransformComponent.Data(initialRotation), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new Harvestable.Data(), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new Health.Data(SimulationSettings.TreeMaxHealth, SimulationSettings.TreeMaxHealth, true), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new Flammable.Data(false, true, FireEffectType.BIG), CommonRequirementSets.PhysicsOnly)
                           .AddComponent(new TreeState.Data((TreeType)Random.Range(0, 2), TreeFSMState.HEALTHY), CommonRequirementSets.PhysicsOnly)
                           .Build();

            return(template);
        }
        public void EntityBuilder_should_Build_if_only_position_is_added()
        {
            var builder = EntityBuilder.Begin();

            builder.AddPosition(0, 0, 0, "write-access");

            var template = new EntityTemplate(new Entity()); // Stops IDE complaining about null check below.

            // Wrap in try - finally to ensure dispose gets called even if the assert fails.
            try
            {
                Assert.DoesNotThrow(() => template = builder.Build());
            }
            finally
            {
                template.Dispose();
            }
        }
        // pirate template
        public static Entity CreatePirateEntityTemplate(Vector3 initialPosition, uint initialRotation)
        {
            var pirateEntityTemplate = EntityBuilder.Begin()
                                       .AddPositionComponent(initialPosition, CommonRequirementSets.PhysicsOnly)
                                       // unity prefab - to create the unity game object
                                       .AddMetadataComponent(SimulationSettings.PirateShipPrefabName)
                                       .SetPersistence(true)
                                       // any worker, server (physics) or client (visual) can read
                                       .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                       // movement components
                                       .AddComponent(new Rotation.Data(initialRotation), CommonRequirementSets.PhysicsOnly)
                                       .AddComponent(new ShipControls.Data(0, 0), CommonRequirementSets.PhysicsOnly)
                                       .AddComponent(new Health.Data(1000), CommonRequirementSets.PhysicsOnly)
                                       // done
                                       .Build();

            return(pirateEntityTemplate);
        }
        public static Entity CreatePlayerTemplate(string clientId)
        {
            var playerTemplate = EntityBuilder.Begin()
                                 .AddPositionComponent(new Improbable.Coordinates(0, 2, 0).ToUnityVector(), CommonRequirementSets.PhysicsOnly)
                                 .AddMetadataComponent(entityType: SimulationSettings.PlayerPrefabName)
                                 .SetPersistence(false)
                                 .SetReadAcl(CommonRequirementSets.PhysicsOrVisual)
                                 .AddComponent(new Rotation.Data(Quaternion.identity.ToNativeQuaternion()), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new ClientAuthorityCheck.Data(), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new PlayerInput.Data(new Joystick(xAxis: 0, yAxis: 0, shift: false, w: false, s: false, space: false)), CommonRequirementSets.SpecificClientOnly(clientId))
                                 .AddComponent(new Health.Data(health: 100), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Scores.Data(scores: 0), CommonRequirementSets.PhysicsOnly)
                                 .AddComponent(new Death.Data(death: false), CommonRequirementSets.PhysicsOnly)
                                 .Build();

            return(playerTemplate);
        }
        public static Entity CreateNodeTemplate(List <EntityId> networks)
        {
            var graphTierAttributeSet = Acl.MakeAttributeSet("graphtier");
            var visualAttributeSet    = Acl.MakeAttributeSet("visual");

            var template =
                EntityBuilder.Begin()
                .AddPositionComponent(new Coordinates(0, 0, -10).ToUnityVector(),
                                      Acl.MakeRequirementSet(graphTierAttributeSet))
                .AddMetadataComponent("Node")
                .SetPersistence(true)
                .SetReadAcl(Acl.MakeRequirementSet(graphTierAttributeSet, visualAttributeSet))
                .AddComponent(new NodeCommands.Data(), Acl.MakeRequirementSet(graphTierAttributeSet))
                .AddComponent(new NodeData.Data(networks), Acl.MakeRequirementSet(graphTierAttributeSet))
                .Build();

            return(template);
        }