コード例 #1
0
ファイル: EntityCloner.cs プロジェクト: radiomonter/Tanki_X
        public EntityInternal Clone(string name, EntityInternal entity, EntityBuilder entityBuilder)
        {
            entityBuilder.SetName(name);
            if (entity.TemplateAccessor.IsPresent())
            {
                TemplateAccessor accessor = entity.TemplateAccessor.Get();
                if (accessor != null)
                {
                    TemplateDescription templateDescription = accessor.TemplateDescription;
                    entityBuilder.SetTemplate(templateDescription.TemplateClass);
                    if (accessor.HasConfigPath())
                    {
                        entityBuilder.SetConfig(accessor.ConfigPath);
                    }
                    else
                    {
                        YamlNode yamlNode = accessor.YamlNode;
                        if (yamlNode != null)
                        {
                            entityBuilder.SetTemplateYamlNode(yamlNode);
                        }
                    }
                }
            }
            EntityInternal internal2 = entityBuilder.Build(true);

            foreach (Type type in entity.ComponentClasses)
            {
                if (!ReferenceEquals(type, this.newEntityComponentType))
                {
                    internal2.AddComponent(entity.GetComponent(type));
                }
            }
            return(internal2);
        }
コード例 #2
0
 private void AutoAddComponents(EntityInternal newEntity, TemplateDescription templateDescription)
 {
     foreach (Type type in templateDescription.GetAutoAddedComponentTypes())
     {
         Component component = !typeof(GroupComponent).IsAssignableFrom(type) ? newEntity.CreateNewComponentInstance(type) : GroupRegistry.FindOrCreateGroup(type, newEntity.Id);
         newEntity.AddComponent(component);
     }
 }