// Template definition for a Example entity public static SnapshotEntity GenerateExampleSnapshotEntityTemplate() { // Set name of Unity prefab associated with this entity var exampleEntity = new SnapshotEntity { Prefab = "ExampleEntity" }; // Define components attached to snapshot entity exampleEntity.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(0, 0, 0)))); exampleEntity.Add(new UnityName.Data(new UnityNameData("your_example_entity"))); exampleEntity.Add(new CppName.Data(new CppNameData("your_example_entity"))); var acl = Acl.Build() // Both FSim (server) workers and client workers granted read access over all states .SetReadAccess(Acl.MakeRequirementSet(CommonAttributeSets.Physics, CommonAttributeSets.Visual, Acl.MakeAttributeSet("cpp"))) // Only FSim workers granted write access over WorldTransform component .SetWriteAccess <WorldTransform>(CommonRequirementSets.PhysicsOnly) // Only client workers granted write access over Name component .SetWriteAccess <UnityName>(CommonRequirementSets.VisualOnly) .SetWriteAccess <CppName>(Acl.MakeRequirementSet(Acl.MakeAttributeSet("cpp"))); exampleEntity.SetAcl(acl); return(exampleEntity); }
public static SnapshotEntity CreateNPCWizardTemplate(Coordinates initialPosition, uint teamId) { var template = new SnapshotEntity { Prefab = SimulationSettings.NPCWizardPrefabName }; template.Add(new TransformComponent.Data(initialPosition, 0)); template.Add(new FSimAuthorityCheck.Data()); template.Add(new Health.Data(SimulationSettings.WizardMaxHealth, SimulationSettings.WizardMaxHealth, true)); template.Add(new Flammable.Data(false, true, FireEffectType.SMALL)); template.Add(new TargetNavigation.Data(NavigationState.INACTIVE, Vector3f.ZERO, EntityId.InvalidEntityId, 0f)); template.Add(new Spells.Data(new Map <SpellType, float> { { SpellType.LIGHTNING, 0f }, { SpellType.RAIN, 0f } }, true)); template.Add(new NPCWizard.Data(WizardFSMState.StateEnum.IDLE, EntityId.InvalidEntityId, SimulationSettings.InvalidPosition.ToVector3f())); template.Add(new TeamAssignment.Data(teamId)); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TargetNavigation>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Spells>(CommonPredicates.PhysicsOnly) .SetWriteAccess <NPCWizard>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamAssignment>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity CreateTreeTemplate(Coordinates initialPosition, uint initialRotation) { var template = new SnapshotEntity { Prefab = SimulationSettings.TreePrefabName }; template.Add(new FSimAuthorityCheck.Data()); template.Add(new TransformComponent.Data(initialPosition, initialRotation)); template.Add(new Harvestable.Data()); template.Add(new Health.Data(SimulationSettings.TreeMaxHealth, SimulationSettings.TreeMaxHealth, true)); template.Add(new Flammable.Data(false, true, FireEffectType.BIG)); template.Add(new TreeState.Data((TreeType)UnityEngine.Random.Range(0, 2), TreeFSMState.HEALTHY)); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Harvestable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TreeState>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity GeneratePlayerSnapshotEntityTemplate(string workerId) { // Set name of Unity prefab associated with this entity var playerEntity = new SnapshotEntity { Prefab = "PlayerPrefab" }; // Define componetns attached to snapshot entity playerEntity.Add( new PlayerComponent.Data( new PlayerComponentData( Coordinates.ZERO, playerEntity.DefaultTransformData(), playerEntity.DefaultTransformData(), playerEntity.DefaultTransformData() ) ) ); var specificClientPredicate = CommonPredicates.SpecificClientOnly(workerId); var acl = Acl.Build() // Both FSim (server) workers and client workers granted read access over all states .SetReadAccess(CommonPredicates.PhysicsOrVisual) // Only the local client worker (local authority) granted write access over PlayerComponent component .SetWriteAccess <PlayerComponent>(specificClientPredicate); playerEntity.SetAcl(acl); return(playerEntity); }
// Template definition for a Swarm Goal entity public static SnapshotEntity GenerateGoalSnapshotEntityTemplate() { //Spawn to a random position Coordinates goalInitialCoordinates = new Coordinates(Random.Range(-tankSize, tankSize), Random.Range(0.0f, tankHeight), Random.Range(-tankSize, tankSize)); Vector3f zero = new Vector3f(); // Set name of Unity prefab associated with this entity var SwarmGoalEntity = new SnapshotEntity { Prefab = "Goal" }; // Define components attached to snapshot entity SwarmGoalEntity.Add(new WorldTransform.Data(new WorldTransformData(goalInitialCoordinates, zero, 0.0f))); SwarmGoalEntity.Add(new GoalParameters.Data(new GoalParametersData(tankSize, tankHeight, goalSpeed))); //Alastair's recommendation: var acl = Acl.Build() .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) .SetWriteAccess <WorldTransform>(CommonRequirementSets.PhysicsOnly); SwarmGoalEntity.SetAcl(acl); return(SwarmGoalEntity); }
public static SnapshotEntity CreateHQTemplate(Coordinates initialPosition, uint initialRotation, uint teamId) { var template = new SnapshotEntity { Prefab = SimulationSettings.HQPrefabName }; template.Add(new FSimAuthorityCheck.Data()); template.Add(new HQInfo.Data(new List <EntityId>())); template.Add(new TransformComponent.Data(initialPosition, initialRotation)); template.Add(new Health.Data(SimulationSettings.HQMaxHealth, SimulationSettings.HQMaxHealth, true)); template.Add(new TeamAssignment.Data(teamId)); template.Add(new Flammable.Data(false, true, FireEffectType.BIG)); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <HQInfo>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamAssignment>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity CreateNPCLumberjackTemplate(Coordinates initialPosition, uint teamId) { var template = new SnapshotEntity { Prefab = SimulationSettings.NPCPrefabName }; template.Add(new TransformComponent.Data(initialPosition, 0)); template.Add(new FSimAuthorityCheck.Data()); template.Add(new Health.Data(SimulationSettings.LumberjackMaxHealth, SimulationSettings.LumberjackMaxHealth, true)); template.Add(new Flammable.Data(false, true, FireEffectType.SMALL)); template.Add(new TargetNavigation.Data(NavigationState.INACTIVE, Vector3f.ZERO, new EntityId(), 0f)); template.Add(new Inventory.Data(0)); template.Add(new NPCLumberjack.Data(LumberjackFSMState.StateEnum.IDLE, new EntityId(), SimulationSettings.InvalidPosition.ToVector3f())); template.Add(new TeamAssignment.Data(teamId)); var permissions = Acl.Build() .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <FSimAuthorityCheck>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <Health>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <Flammable>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <TargetNavigation>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <Inventory>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <NPCLumberjack>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <TeamAssignment>(CommonRequirementSets.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity CreateBarracksTemplate(Coordinates initialPosition, BarracksState barracksState, uint teamId) { var template = new SnapshotEntity { Prefab = SimulationSettings.BarracksPrefabName }; template.Add(new FSimAuthorityCheck.Data()); template.Add(new TransformComponent.Data(initialPosition, (uint)(UnityEngine.Random.value * 360))); template.Add(new BarracksInfo.Data(barracksState)); template.Add(new Health.Data(barracksState == BarracksState.CONSTRUCTION_FINISHED ? SimulationSettings.BarracksMaxHealth : 0, SimulationSettings.BarracksMaxHealth, true)); template.Add(new Flammable.Data(false, false, FireEffectType.BIG)); template.Add(new StockpileDepository.Data(barracksState == BarracksState.UNDER_CONSTRUCTION)); template.Add(new NPCSpawner.Data(barracksState == BarracksState.CONSTRUCTION_FINISHED, new Map <NPCRole, float> { { NPCRole.LUMBERJACK, 0f }, { NPCRole.WIZARD, 0f } })); template.Add(new TeamAssignment.Data(teamId)); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <BarracksInfo>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <StockpileDepository>(CommonPredicates.PhysicsOnly) .SetWriteAccess <NPCSpawner>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamAssignment>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity CreateIndividualTemplate(Coordinates initialPosition) { var template = new SnapshotEntity { Prefab = SimulationSettings.PlayerPrefabName }; template.Add(new TransformComponent.Data(initialPosition, (uint)0)); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
private static SnapshotEntity Spawner() { var exampleEntity = new SnapshotEntity { Prefab = "Spawner" }; exampleEntity.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(0, 0, 0)))); exampleEntity.Add(new SpawnComponent.Data(new SpawnComponentData())); var acl = Acl.Build() .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) .SetWriteAccess <WorldTransform>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <SpawnComponent>(CommonRequirementSets.PhysicsOnly); exampleEntity.SetAcl(acl); return(exampleEntity); }
public static SnapshotEntity GenerateEnvironmentNodeEntityTemplate(Coordinates position, Map <Evolution.Material, uint> initialResources) { var entity = new SnapshotEntity { Prefab = "EnvironmentNode" }; entity.Add(new Position.Data(new PositionData(position))); entity.Add(new Evolution.Environment.Resources.Data(new ResourcesData(initialResources))); var acl = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <Position>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Evolution.Environment.Resources>(CommonPredicates.PhysicsOrVisual); entity.SetAcl(acl); return(entity); }
public void ReleaseControl(EntityId entityId) { Debug.LogWarning("Server regaining control of: " + entityId); EntityAclWriter.Send( Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <EntityAcl>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Crate>(CommonPredicates.PhysicsOnly) .SetWriteAccess <WorldTransform>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Controllable>(CommonPredicates.PhysicsOnly) ); // Ensure crate is kinematic if (GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().isKinematic = false; } }
public void GainControl(EntityId entityId, string workerId) { Debug.LogWarning(workerId + " is attempting to gain control of: " + entityId); EntityAclWriter.Send( Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <EntityAcl>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Crate>(CommonPredicates.PhysicsOnly) .SetWriteAccess <WorldTransform>(CommonPredicates.SpecificClientOnly(workerId)) .SetWriteAccess <Controllable>(CommonPredicates.PhysicsOnly) ); // Ensure crate is kinematic if (!GetComponent <Rigidbody>().isKinematic) { GetComponent <Rigidbody>().isKinematic = true; } }
public static Entity CreateSpecatorPlayerTemplate(string clientId) { var entityTemplate = new SnapshotEntity { Prefab = SimulationSettings.SpectatorPlayerPrefabName }; entityTemplate.Add(new WorldTransform.Data(Coordinates.ZERO + new Vector3d(0, 4, 0), new Quaternion(0, 0, 0, 0))); entityTemplate.Add(new ClientAuthorityCheck.Data()); entityTemplate.Add(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout)); var acl = Acl.Build() .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) .SetWriteAccess <WorldTransform>(CommonRequirementSets.SpecificClientOnly(clientId)) .SetWriteAccess <ClientAuthorityCheck>(CommonRequirementSets.SpecificClientOnly(clientId)) .SetWriteAccess <ClientConnection>(CommonRequirementSets.PhysicsOnly); entityTemplate.SetAcl(acl); return(entityTemplate); }
// Template definition for a PlayerShip snapshot entity static public Entity GeneratePlayerShipEntityTemplate(string clientWorkerId, Coordinates initialPosition) { var playerEntityTemplate = new Entity(); // Define components attached to entity playerEntityTemplate.Add(new WorldTransform.Data(new WorldTransformData(initialPosition, 0))); playerEntityTemplate.Add(new PlayerLifecycle.Data(new PlayerLifecycleData(0, 3, 10))); playerEntityTemplate.Add(new ShipControls.Data(new ShipControlsData(0, 0))); // Grant component access permissions var acl = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <WorldTransform>(CommonPredicates.SpecificClientOnly(clientWorkerId)) .SetWriteAccess <ShipControls>(CommonPredicates.SpecificClientOnly(clientWorkerId)) .SetWriteAccess <PlayerLifecycle>(CommonPredicates.PhysicsOnly); playerEntityTemplate.SetAcl(acl); return(playerEntityTemplate); }
public static SnapshotEntity CreateSimulationManagerTemplate() { var template = new SnapshotEntity { Prefab = SimulationSettings.SimulationManagerEntityName }; template.Add(new TransformComponent.Data(Coordinates.ZERO, 0)); template.Add(new FSimAuthorityCheck.Data()); template.Add(new PlayerLifeCycle.Data(new Map <string, EntityId>())); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <PlayerLifeCycle>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static Entity CreatePlayerTemplate(string clientWorkerId, Coordinates initialPosition, uint teamId) { var template = new Entity(); template.Add(new ClientAuthorityCheck.Data()); template.Add(new FSimAuthorityCheck.Data()); template.Add(new TransformComponent.Data(initialPosition, 0)); template.Add(new PlayerInfo.Data(true, initialPosition)); template.Add(new PlayerControls.Data(initialPosition)); template.Add(new Health.Data(SimulationSettings.PlayerMaxHealth, SimulationSettings.PlayerMaxHealth, true)); template.Add(new Flammable.Data(false, true, FireEffectType.SMALL)); template.Add(new Spells.Data(new Map <SpellType, float> { { SpellType.LIGHTNING, 0f }, { SpellType.RAIN, 0f } }, true)); template.Add(new Inventory.Data(0)); template.Add(new Chat.Data()); template.Add(new Heartbeat.Data(SimulationSettings.HeartbeatMax)); template.Add(new TeamAssignment.Data(teamId)); template.Add(new Flammable.Data(false, true, FireEffectType.SMALL)); var specificClientPredicate = CommonPredicates.SpecificClientOnly(clientWorkerId); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <ClientAuthorityCheck>(specificClientPredicate) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <PlayerInfo>(CommonPredicates.PhysicsOnly) .SetWriteAccess <PlayerControls>(specificClientPredicate) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Spells>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Inventory>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Chat>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Heartbeat>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamAssignment>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity GenerateCrateEntityTemplate() { var crate = new SnapshotEntity { Prefab = "Crate" }; crate.Add(new Crate.Data(new CrateData())); crate.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(1, 6, 9), 0))); crate.Add(new Controllable.Data()); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <EntityAcl>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Crate>(CommonPredicates.PhysicsOnly) .SetWriteAccess <WorldTransform>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Controllable>(CommonPredicates.PhysicsOnly); crate.SetAcl(permissions); return(crate); }
public static SnapshotEntity CreateSimulationManagerEntitySnapshotTemplate(IList <Team> teams) { var template = new SnapshotEntity { Prefab = SimulationSettings.SimulationManagerEntityName }; template.Add(new TransformComponent.Data(Coordinates.ZERO, 0)); template.Add(new FSimAuthorityCheck.Data()); template.Add(new PlayerLifeCycle.Data()); template.Add(new TeamCollection.Data(new TeamCollectionData(new Improbable.Collections.List <Team>(teams)))); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <PlayerLifeCycle>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamCollection>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity CreateTreeTemplate(Coordinates initialPosition, uint initialRotation) { var template = new SnapshotEntity { Prefab = SimulationSettings.TreePrefabName }; template.Add(new TransformComponent.Data(new TransformComponentData(initialPosition, initialRotation))); template.Add(new Harvestable.Data(new HarvestableData(SimulationSettings.InitialResourceTotal))); template.Add(new Flammable.Data(new FlammableData(false, true, FireEffectType.SMALL))); template.Add(new TreeState.Data(new TreeStateData(TreeFSMState.HEALTHY))); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Harvestable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TreeState>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }
public static SnapshotEntity GenerateOrganismEntityTemplate(Coordinates position, Genome genome1, Genome genome2, int[][] genomeKey) { var entity = new SnapshotEntity { Prefab = "OrganismPrefab" }; //Debug.Log(position); entity.Add(new Health.Data(new HealthData(50))); string dominantGenome = mixGenes(genome1, genome2); BitArray phenotype = new BitArray(Convert.FromBase64String(dominantGenome)); var food = getFood(phenotype, genomeKey[0]); entity.Add(new Consumer.Data( new ConsumerData(food, getWaste(food), getRadius(phenotype, genomeKey[2])) )); entity.Add(new Reproducer.Data(new ReproducerData(genome1, genome2))); entity.Add(new Mover.Data(new MoverData(position, getSpeed(phenotype, genomeKey[3]), 0.0f, 10))); entity.Add(new Affectable.Data( new AffectableData(getLimits(phenotype, genomeKey), getMutationP(phenotype, genomeKey[7])) )); var acl = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Consumer>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Reproducer>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Mover>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Affectable>(CommonPredicates.PhysicsOnly); entity.SetAcl(acl); return(entity); }
// Template definition for a Player snapshot entity static public Entity GeneratePlayerEntityTemplate(string clientWorkerId, Coordinates initialPosition) { Vector3f playerInitialRotation = new Vector3f(0.0f, 0.0f, 0.0f); var playerEntityTemplate = new Entity(); // Define components attached to entity playerEntityTemplate.Add(new WorldTransform.Data(new WorldTransformData(initialPosition, playerInitialRotation, 0))); playerEntityTemplate.Add(new PlayerLifecycle.Data(new PlayerLifecycleData(0, 3, 10))); //No missed heartbeats, upto 3 missed Hbs allowed, HB interval = 10 playerEntityTemplate.Add(new PlayerControls.Data(new PlayerControlsData(0, 0, 0, 0))); // Grant component access permissions var acl = Acl.Build() .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) //Both Server and Client workers have read access to all the components of PlayerShip .SetWriteAccess <WorldTransform> (CommonRequirementSets.SpecificClientOnly(clientWorkerId)) //only UnityClient has access .SetWriteAccess <PlayerControls> (CommonRequirementSets.SpecificClientOnly(clientWorkerId)) //only UnityClient has access .SetWriteAccess <PlayerLifecycle>(CommonRequirementSets.PhysicsOnly); //UnityWorker has access playerEntityTemplate.SetAcl(acl); return(playerEntityTemplate); }
public static Entity CreateVrPlayerTemplate(string clientId) { var entityTemplate = new SnapshotEntity { Prefab = SimulationSettings.VrPlayerPrefabName }; entityTemplate.Add(new WorldTransform.Data(Coordinates.ZERO, new Quaternion(0, 0, 0, 0))); entityTemplate.Add(new VRPeripheralOffsets.Data(new TransformOffset(Vector3f.ZERO, Vector3f.ZERO), new TransformOffset(Vector3f.ZERO, Vector3f.ZERO), new TransformOffset(Vector3f.ZERO, Vector3f.ZERO))); entityTemplate.Add(new ClientAuthorityCheck.Data()); entityTemplate.Add(new ClientConnection.Data(SimulationSettings.TotalHeartbeatsBeforeTimeout)); entityTemplate.Add(new Grab.Data(new Map <ControllerSide, EntityId>())); var acl = Acl.Build() .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) .SetWriteAccess <WorldTransform>(CommonRequirementSets.SpecificClientOnly(clientId)) .SetWriteAccess <VRPeripheralOffsets>(CommonRequirementSets.SpecificClientOnly(clientId)) .SetWriteAccess <ClientAuthorityCheck>(CommonRequirementSets.SpecificClientOnly(clientId)) .SetWriteAccess <ClientConnection>(CommonRequirementSets.PhysicsOnly) .SetWriteAccess <Grab>(CommonRequirementSets.SpecificClientOnly(clientId)); entityTemplate.SetAcl(acl); return(entityTemplate); }
public static SnapshotEntity CreateNPCLumberjackTemplate(Coordinates initialPosition, uint teamId) { var template = new SnapshotEntity { Prefab = SimulationSettings.NPCPrefabName }; template.Add(new TransformComponent.Data(initialPosition, 0)); template.Add(new FSimAuthorityCheck.Data()); template.Add(new Health.Data(SimulationSettings.LumberjackMaxHealth, SimulationSettings.LumberjackMaxHealth, true)); template.Add(new Flammable.Data(false, true, FireEffectType.SMALL)); template.Add(new TargetNavigation.Data(false, new Option <Coordinates>(), new Option <EntityId>())); template.Add(new Inventory.Data(0)); template.Add(new NPCLumberjack.Data( currentState: LumberjackFSMState.StateEnum.IDLE, targetEntity: EntityId.InvalidEntityId, npcRole: new NPCRole(NPCRoleEnum.LUMBERJACK))); template.Add(new TeamAssignment.Data(new TeamAssignmentData(teamId))); template.Add(new TeamKnowledge.Data(new Improbable.Collections.List <Coordinates>(SimulationSettings.TeamHQLocations))); var permissions = Acl.Build() .SetReadAccess(CommonPredicates.PhysicsOrVisual) .SetWriteAccess <TransformComponent>(CommonPredicates.PhysicsOnly) .SetWriteAccess <FSimAuthorityCheck>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Health>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Flammable>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TargetNavigation>(CommonPredicates.PhysicsOnly) .SetWriteAccess <Inventory>(CommonPredicates.PhysicsOnly) .SetWriteAccess <NPCLumberjack>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamAssignment>(CommonPredicates.PhysicsOnly) .SetWriteAccess <TeamKnowledge>(CommonPredicates.PhysicsOnly); template.SetAcl(permissions); return(template); }