コード例 #1
0
    public static List <Component> FindComponents(Transform transform, Type t)
    {
        List <Component> components = new List <Component>();

        PrefabPreProcess.FindComponents(transform, components, t);
        return(components);
    }
コード例 #2
0
    public static List <T> FindComponents <T>(Transform transform)
    {
        List <T> ts = new List <T>();

        PrefabPreProcess.FindComponents <T>(transform, ts);
        return(ts);
    }
コード例 #3
0
    public static List <Component> FindComponents(Transform transform, System.Type t)
    {
        List <Component> list = new List <Component>();

        PrefabPreProcess.FindComponents(transform, list, t);
        return(list);
    }
コード例 #4
0
 public static void FindComponents(Transform transform, List <Component> list, Type t)
 {
     list.AddRange(transform.GetComponents(t));
     foreach (Transform transforms in transform)
     {
         if (PrefabPreProcess.ShouldExclude(transforms))
         {
             continue;
         }
         PrefabPreProcess.FindComponents(transforms, list, t);
     }
 }
コード例 #5
0
    private void DestroyComponents(Type t, GameObject go, bool client, bool server)
    {
        List <Component> components = new List <Component>();

        PrefabPreProcess.FindComponents(go.transform, components, t);
        components.Reverse();
        foreach (Component component in components)
        {
            RealmedRemove realmedRemove = component.GetComponent <RealmedRemove>();
            if (realmedRemove != null && !realmedRemove.ShouldDelete(component, client, server))
            {
                continue;
            }
            if (!component.gameObject.CompareTag("persist"))
            {
                this.NominateForDeletion(component.gameObject);
            }
            UnityEngine.Object.DestroyImmediate(component, true);
        }
    }
コード例 #6
0
    public static void FindComponents(Transform transform, List <Component> list, System.Type t)
    {
        list.AddRange((IEnumerable <Component>)((Component)transform).GetComponents(t));
        IEnumerator enumerator = transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform current = (Transform)enumerator.Current;
                if (!PrefabPreProcess.ShouldExclude(current))
                {
                    PrefabPreProcess.FindComponents(current, list, t);
                }
            }
        }
        finally
        {
            (enumerator as IDisposable)?.Dispose();
        }
    }
コード例 #7
0
    private void DestroyComponents(System.Type t, GameObject go, bool client, bool server)
    {
        List <Component> list = new List <Component>();

        PrefabPreProcess.FindComponents(go.get_transform(), list, t);
        list.Reverse();
        using (List <Component> .Enumerator enumerator = list.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                Component     current   = enumerator.Current;
                RealmedRemove component = (RealmedRemove)current.GetComponent <RealmedRemove>();
                if (!Object.op_Inequality((Object)component, (Object)null) || component.ShouldDelete(current, client, server))
                {
                    if (!current.get_gameObject().CompareTag("persist"))
                    {
                        this.NominateForDeletion(current.get_gameObject());
                    }
                    Object.DestroyImmediate((Object)current, true);
                }
            }
        }
    }
コード例 #8
0
    public void ProcessObject(string name, GameObject go, bool resetLocalTransform = true)
    {
        Type[] typeArray;
        int    i;

        if (!this.isClientside)
        {
            typeArray = PrefabPreProcess.clientsideOnlyTypes;
            for (i = 0; i < (int)typeArray.Length; i++)
            {
                Type type = typeArray[i];
                this.DestroyComponents(type, go, this.isClientside, this.isServerside);
            }
            foreach (IClientComponentEx clientComponentEx in PrefabPreProcess.FindComponents <IClientComponentEx>(go.transform))
            {
                clientComponentEx.PreClientComponentCull(this);
            }
        }
        if (!this.isServerside)
        {
            typeArray = PrefabPreProcess.serversideOnlyTypes;
            for (i = 0; i < (int)typeArray.Length; i++)
            {
                Type type1 = typeArray[i];
                this.DestroyComponents(type1, go, this.isClientside, this.isServerside);
            }
            foreach (IServerComponentEx serverComponentEx in PrefabPreProcess.FindComponents <IServerComponentEx>(go.transform))
            {
                serverComponentEx.PreServerComponentCull(this);
            }
        }
        this.DestroyComponents(typeof(IEditorComponent), go, this.isClientside, this.isServerside);
        if (resetLocalTransform)
        {
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
        }
        List <Transform> transforms = PrefabPreProcess.FindComponents <Transform>(go.transform);

        transforms.Reverse();
        foreach (IPrefabPreProcess prefabPreProcess in PrefabPreProcess.FindComponents <IPrefabPreProcess>(go.transform))
        {
            prefabPreProcess.PreProcess(this, go, name, this.isServerside, this.isClientside, this.isBundling);
        }
        foreach (Transform transforms1 in transforms)
        {
            if (!transforms1 || !transforms1.gameObject)
            {
                continue;
            }
            if (this.isServerside && transforms1.gameObject.CompareTag("Server Cull"))
            {
                this.RemoveComponents(transforms1.gameObject);
                this.NominateForDeletion(transforms1.gameObject);
            }
            if (!this.isClientside)
            {
                continue;
            }
            if (!(transforms1.gameObject.CompareTag("Client Cull") | (transforms1 == go.transform ? false : transforms1.gameObject.GetComponent <BaseEntity>() != null)))
            {
                continue;
            }
            this.RemoveComponents(transforms1.gameObject);
            this.NominateForDeletion(transforms1.gameObject);
        }
        this.RunCleanupQueue();
        foreach (IPrefabPostProcess prefabPostProcess in PrefabPreProcess.FindComponents <IPrefabPostProcess>(go.transform))
        {
            prefabPostProcess.PostProcess(this, go, name, this.isServerside, this.isClientside, this.isBundling);
        }
    }
