public IComponent FindComponent(ComponentTypes type) { return(componentList.Find(delegate(IComponent c) { return c.ComponentType == type; })); }
/// <summary> /// ゲームオブジェクトとしての子オブジェクトは、変換プロセスにて、すべてエンティティとして生成されるようす。 /// physics もそれをあてにするようなので、ボーンもそれに乗っかろうと思う。 /// </summary> static Entity[] addComponentsBoneEntities (GameObjectConversionSystem gcs, Transform[] bones) { var em = gcs.DstEntityManager; return(bones .Select(bone => gcs.TryGetPrimaryEntity(bone)) //.Select( existsEnt => existsEnt != Entity.Null ? addComponents_(existsEnt) : create_() ) .Do(ent => addComponents_(ent)) .ToArray()); Entity addComponents_(Entity exists_) { var addtypes = new ComponentTypes ( typeof(Bone.RelationLinkData), typeof(Bone.LocalValueData),// 回転と移動をわけたほうがいいか? typeof(Translation), typeof(Rotation) ); em.AddComponents(exists_, addtypes); return(exists_); } }
public void AddComponentsWithSharedComponentsWorks() { var archetype = m_Manager.CreateArchetype(typeof(EcsTestData), typeof(EcsTestSharedComp)); var entity = m_Manager.CreateEntity(archetype); var sharedComponentValue = new EcsTestSharedComp(1337); m_Manager.SetSharedComponentData(entity, sharedComponentValue); var typesToAdd = new ComponentTypes(typeof(EcsTestData3), typeof(EcsTestSharedComp2), typeof(EcsTestData2)); m_Manager.AddComponents(entity, typesToAdd); Assert.AreEqual(m_Manager.GetSharedComponentData <EcsTestSharedComp>(entity), sharedComponentValue); var expectedTotalTypes = new ComponentTypes(typeof(EcsTestData), typeof(EcsTestData2), typeof(EcsTestData3), typeof(EcsTestSharedComp), typeof(EcsTestSharedComp2)); var actualTotalTypes = m_Manager.GetComponentTypes(entity); Assert.AreEqual(expectedTotalTypes.Length, actualTotalTypes.Length); for (var i = 0; i < expectedTotalTypes.Length; ++i) { Assert.AreEqual(expectedTotalTypes.GetTypeIndex(i), actualTotalTypes[i].TypeIndex); } actualTotalTypes.Dispose(); }
public new void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { base.Convert(entity, dstManager, conversionSystem); var top = this.gameObject; var main = top.transform.GetChild(0).gameObject; initMain_(conversionSystem, main); return; void initMain_(GameObjectConversionSystem gcs_, GameObject main_) { var em = gcs_.DstEntityManager; var mainEntity = gcs_.GetPrimaryEntity(main_); var types = new ComponentTypes ( typeof(PlayerTag), typeof(HorizontalMovingTag), typeof(MoveHandlingData), typeof(GroundHitResultData), typeof(MinicWalkActionState) ); em.AddComponents(mainEntity, types); } }
public async Task Initialize <TComponent, TComponentData>(TComponentData data, ProjectSettings settings) where TComponent : IComponent { var componentType = ComponentTypes .OfType <IComponentType <TComponent, TComponentData> >() .ToList(); var newComponents = new List <IComponent>(); foreach (var type in componentType) { var component = await type.InitializeAt(this, data, settings); if (component != null) { newComponents.Add(component); } } _components = _components.AddRange(newComponents); if (newComponents.OfType <INeedConfiguration>().Any()) { await Configure(settings, false, false); await settings.Save(); } foreach (var restorableComponent in newComponents.OfType <IRestorableComponent>()) { await restorableComponent.Restore(); } }
/// <summary> /// Constructor for single-frame component /// </summary> /// <param name="sprite">Filepath for the sprite</param> /// <param name="name">Component name</param> /// <param name="type">Component type</param> public FairyComponent(string sprite, string name, ComponentTypes type) { Sprite = sprite; Name = name; ComponentType = type; IsTextureAtlas = false; }
public TopicInformation(LaneTypes lanetype, int groupid, ComponentTypes componenttype, int componentid) { laneType = lanetype; groupID = groupid; componentType = componenttype; componentID = componentid; }
public async Task <IActionResult> PutComponentTypes([FromRoute] int id, [FromBody] ComponentTypes componentTypes) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != componentTypes.ComponentTypeId) { return(BadRequest()); } _context.Entry(componentTypes).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComponentTypesExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void AddMultipleComponentsWithQuery_ExceedChunkCapacityThrows() { var componentTypes = new ComponentTypes(typeof(EcsTestDataHuge)); // add really big component(s) Assert.AreEqual(16320, Chunk.GetChunkBufferSize()); // if chunk size changes, need to update this test var entity1 = m_Manager.CreateEntity(typeof(EcsTestData)); var entity2 = m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestData2)); var entity3 = m_Manager.CreateEntity(typeof(EcsTestData2)); var archetype1 = m_Manager.GetChunk(entity1).Archetype; var archetype2 = m_Manager.GetChunk(entity2).Archetype; var archetype3 = m_Manager.GetChunk(entity3).Archetype; var query = m_Manager.CreateEntityQuery(typeof(EcsTestData)); #if UNITY_DOTSRUNTIME Assert.Throws <InvalidOperationException>(() => m_Manager.AddComponent(query, componentTypes)); #else Assert.That(() => m_Manager.AddComponent(query, componentTypes), Throws.InvalidOperationException .With.Message.Contains("Entity archetype component data is too large.")); #endif m_ManagerDebug.CheckInternalConsistency(); // entities should be unchanged Assert.AreEqual(archetype1, m_Manager.GetChunk(entity1).Archetype); Assert.AreEqual(archetype2, m_Manager.GetChunk(entity2).Archetype); Assert.AreEqual(archetype3, m_Manager.GetChunk(entity3).Archetype); }
public void AddComponent(IComponent component) { Debug.Assert(component != null, "Component cannot be null"); componentList.Add(component); mask |= component.ComponentType; }
private void Entity_ComponentChanged(object sender, NotifyCollectionChangedEventArgs e) { Entity entity = (Entity)sender; switch (e.Action) { case NotifyCollectionChangedAction.Add: break; case NotifyCollectionChangedAction.Move: break; case NotifyCollectionChangedAction.Remove: if (!ComponentTypes.All(entity.Has)) { Remove(entity); } break; case NotifyCollectionChangedAction.Replace: break; case NotifyCollectionChangedAction.Reset: Remove(entity); break; default: throw new ArgumentOutOfRangeException(); } }
public IComponent GetComponent(ComponentTypes pType) { return(Components.Find(delegate(IComponent component) { return component.ComponentType == pType; })); }
public List <IComponent> GetComponents(ComponentTypes pType) { return(Components.FindAll(delegate(IComponent component) { return component.ComponentType == pType; })); }
public TopicInformation(string[] topicInformation) { laneType = (LaneTypes)System.Enum.Parse(typeof(LaneTypes), topicInformation[1]); groupID = int.Parse(topicInformation[2]); componentType = (ComponentTypes)System.Enum.Parse(typeof(ComponentTypes), topicInformation[3]); componentID = int.Parse(topicInformation[4]); }
private static XmlNode SaveComponent(XmlDocument file, IComponent component) { ComponentTypes type = component.ComponentType; XmlNode componentNode; switch (type) { case ComponentTypes.COMPONENT_TRANSFORM: componentNode = SaveComponentTransform(file, (ComponentTransform)component); break; case ComponentTypes.COMPONENT_GEOMETRY: componentNode = SaveComponentGeometry(file, (ComponentGeometry)component); break; case ComponentTypes.COMPONENT_TEXTURE: componentNode = SaveComponentTexture(file, (ComponentTexture)component); break; case ComponentTypes.COMPONENT_COLLISION_BOX: componentNode = SaveComponentCollisionBox(file, (ComponentCollisionBox)component); break; default: return(null); } return(componentNode); }
private void Initialize(string dataType, string componentType, string portName) { UpdateDataTypeCommand = new ReactiveCommand(); UpdatePortNameCommand = new ReactiveCommand(); UpdateCompoentTypeCommand = new ReactiveCommand(); DataTypes = UpdateDataTypeCommand .SelectMany(_ => Observable.Start(() => _recordDescriptionRepository.GetDataTypes(componentType, portName)) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データベースアクセスに失敗しました。", "エラー", "ShowError")))) .Do(_ => DataTypes.ClearOnScheduler()) .SelectMany(_ => _) .ToReactiveCollection(); PortNames = UpdatePortNameCommand .SelectMany(_ => Observable.Start(() => _recordDescriptionRepository.GetPortNames(dataType, componentType)) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データベースアクセスに失敗しました。", "エラー", "ShowError")))) .Do(_ => PortNames.ClearOnScheduler()) .SelectMany(_ => _) .ToReactiveCollection(); ComponentTypes = UpdateCompoentTypeCommand .SelectMany(_ => Observable.Start(() => _recordDescriptionRepository.GetComponentTypes(dataType, portName)) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データベースアクセスに失敗しました。", "エラー", "ShowError")))) .Do(_ => ComponentTypes.ClearOnScheduler()) .SelectMany(_ => _) .ToReactiveCollection(); DataType = dataType; PortName = portName; ComponentType = componentType; UpdateDataTypeCommand.Execute(null); UpdatePortNameCommand.Execute(null); UpdateCompoentTypeCommand.Execute(null); }
public void BuildComponentInfoTab(ComponentQuestionInfoData info, CSET_Context controlContext) { try { IsComponent = true; ShowRequirementFrameworkTitle = false; NEW_QUESTION question = BuildFromNewQuestion(info, info.Set, controlContext); ComponentVisibility = true; // Build multiServiceComponent types list if any ComponentTypes.Clear(); int salLevel = controlContext.UNIVERSAL_SAL_LEVEL.Where(x => x.Universal_Sal_Level1 == question.Universal_Sal_Level).First().Sal_Level_Order; List <ComponentOverrideLinkInfo> tmpList = new List <ComponentOverrideLinkInfo>(); foreach (COMPONENT_QUESTIONS componentType in question.COMPONENT_QUESTIONS) { bool enabled = info.HasComponentsForTypeAtSal(componentType.Component_Type, salLevel); SymbolComponentInfoData componentTypeData = info.DictionaryComponentInfo[componentType.Component_Type]; tmpList.Add(new ComponentOverrideLinkInfo() { TypeComponetXML = componentTypeData.XMLName, Type = componentTypeData.DisplayName, Enabled = enabled }); } ComponentTypes = tmpList.OrderByDescending(x => x.Enabled).ThenBy(x => x.Type).ToList(); } catch (Exception ex) { //CSETLogger.Fatal("Failed to get component information tab data.", ex); } }
private ComponentNode GetLoadStartNode(IssoPoint2D pt1, ComponentTypes loadType) { // Если пользователь указал узел, то создаём силу, приложенную в этом узле ComponentNode node = modelVM.GetNodeAtPoint(pt1); if ((node == null) || (!modelVM.CloseEnough(pt1, node.Location))) { ComponentBasic lin = modelVM.GetComponent(pt1, out IssoPoint2D pt2); // Если же он указал линейный компонент, то создаём узел в ближайшей точке к указанной // точке компонента, а уже в нём - силу if (lin?.CompType == ComponentTypes.ctLinear) { if (loadType == ComponentTypes.ctForce) { if (lin?.CompType == ComponentTypes.ctLinear) { modelVM.SplitLinearAt((ComponentLinear)lin, pt1); } node = modelVM.GetNodeAtPoint(pt1); } else { node = new ComponentNode(pt2); } } else { node = null; } } return(node); }
public void AddComponent(ComponentTypes componentType) { var comp = ComponentFactory.Create(componentType); //var comp = ComponentCache.Instance.Get(componentType); AddComponent(comp); }
public void AddMultipleComponentsWithQuery_ExceedMaxSharedComponentsThrows() { var componentTypes = new ComponentTypes(new ComponentType[] { typeof(EcsTestSharedComp), typeof(EcsTestSharedComp2), typeof(EcsTestSharedComp3), typeof(EcsTestSharedComp4), typeof(EcsTestSharedComp5), typeof(EcsTestSharedComp6), typeof(EcsTestSharedComp7), typeof(EcsTestSharedComp8) }); Assert.AreEqual(8, EntityComponentStore.kMaxSharedComponentCount); // if kMaxSharedComponentCount changes, need to update this test var entity1 = m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestSharedComp9)); var entity2 = m_Manager.CreateEntity(typeof(EcsTestData), typeof(EcsTestData2)); var entity3 = m_Manager.CreateEntity(typeof(EcsTestData2)); var archetype1 = m_Manager.GetChunk(entity1).Archetype; var archetype2 = m_Manager.GetChunk(entity2).Archetype; var archetype3 = m_Manager.GetChunk(entity3).Archetype; var query = m_Manager.CreateEntityQuery(typeof(EcsTestData)); #if UNITY_DOTSRUNTIME Assert.Throws <InvalidOperationException>(() => m_Manager.AddComponent(query, componentTypes)); #else Assert.That(() => m_Manager.AddComponent(query, componentTypes), Throws.InvalidOperationException .With.Message.EqualTo("Cannot add more than 8 SharedComponent to a single Archetype")); #endif m_ManagerDebug.CheckInternalConsistency(); // entities should be unchanged Assert.AreEqual(archetype1, m_Manager.GetChunk(entity1).Archetype); Assert.AreEqual(archetype2, m_Manager.GetChunk(entity2).Archetype); Assert.AreEqual(archetype3, m_Manager.GetChunk(entity3).Archetype); }
static void setBoneComponentValues ( GameObjectConversionSystem gcs, Transform[] bones, Entity drawInstanceEntity, BoneType boneType, int instanceDataVectorLength ) { var em = gcs.DstEntityManager; var boneEntities = bones .Select(bone => gcs.GetPrimaryEntity(bone)) .ToArray(); addComponents_(em, boneEntities); setDrawComponet_(em, boneEntities, drawInstanceEntity); setBoneId_(em, boneEntities, (int)boneType, instanceDataVectorLength); return; void addComponents_(EntityManager em_, IEnumerable <Entity> boneEntities_) { var addtypes = new ComponentTypes ( typeof(DrawTransform.LinkData), typeof(DrawTransform.IndexData), typeof(DrawTransform.VectorBufferData) ); em.AddComponents(boneEntities_, addtypes); } void setDrawComponet_ (EntityManager em_, IEnumerable <Entity> boneEntities_, Entity drawInstanceEntity_) { em_.SetComponentData( boneEntities_, new DrawTransform.LinkData { DrawInstanceEntity = drawInstanceEntity_, } ); } void setBoneId_ (EntityManager em_, IEnumerable <Entity> boneEntities_, int vectorLengthInBone_, int instanceDataVectorLength_) { var boneLength = boneEntities_.Count(); em_.SetComponentData(boneEntities_, from i in Enumerable.Range(0, boneLength) select new DrawTransform.IndexData { BoneId = i, BoneLength = boneLength, VectorBufferOffsetOfBone = vectorLengthInBone_ * i + instanceDataVectorLength_, } ); } }
public static ComponentEcs Create(ComponentTypes type) { if (!ComponentLookup.ContainsKey(type)) { return(null); } return(ComponentCache.Instance.Get(type)); }
private void AddComponentType <T>(int index) where T : IComponent, new() { ComponentHelper <TEntity, T> .Initialize(index); ComponentNames.Add(typeof(T).PrettyPrintGenericTypeName()); ComponentTypes.Add(typeof(T)); ComponentCount++; }
public BibaCompiler(RegistesteredTags tags, IServiceProvider services, ComponentTypes types) { _ass = Assembly.GetEntryAssembly(); _doc = new HtmlDocument(); _tags = tags; _provider = services; _types = types; }
public static string GetComponentImage(this ComponentTypes componentType) { if (!_availableComponents.ContainsKey(componentType)) { throw new ArgumentException("Invalid component"); } return(_availableComponents[componentType]); }
public T GetOrAddComponent <T>(ComponentTypes ctypes) where T : ComponentEcs { if (!HasComponent(ctypes)) { AddComponent(ctypes); } return(GetComponent <T>()); }
public T AddComponent <T>(ComponentTypes componentType) where T : ComponentEcs { var comp = ComponentFactory.Create(componentType); //var comp = ComponentCache.Instance.Get(componentType); AddComponent(comp); return((T)comp); }
public static ComponentTypes ToComponentTypes(this EntityArchetype archetype) { var components = archetype.GetComponentTypes(); var result = new ComponentTypes(components.ToArray()); components.Dispose(); return(result); }
/// <summary>Adds a single component</summary> public void AddComponent(IComponent component) { Debug.Assert(component != null, "Component cannot be null"); Debug.Assert(!(component is ComponentTransform), "There is already a Transform Component attached by default, no need to add another one"); componentList.Add(component); mask |= component.ComponentType; }
public static IComponentProcessor GetComponentProcessor(this ComponentTypes componentType) { if (!_availableComponents.ContainsKey(componentType)) { throw new ArgumentException("Invalid component"); } return((IComponentProcessor)Activator.CreateInstance(_availableComponents[componentType])); }