// 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 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); }
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 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 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); }
// 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 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 CreatePlayerCreatorTemplate() { var entityTemplate = new SnapshotEntity { Prefab = SimulationSettings.PlayerCreatorPrefabName }; entityTemplate.Add(new WorldTransform.Data(Coordinates.ZERO, new Quaternion(0, 0, 0, 0))); entityTemplate.Add(new PlayerCreation.Data()); var acl = Acl.GenerateServerAuthoritativeAcl(entityTemplate); entityTemplate.SetAcl(acl); return(entityTemplate); }
public static SnapshotEntity CreateArmchairEntityTemplate(Coordinates spawnPosition, float rotation) { var entityTemplate = new SnapshotEntity { Prefab = SimulationSettings.ArmchairPrefabName }; entityTemplate.Add(new WorldTransform.Data(spawnPosition, MathUtils.ToNativeQuaternion(UnityEngine.Quaternion.Euler(0, rotation, 0)))); entityTemplate.Add(new Grabbable.Data(new Option <CurrentGrabberInfo>())); var acl = Acl.GenerateServerAuthoritativeAcl(entityTemplate); entityTemplate.SetAcl(acl); return(entityTemplate); }
public static SnapshotEntity CreateCubeEntityTemplate(Coordinates spawnPosition) { var entityTemplate = new SnapshotEntity { Prefab = SimulationSettings.CubePrefabName }; entityTemplate.Add(new WorldTransform.Data(spawnPosition, new Quaternion(0, 0, 0, 0))); entityTemplate.Add(new Grabbable.Data(new Option <CurrentGrabberInfo>())); var acl = Acl.GenerateServerAuthoritativeAcl(entityTemplate); entityTemplate.SetAcl(acl); return(entityTemplate); }
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); }
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); }
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); }
// Template definition for a Terrain entity public static SnapshotEntity GenerateTerrainSnapshotEntityTemplate() { // Set name of Unity prefab associated with this entity var terrain = new SnapshotEntity { Prefab = "Terrain" }; // Define components attached to snapshot entity terrain.Add(new Terrain.Data(new TerrainData())); terrain.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(5, 0, 0), 0))); // Grant FSim workers write-access over all of this entity's components, read-access for visual (e.g. client) workers var acl = Acl.GenerateServerAuthoritativeAcl(terrain); terrain.SetAcl(acl); return(terrain); }
// Template definition for a PlayerSpawner entity public static SnapshotEntity GeneratePlayerSpawnerSnapshotEntityTemplate() { // Set name of Unity prefab associated with this entity var playerSpawner = new SnapshotEntity { Prefab = "PlayerSpawner" }; // Define components attached to snapshot entity playerSpawner.Add(new WorldTransform.Data(new WorldTransformData(new Coordinates(0, 5, 0), new Vector3f(), 0.0f))); playerSpawner.Add(new Spawner.Data(new SpawnerData())); // Grant FSim (server-side) workers write-access over all of this entity's components, read-access for visual (e.g. client) workers var acl = Acl.GenerateServerAuthoritativeAcl(playerSpawner); playerSpawner.SetAcl(acl); return(playerSpawner); }
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 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); }
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); }
// Template definition for a Fish entity public static SnapshotEntity GenerateFishSnapshotEntityTemplate() { //Spawn to a random position Coordinates fishInitialCoordinates = new Coordinates(Random.Range(-tankSize, tankSize), Random.Range(0.0f, tankHeight), Random.Range(-tankSize, tankSize)); Vector3f fishInitialRotation = new Vector3f(Random.Range(-30, 30), Random.Range(-30, 30), Random.value * 360); //roll, pitch, yaw float speed = Random.Range(initialSpeed / 2.0f, initialSpeed); //float fishInitialSpeed = Random.Range (initialSpeed / 2.0f, initialSpeed); // Set name of Unity prefab associated with this entity var FishEntity = new SnapshotEntity { Prefab = "Fish" }; // Define components attached to snapshot entity FishEntity.Add(new WorldTransform.Data(new WorldTransformData(fishInitialCoordinates, fishInitialRotation, speed))); FishEntity.Add(new FishParameters.Data(new FishParametersData(numFish, initialSpeed, tankSize, tankHeight))); // Grant UnityWorker (server-side) workers write-access over all of this entity's components, read-access for visual (e.g. client) workers var acl = Acl.GenerateServerAuthoritativeAcl(FishEntity); //Alastair's recommendation: seems to have an issue /*var acl = Acl.Build() * .SetReadAccess(CommonRequirementSets.PhysicsOrVisual) * .SetWriteAccess<WorldTransform>(CommonRequirementSets.PhysicsOnly) * .SetWriteAccess<FishParameters>(CommonRequirementSets.PhysicsOnly);*/ FishEntity.SetAcl(acl); return(FishEntity); }
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); }
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); }
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); }