Example #1
0
        private static Result Visit(ComponentBase componentBase)
        {
            if (componentBase == null) throw new ArgumentNullException("componentBase");

            var entityReferenceVistor = new EntityReferenceAnalysis();
            entityReferenceVistor.Visit(componentBase);

            return entityReferenceVistor.Result;
        }
Example #2
0
 public EntityLink(ComponentBase referencer, Script script, MemberPath path)
 {
     Referencer = referencer;
     Entity = null;
     EntityScript = script;
     EntityComponent = null;
     Path = path;
 }
Example #3
0
 public EntityLink(ComponentBase referencer, Entity entity, MemberPath path)
 {
     Referencer = referencer;
     Entity = entity;
     EntityScript = null;
     EntityComponent = null;
     Path = path;
 }
Example #4
0
            public override void VisitObject(object obj, ObjectDescriptor descriptor, bool visitMembers)
            {
                bool processObject = true;
                ++scriptComponentDepth;

                if (componentDepth >= 1)
                {
                    var entity = obj as Entity;
                    if (entity != null)
                    {
                        Result.EntityReferences.Add(new EntityLink(currentReferencer, entity, CurrentPath.Clone()));
                        processObject = false;
                    }

                    var entityComponent = obj as EntityComponent;
                    if (entityComponent != null)
                    {
                        Result.EntityReferences.Add(new EntityLink(currentReferencer, entityComponent, CurrentPath.Clone()));
                        processObject = false;
                    }
                }
                else
                {
                    var entity = obj as Entity;
                    if (entity != null)
                        currentReferencer = entity;
                    var settings = obj as SceneSettings;
                    if (settings != null)
                        currentReferencer = settings;
                }
                if (scriptComponentDepth != 2 && obj is Script)
                {
                    Result.EntityReferences.Add(new EntityLink(currentReferencer, (Script)obj, CurrentPath.Clone()));
                    processObject = false;
                }

                if (obj is EntityComponent || obj is SceneSettings)
                    componentDepth++;

                if (obj is ScriptComponent)
                    scriptComponentDepth = 0;

                if (processObject)
                    base.VisitObject(obj, descriptor, visitMembers);

                if (obj is EntityComponent || obj is SceneSettings)
                    componentDepth--;

                --scriptComponentDepth;
            }
 /// <summary>
 /// Attaches a <see cref="ModelComponentRenderer"/> to the specified component.
 /// </summary>
 /// <param name="component">The component.</param>
 /// <param name="renderer">The renderer.</param>
 /// <exception cref="System.ArgumentNullException">component</exception>
 public static void Attach(ComponentBase component, ModelComponentRenderer renderer)
 {
     if (component == null) throw new ArgumentNullException("component");
     component.Tags.Set(Current, renderer);
 }
 /// <summary>
 /// Gets the attached <see cref="ModelComponentRenderer"/> from the specified component.
 /// </summary>
 /// <param name="component">The component.</param>
 /// <returns>ModelComponentRenderer.</returns>
 /// <exception cref="System.ArgumentNullException">component</exception>
 public static ModelComponentRenderer GetAttached(ComponentBase component)
 {
     if (component == null) throw new ArgumentNullException("component");
     return component.Tags.Get(Current);
 }
Example #7
0
 public EntityLink(ComponentBase referencer, EntityComponent entityComponent, MemberPath path)
 {
     Referencer = referencer;
     Entity = null;
     EntityComponent = entityComponent;
     Path = path;
 }