コード例 #9
0
    public void ProcessObject(string name, GameObject go, bool resetLocalTransform = true)
    {
        if (!this.isClientside)
        {
            foreach (System.Type clientsideOnlyType in PrefabPreProcess.clientsideOnlyTypes)
            {
                this.DestroyComponents(clientsideOnlyType, go, this.isClientside, this.isServerside);
            }
            foreach (IClientComponentEx component in PrefabPreProcess.FindComponents <IClientComponentEx>(go.get_transform()))
            {
                component.PreClientComponentCull((IPrefabProcessor)this);
            }
        }
        if (!this.isServerside)
        {
            foreach (System.Type serversideOnlyType in PrefabPreProcess.serversideOnlyTypes)
            {
                this.DestroyComponents(serversideOnlyType, go, this.isClientside, this.isServerside);
            }
            foreach (IServerComponentEx component in PrefabPreProcess.FindComponents <IServerComponentEx>(go.get_transform()))
            {
                component.PreServerComponentCull((IPrefabProcessor)this);
            }
        }
        this.DestroyComponents(typeof(IEditorComponent), go, this.isClientside, this.isServerside);
        if (resetLocalTransform)
        {
            go.get_transform().set_localPosition(Vector3.get_zero());
            go.get_transform().set_localRotation(Quaternion.get_identity());
        }
        List <Transform> components = PrefabPreProcess.FindComponents <Transform>(go.get_transform());

        components.Reverse();
        foreach (IPrefabPreProcess component in PrefabPreProcess.FindComponents <IPrefabPreProcess>(go.get_transform()))
        {
            component.PreProcess((IPrefabProcessor)this, go, name, this.isServerside, this.isClientside, this.isBundling);
        }
        using (List <Transform> .Enumerator enumerator = components.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                Transform current = enumerator.Current;
                if (Object.op_Implicit((Object)current) && Object.op_Implicit((Object)((Component)current).get_gameObject()))
                {
                    if (this.isServerside && ((Component)current).get_gameObject().CompareTag("Server Cull"))
                    {
                        this.RemoveComponents(((Component)current).get_gameObject());
                        this.NominateForDeletion(((Component)current).get_gameObject());
                    }
                    if (this.isClientside && ((((Component)current).get_gameObject().CompareTag("Client Cull") ? 1 : 0) | (!Object.op_Inequality((Object)current, (Object)go.get_transform()) ? (false ? 1 : 0) : (Object.op_Inequality((Object)((Component)current).get_gameObject().GetComponent <BaseEntity>(), (Object)null) ? 1 : 0))) != 0)
                    {
                        this.RemoveComponents(((Component)current).get_gameObject());
                        this.NominateForDeletion(((Component)current).get_gameObject());
                    }
                }
            }
        }
        this.RunCleanupQueue();
        foreach (IPrefabPostProcess component in PrefabPreProcess.FindComponents <IPrefabPostProcess>(go.get_transform()))
        {
            component.PostProcess((IPrefabProcessor)this, go, name, this.isServerside, this.isClientside, this.isBundling);
        }
    }