コード例 #1
0
 /// <summary>
 /// A generic add component
 /// </summary>
 private void AddComponentGeneric(Entity entity, IComponentData component)
 {
     MethodInfo methodInfo        = typeof(EntityManager).GetMethod("AddComponentData");
     MethodInfo genericMethodInfo = methodInfo.MakeGenericMethod(component.GetType());
     var        parameters        = new object[] { entity, component };
     object     componentData     = genericMethodInfo.Invoke(this.entityManager, parameters);
 }
コード例 #2
0
        public void BindComponentTo(Entity entity, IComponentData componentData, bool isAttach = true)
        {
            var componentType = componentData.GetType();
            var processing    = entitySystemsController.SystemInfos.Values.Where(e =>
                                                                                 e.NeededComponents.Any(x => x.TypeComponent.GetElementType() == componentType));

            foreach (var processingInfo in processing)
            {
                if (processingInfo.NeededComponents.All(e =>
                                                        EntityContainer.HasComponent(entity, e.TypeComponent.GetElementType())))
                {
                    processingInfo.AttachedEntity.Add(entity);
                    if (isAttach)
                    {
                        AttachComponents(processingInfo, processingInfo.AttachedEntity);
                    }
                }
            }
        }
コード例 #3
0
 public void AddComponent(Entity entity, IComponentData componentData)
 {
     ComponentsContainer[entity].Add(componentData.GetType(), componentData);
 }