public override IComponent CreateComponent() { var container = new ComponentGroup("Content"); container.ContainerType = ContainerType.System; foreach (var slice in _slices.OrderByDescending(x => x.Order)) { var listComponent = new ContentSliceComponent { Heading = slice.Name }; listComponent.Settings["queryName"] = slice.Name; listComponent.Settings["heading"] = slice.Name; listComponent.Settings["createOptions"] = slice.CreateOptions; var sortableSlice = slice as ISortableContentSlice; if (sortableSlice != null) { listComponent.Settings["sortOptions"] = sortableSlice.SortOptions; listComponent.Settings["defaultSortOption"] = sortableSlice.DefaultSortOption; listComponent.Settings["hideSortOptions"] = sortableSlice.HideSortOptions; } container.Add(listComponent); } return container; }
ComponentGroup CreateComponentGroup(Type type) { var group = new ComponentGroup(type); for (int i = 0; i < allComponents.Count; i++) group.TryAddComponent(allComponents[i]); return group; }
// struct PlaneWaveTagGroup { // [ReadOnly] public ComponentDataArray<PlaneWaveTag> planeWaveTag; // public TransformAccessArray transformsAccess; // } // [Inject] PlaneWaveTagGroup planeWaveTagGroup; protected override void OnCreateManager(int capacity) { transformGroup = GetComponentGroup(ComponentType.Create <Transform> (), ComponentType.ReadOnly <PlaneWaveTag> ()); positionGroup = GetComponentGroup(ComponentType.Create <Position> (), ComponentType.ReadOnly <PlaneWaveTag> ()); }
public override void SendCommands(ComponentGroup commandGroup, ComponentSystemBase system, global::Improbable.Worker.Core.Connection connection) { Profiler.BeginSample("ComponentWithNoFieldsWithCommands"); var entityType = system.GetArchetypeChunkEntityType(); { var senderType = system.GetArchetypeChunkComponentType <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandSenders.Cmd>(true); var responderType = system.GetArchetypeChunkComponentType <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.CommandResponders.Cmd>(true); var chunks = commandGroup.CreateArchetypeChunkArray(Allocator.TempJob); foreach (var chunk in chunks) { var entities = chunk.GetNativeArray(entityType); var senders = chunk.GetNativeArray(senderType); var responders = chunk.GetNativeArray(responderType); for (var i = 0; i < senders.Length; i++) { var requests = senders[i].RequestsToSend; var responses = responders[i].ResponsesToSend; if (requests.Count > 0) { foreach (var request in requests) { var schemaCommandRequest = new global::Improbable.Worker.Core.SchemaCommandRequest(ComponentId, 1); global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Serialize(request.Payload, schemaCommandRequest.GetObject()); var requestId = connection.SendCommandRequest(request.TargetEntityId, new global::Improbable.Worker.Core.CommandRequest(schemaCommandRequest), request.TimeoutMillis, request.AllowShortCircuiting ? ShortCircuitParameters : null); cmdStorage.CommandRequestsInFlight[requestId.Id] = new CommandRequestStore <global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty>(entities[i], request.Payload, request.Context, request.RequestId); } requests.Clear(); } if (responses.Count > 0) { foreach (var response in responses) { var requestId = new global::Improbable.Worker.Core.RequestId <IncomingCommandRequest>(response.RequestId); if (response.FailureMessage != null) { // Send a command failure if the string is non-null. connection.SendCommandFailure(requestId, response.FailureMessage); continue; } var schemaCommandResponse = new global::Improbable.Worker.Core.SchemaCommandResponse(ComponentId, 1); global::Improbable.Gdk.Tests.ComponentsWithNoFields.Empty.Serialization.Serialize(response.Payload.Value, schemaCommandResponse.GetObject()); connection.SendCommandResponse(requestId, new global::Improbable.Worker.Core.CommandResponse(schemaCommandResponse)); } responses.Clear(); } } } chunks.Dispose(); } Profiler.EndSample(); }
protected override void OnCreateManager(int capacity) { base.OnCreateManager(capacity); Group = GetComponentGroup(typeof(Fan), ComponentType.Subtractive <DespawningEntity>()); }
protected override void OnCreateManager() { m_Group = GetComponentGroup(typeof(EcsIntElement)); }
protected override void OnCreateManager(int capacity) { m_TransformGroup = GetComponentGroup(ComponentType.ReadOnly(typeof(CopyTransformFromGameObject)), typeof(UnityEngine.Transform)); }
protected override void OnCreateManager() { base.OnCreateManager(); DespawnGroup = GetComponentGroup(typeof(CharacterDespawnRequest)); // ItemGroup = GetComponentGroup(typeof(CharacterItem)); }
protected override void OnCreateManager() { base.OnCreateManager(); Group = GetComponentGroup(typeof(HealthStateData), typeof(HitCollisionOwnerData)); }
protected override void OnCreateManager() { base.OnCreateManager(); group = GetComponentGroup(typeof(LooksInfo), typeof(LocomotionState)); }
protected override void OnCreateManager() { _rows = GetComponentGroup(typeof(Position), typeof(RuntimeRow)); }
protected override void OnCreateManager() { group = GetComponentGroup(typeof(Position), typeof(Velocity), typeof(NeighborsEntityBuffer)); }
protected override void OnCreateManager() { base.OnCreateManager(); group = GetComponentGroup(typeof(UserCommand), typeof(TargetPosition), typeof(MoveSpeed)); }
protected override void OnCreateManager(int capacity) { g = GetComponentGroup(ComponentType.ReadOnly <Position2D>(), ComponentType.ReadOnly <BombEffect>(), ComponentType.Create <LifeTime>()); }
public override void CleanComponents(ComponentGroup group, ComponentSystemBase system, EntityCommandBuffer buffer) { var entityType = system.GetArchetypeChunkEntityType(); var componentAddedType = system.GetArchetypeChunkComponentType <ComponentAdded <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Component> >(); var componentRemovedType = system.GetArchetypeChunkComponentType <ComponentRemoved <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Component> >(); var receivedUpdateType = system.GetArchetypeChunkComponentType <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.ReceivedUpdates>(); var authorityChangeType = system.GetArchetypeChunkComponentType <AuthorityChanges <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Component> >(); var cmdRequestType = system.GetArchetypeChunkComponentType <CommandRequests.Cmd>(); var cmdResponseType = system.GetArchetypeChunkComponentType <CommandResponses.Cmd>(); var chunkArray = group.CreateArchetypeChunkArray(Allocator.TempJob); foreach (var chunk in chunkArray) { var entities = chunk.GetNativeArray(entityType); // Updates if (chunk.Has(receivedUpdateType)) { var updateArray = chunk.GetNativeArray(receivedUpdateType); for (int i = 0; i < entities.Length; ++i) { buffer.RemoveComponent <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.ReceivedUpdates>(entities[i]); var updateList = updateArray[i].Updates; // Pool update lists to avoid excessive allocation updateList.Clear(); Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Update.Pool.Push(updateList); ReferenceTypeProviders.UpdatesProvider.Free(updateArray[i].handle); } } // Component Added if (chunk.Has(componentAddedType)) { for (int i = 0; i < entities.Length; ++i) { buffer.RemoveComponent <ComponentAdded <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Component> >(entities[i]); } } // Component Removed if (chunk.Has(componentRemovedType)) { for (int i = 0; i < entities.Length; ++i) { buffer.RemoveComponent <ComponentRemoved <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Component> >(entities[i]); } } // Authority if (chunk.Has(authorityChangeType)) { var authorityChangeArray = chunk.GetNativeArray(authorityChangeType); for (int i = 0; i < entities.Length; ++i) { buffer.RemoveComponent <AuthorityChanges <Improbable.Gdk.Tests.ComponentsWithNoFields.ComponentWithNoFieldsWithCommands.Component> >(entities[i]); AuthorityChangesProvider.Free(authorityChangeArray[i].Handle); } } // Cmd Command if (chunk.Has(cmdRequestType)) { var cmdRequestArray = chunk.GetNativeArray(cmdRequestType); for (int i = 0; i < entities.Length; ++i) { buffer.RemoveComponent <CommandRequests.Cmd>(entities[i]); ReferenceTypeProviders.CmdRequestsProvider.Free(cmdRequestArray[i].CommandListHandle); } } if (chunk.Has(cmdResponseType)) { var cmdResponseArray = chunk.GetNativeArray(cmdResponseType); for (int i = 0; i < entities.Length; ++i) { buffer.RemoveComponent <CommandResponses.Cmd>(entities[i]); ReferenceTypeProviders.CmdResponsesProvider.Free(cmdResponseArray[i].CommandListHandle); } } } chunkArray.Dispose(); }
/// <summary> /// Processing TDirectory tag /// </summary> /// <param name="compGroup">Component group</param> /// <param name="nodeTemplate">XML node, contained template</param> /// <returns>Generated XML node</returns> private XmlElement Process_Directory(ComponentGroup compGroup, XmlElement nodeTemplate) { XmlElement nodeDirectory = m_doc.CreateElement("Directory", m_namespaceURI); CopyAttribute(nodeDirectory, nodeTemplate, "Id"); string dirName = GetAttributeDecoded(nodeTemplate, "Name"); setDirectoryName(ref nodeDirectory, dirName); XmlElement nodeComponent = m_doc.CreateElement("Component", m_namespaceURI); nodeDirectory.AppendChild(nodeComponent); string ComponentId = GetAttributeDecoded(nodeTemplate, "ComponentId"); nodeComponent.SetAttribute("Id", ComponentId); CopyAttribute(nodeComponent, nodeTemplate, "Guid"); nodeComponent.SetAttribute("KeyPath", "yes"); compGroup.m_components.Add(ComponentId); // StringCollection files = new StringCollection(); foreach (XmlNode child in nodeTemplate.ChildNodes) { XmlElement node = child as XmlElement; if (node == null) continue; if (node.Name == "TFiles") { Process_Files(nodeComponent, node); } else if (node.Name == "TDirectory") { XmlElement nodeSubDirectory = Process_Directory(compGroup, node); nodeDirectory.AppendChild(nodeSubDirectory); } else if (node.Name == "Inline") { foreach (XmlNode subInline in node.ChildNodes) { XmlNode newNode = m_doc.ImportNode(subInline, true); nodeComponent.AppendChild(newNode); } } else { GenError("Invalid node name - " + node.Name); } } return nodeDirectory; }
protected sealed override void internalOnNodeRemoved(ComponentGroup <T> group) { OnNodeRemoved(group.entity, group.component); }
protected override void OnCreateManager() { //Obtener grupos de componentes que contengan los componentes indicados (manos y tiempospawnmanos) m_Manos = GetComponentGroup(typeof(ManoComponent)); m_TiempoSpawn = GetComponentGroup(typeof(TiempoSpawnManosComponent)); }
public override void ExecuteReplication(ComponentGroup replicationGroup, Connection connection) { throw new System.NotImplementedException(); }
public void SetComponentGroupSelection(ComponentGroup group) { SetSelection(new List <int>()); }
protected override void OnCreateManager() { base.OnCreateManager(); Group = GetComponentGroup(typeof(PlayerCharacterControl), typeof(PlayerState)); }
protected override void OnCreateManager(int capacity) { _group = GetComponentGroup(typeof(Particle), typeof(T)); }
protected override void OnCreateManager(int capacity) { base.OnCreateManager(capacity); WeaponGroup = GetComponentGroup(typeof(TerraformerWeaponA), typeof(CharacterItem)); }
protected override void OnCreateManager() { base.OnCreateManager(); SpawnGroup = GetComponentGroup(typeof(CharacterSpawnRequest)); }
protected override void OnCreateManager() { m_Logros = GetComponentGroup(typeof(LogroComponent), typeof(ComprobarLogroComponent)); }
protected override void OnCreateManager() { base.OnCreateManager(); WeaponGroup = GetComponentGroup(typeof(TerraformerWeaponA), typeof(CharacterPresentationSetup)); }
private XmlElement Process_DirectoryRef(XmlElement nodeTemplate) { XmlElement nodeDirectoryRef = m_doc.CreateElement("DirectoryRef", m_namespaceURI); CopyAttribute(nodeDirectoryRef, nodeTemplate, "Id"); // nodeDirectoryRef.SetAttributeNode(parent.GetAttributeNode("Id")); // nodeDirectoryRef.SetAttribute("LongName", parent.GetAttribute("Name")); ComponentGroup compGroup = new ComponentGroup(GetAttributeDecoded(nodeTemplate, "ComponentGroupId")); // List Directory nodes foreach (XmlNode child in nodeTemplate.ChildNodes) { XmlElement node = child as XmlElement; if (node == null) continue; if (node.Name == "TDirectory") { XmlElement nodeDirectory = Process_Directory(compGroup, node); nodeDirectoryRef.AppendChild(nodeDirectory); } else if (node.Name == "TDirectoryTree") { XmlElement nodeDirectoryTree = Process_DirectoryTree(compGroup, node); nodeDirectoryRef.AppendChild(nodeDirectoryTree); } else if (node.Name == "TIncludeComponent") { Process_IncludeComponent(compGroup, node); } else GenError("Invalid node name - " + node.Name); } m_componentGroups.Add(compGroup); return nodeDirectoryRef; }
protected override void OnCreateManager() { base.OnCreateManager(); _group = GetComponentGroup(typeof(DataComponent)); }
internal void AppendFilesAndDirectories(ComponentGroup compGroup, ref XmlElement parentDirectory, ref XmlElement parentComponent, DirectoryInfo sourceDirInfo, Guid baseGuid, string basePath) { FileInfo[] files = sourceDirInfo.GetFiles(); if (files.Length <= 0) { XmlElement nodeFile = m_doc.CreateElement("CreateFolder", m_namespaceURI); parentComponent.AppendChild(nodeFile); } else { foreach (FileInfo file in files) { XmlElement nodeFile = m_doc.CreateElement("File", m_namespaceURI); string fileShortName = GenerateShortName(file.Name, true); nodeFile.SetAttribute("Id", NormalizeWixId(file.Name + '.' + fileShortName + '.' + baseGuid)); if (m_wixVersion == WixVersion.Wix3) { nodeFile.SetAttribute("Name", file.Name); } else { nodeFile.SetAttribute("Name", fileShortName); nodeFile.SetAttribute("LongName", file.Name); } nodeFile.SetAttribute("Source", file.FullName.Replace(basePath, "$(var." + VAR_BASEDIR + ")")); nodeFile.SetAttribute("Vital", "yes"); parentComponent.AppendChild(nodeFile); } } DirectoryInfo[] dirs = sourceDirInfo.GetDirectories(); foreach (DirectoryInfo dir in dirs) { XmlElement nodeSubDir = m_doc.CreateElement("Directory", m_namespaceURI); setDirectoryName(ref nodeSubDir, dir.Name); string dirSubName = dir.FullName.Replace(basePath, ""); if (dirSubName.Length == 0 || dirSubName[0] != '\\') dirSubName = '\\' + dirSubName; string posfix = '.' + baseGuid.ToString().Substring(0, 8).ToUpper(); string directoryId = NormalizeWixId("Dir" + dirSubName + posfix); string componentId = NormalizeWixId("CM" + dirSubName + posfix); Guid directoryGuid = ComputeNewGuid(baseGuid, dirSubName); nodeSubDir.SetAttribute("Id", directoryId); XmlElement nodeSubComponent = m_doc.CreateElement("Component", m_namespaceURI); compGroup.m_components.Add(componentId); nodeSubComponent.SetAttribute("Id", componentId); nodeSubComponent.SetAttribute("DiskId", "1"); nodeSubComponent.SetAttribute("Guid", directoryGuid.ToString()); nodeSubComponent.SetAttribute("KeyPath", "yes"); AppendFilesAndDirectories(compGroup, ref nodeSubDir, ref nodeSubComponent, dir, directoryGuid, basePath); nodeSubDir.AppendChild(nodeSubComponent); parentDirectory.AppendChild(nodeSubDir); } }
protected override void Initialize(ref ComponentGroup group) { // We are not allowed to spawn prefabs while iterating ComponentGroup so we copy list of entities and characters. entityBuffer.Clear(); characterBuffer.Clear(); { var entityArray = group.GetEntityArray(); var characterArray = group.GetComponentArray <Character>(); for (var i = 0; i < entityArray.Length; i++) { entityBuffer.Add(entityArray[i]); characterBuffer.Add(characterArray[i]); } } for (var i = 0; i < entityBuffer.Count; i++) { var charEntity = entityBuffer[i]; var character = characterBuffer[i]; var characterRepAll = EntityManager.GetComponentData <CharacterReplicatedData>(charEntity); var heroTypeRegistry = m_resourceManager.GetResourceRegistry <HeroTypeRegistry>(); var heroTypeAsset = heroTypeRegistry.entries[characterRepAll.heroTypeIndex]; character.heroTypeData = heroTypeAsset; var characterTypeAsset = heroTypeAsset.character; // Create main presentation var charPrefabGUID = server ? characterTypeAsset.prefabServer : characterTypeAsset.prefabClient; var charPrefab = m_resourceManager.GetSingleAssetResource(charPrefabGUID) as GameObject; var presentationGOE = m_world.Spawn <GameObjectEntity>(charPrefab); var charPresentationEntity = presentationGOE.Entity; character.presentation = charPresentationEntity; var charPresentation = EntityManager.GetComponentObject <CharacterPresentationSetup>(charPresentationEntity); charPresentation.character = charEntity; character.presentations.Add(charPresentation); // Setup health var healthState = EntityManager.GetComponentData <HealthStateData>(charEntity); healthState.SetMaxHealth(heroTypeAsset.health); EntityManager.SetComponentData(charEntity, healthState); // Setup CharacterMoveQuery var moveQuery = EntityManager.GetComponentObject <CharacterMoveQuery>(charEntity); moveQuery.Initialize(heroTypeAsset.characterMovementSettings, charEntity); // Setup HitCollisionHistory if (EntityManager.HasComponent <HitCollisionData>(charPresentationEntity)) { var hitCollisionData = EntityManager.GetComponentData <HitCollisionData>(charPresentationEntity); hitCollisionData.hitCollisionOwner = charEntity; EntityManager.SetComponentData(charPresentationEntity, hitCollisionData); } else { var hitCollisionData = new HitCollisionData { hitCollisionOwner = charEntity, }; EntityManager.AddComponentData(charPresentationEntity, hitCollisionData); } character.eyeHeight = heroTypeAsset.eyeHeight; // Setup abilities GameDebug.Assert(EntityManager.Exists(characterRepAll.abilityCollection), "behavior controller entity does not exist"); var buffer = EntityManager.GetBuffer <EntityGroupChildren>(characterRepAll.abilityCollection); for (int j = 0; j < buffer.Length; j++) { var childEntity = buffer[j].entity; if (EntityManager.HasComponent <CharBehaviour>(childEntity)) { var charBehaviour = EntityManager.GetComponentData <CharBehaviour>(childEntity); charBehaviour.character = charEntity; EntityManager.SetComponentData(childEntity, charBehaviour); } } // Create items foreach (var itemEntry in heroTypeAsset.items) { var itemPrefabGuid = server ? itemEntry.itemType.prefabServer : itemEntry.itemType.prefabClient; if (!itemPrefabGuid.IsSet()) { continue; } var itemPrefab = m_resourceManager.GetSingleAssetResource(itemPrefabGuid) as GameObject; var itemGOE = m_world.Spawn <GameObjectEntity>(itemPrefab); var itemCharPresentation = EntityManager.GetComponentObject <CharacterPresentationSetup>(itemGOE.Entity); itemCharPresentation.character = charEntity; itemCharPresentation.attachToPresentation = charPresentationEntity; character.presentations.Add(itemCharPresentation); } } }
public EntityListView(TreeViewState state, ComponentGroup componentGroup, IEntitySelectionWindow window) : base(state) { this.window = window; SelectedComponentGroup = componentGroup; Reload(); }
private void Process_IncludeComponent(ComponentGroup compGroup, XmlElement nodeTemplate) { string componentId = GetAttributeDecoded(nodeTemplate, "Id"); compGroup.m_components.Add(componentId); }
protected override void OnCreateManager() { base.OnCreateManager(); Group = GetComponentGroup(typeof(ServerEntity), typeof(Character), typeof(CharacterPredictedData)); }
private XmlElement Process_DirectoryTree(ComponentGroup compGroup, XmlElement nodeTemplate) { XmlElement nodeDirectory = m_doc.CreateElement("Directory", m_namespaceURI); CopyAttribute(nodeDirectory, nodeTemplate, "Id"); string dirName = GetAttributeDecoded(nodeTemplate, "Name"); setDirectoryName(ref nodeDirectory, dirName); string sourceDir = GetAttributeDecoded(nodeTemplate, "SourceDir"); nodeDirectory.AppendChild( m_doc.CreateProcessingInstruction("define", String.Format("{0}=\"{1}\"", VAR_BASEDIR, sourceDir))); XmlElement nodeComponent = m_doc.CreateElement("Component", m_namespaceURI); nodeDirectory.AppendChild(nodeComponent); string ComponentId = GetAttributeDecoded(nodeTemplate, "ComponentId"); nodeComponent.SetAttribute("Id", ComponentId); nodeComponent.SetAttribute("DiskId", "1"); CopyAttribute(nodeComponent, nodeTemplate, "Guid"); Guid ComponentGuid = new Guid(GetAttributeDecoded(nodeTemplate, "Guid")); compGroup.m_components.Add(ComponentId); // StringCollection files = new StringCollection(); DirectoryInfo sourceDirInfo = new DirectoryInfo(sourceDir); AppendFilesAndDirectories(compGroup, ref nodeDirectory, ref nodeComponent, sourceDirInfo, ComponentGuid, sourceDirInfo.FullName); nodeDirectory.AppendChild(m_doc.CreateProcessingInstruction("undef", VAR_BASEDIR)); return nodeDirectory; }
protected override void OnCreateManager() { base.OnCreateManager(); CharGroup = GetComponentGroup(typeof(AnimStateController), typeof(CharacterPresentationSetup), ComponentType.Subtractive <DespawningEntity>()); }
protected override void OnCreateManager() { base.OnCreateManager(); Group = GetComponentGroup(typeof(LocalPlayer), typeof(PlayerCameraSettings), typeof(SpectatorCamControl)); }
protected override void OnCreateManager(int capacity) { _scannerGroup = GetComponentGroup(typeof(Scanner), typeof(Position)); _voxelGroup = GetComponentGroup(typeof(Voxel), typeof(TransformMatrix)); }