Ejemplo n.º 1
0
    private static bool HasComponents(Transform transform, System.Type t)
    {
        if (Object.op_Inequality((Object)((Component)transform).GetComponent(t), (Object)null))
        {
            return(true);
        }
        IEnumerator enumerator = transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform current = (Transform)enumerator.Current;
                if (!PrefabPreProcess.ShouldExclude(current) && PrefabPreProcess.HasComponents(current, t))
                {
                    return(true);
                }
            }
        }
        finally
        {
            (enumerator as IDisposable)?.Dispose();
        }
        return(false);
    }
Ejemplo n.º 2
0
    public static List <Component> FindComponents(Transform transform, System.Type t)
    {
        List <Component> list = new List <Component>();

        PrefabPreProcess.FindComponents(transform, list, t);
        return(list);
    }
Ejemplo n.º 3
0
    private static bool HasComponents <T>(Transform transform)
    {
        if ((object)((Component)transform).GetComponent <T>() != null)
        {
            return(true);
        }
        IEnumerator enumerator = transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform current = (Transform)enumerator.Current;
                if (!PrefabPreProcess.ShouldExclude(current) && PrefabPreProcess.HasComponents <T>(current))
                {
                    return(true);
                }
            }
        }
        finally
        {
            (enumerator as IDisposable)?.Dispose();
        }
        return(false);
    }
Ejemplo n.º 4
0
    public static List <Component> FindComponents(Transform transform, Type t)
    {
        List <Component> components = new List <Component>();

        PrefabPreProcess.FindComponents(transform, components, t);
        return(components);
    }
Ejemplo n.º 5
0
 public GameManager(bool clientside, bool serverside)
 {
     Clientside   = clientside;
     Serverside   = serverside;
     preProcessed = new PrefabPreProcess(clientside, serverside);
     pool         = new PrefabPoolCollection();
 }
Ejemplo n.º 6
0
 public GameManager(bool clientside, bool serverside)
 {
     this.Clientside   = clientside;
     this.Serverside   = serverside;
     this.preProcessed = new PrefabPreProcess(clientside, serverside, false);
     this.pool         = new PrefabPoolCollection();
 }
Ejemplo n.º 7
0
    internal void SpawnMapEntities()
    {
        int i;
        PrefabPreProcess prefabPreProcess = new PrefabPreProcess(false, true, false);

        BaseEntity[] baseEntityArray  = UnityEngine.Object.FindObjectsOfType <BaseEntity>();
        BaseEntity[] baseEntityArray1 = baseEntityArray;
        for (i = 0; i < (int)baseEntityArray1.Length; i++)
        {
            BaseEntity baseEntity = baseEntityArray1[i];
            if (prefabPreProcess.NeedsProcessing(baseEntity.gameObject))
            {
                prefabPreProcess.ProcessObject(null, baseEntity.gameObject, false);
            }
            baseEntity.SpawnAsMapEntity();
        }
        DebugEx.Log(string.Format("Map Spawned {0} entities", (int)baseEntityArray.Length), StackTraceLogType.None);
        baseEntityArray1 = baseEntityArray;
        for (i = 0; i < (int)baseEntityArray1.Length; i++)
        {
            BaseEntity baseEntity1 = baseEntityArray1[i];
            if (baseEntity1 != null)
            {
                baseEntity1.PostMapEntitySpawn();
            }
        }
    }
Ejemplo n.º 8
0
    public static List <T> FindComponents <T>(Transform transform)
    {
        List <T> ts = new List <T>();

        PrefabPreProcess.FindComponents <T>(transform, ts);
        return(ts);
    }
Ejemplo n.º 9
0
    private static bool HasComponents(Transform transform, Type t)
    {
        bool flag;

        if (transform.GetComponent(t) != null)
        {
            return(true);
        }
        IEnumerator enumerator = transform.GetEnumerator();

        try
        {
            while (enumerator.MoveNext())
            {
                Transform current = (Transform)enumerator.Current;
                if (PrefabPreProcess.ShouldExclude(current) || !PrefabPreProcess.HasComponents(current, t))
                {
                    continue;
                }
                flag = true;
                return(flag);
            }
            return(false);
        }
        finally
        {
            IDisposable disposable = enumerator as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
        }
        return(flag);
    }
Ejemplo n.º 10
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);
     }
 }
Ejemplo n.º 11
0
 public bool NeedsProcessing(GameObject go)
 {
     if (go.CompareTag("NoPreProcessing"))
     {
         return(false);
     }
     if (PrefabPreProcess.HasComponents <IPrefabPreProcess>(go.transform))
     {
         return(true);
     }
     if (PrefabPreProcess.HasComponents <IPrefabPostProcess>(go.transform))
     {
         return(true);
     }
     if (PrefabPreProcess.HasComponents <IEditorComponent>(go.transform))
     {
         return(true);
     }
     if (!this.isClientside)
     {
         if (PrefabPreProcess.clientsideOnlyTypes.Any <Type>((Type type) => PrefabPreProcess.HasComponents(go.transform, type)))
         {
             return(true);
         }
         if (PrefabPreProcess.HasComponents <IClientComponentEx>(go.transform))
         {
             return(true);
         }
     }
     if (!this.isServerside)
     {
         if (PrefabPreProcess.serversideOnlyTypes.Any <Type>((Type type) => PrefabPreProcess.HasComponents(go.transform, type)))
         {
             return(true);
         }
         if (PrefabPreProcess.HasComponents <IServerComponentEx>(go.transform))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 12
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);
        }
    }
Ejemplo n.º 13
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();
        }
    }
Ejemplo n.º 14
0
    internal void SpawnMapEntities()
    {
        PrefabPreProcess prefabPreProcess = new PrefabPreProcess(false, true, false);

        BaseEntity[] objectsOfType = (BaseEntity[])Object.FindObjectsOfType <BaseEntity>();
        foreach (BaseEntity baseEntity in objectsOfType)
        {
            if (prefabPreProcess.NeedsProcessing(((Component)baseEntity).get_gameObject()))
            {
                prefabPreProcess.ProcessObject((string)null, ((Component)baseEntity).get_gameObject(), false);
            }
            baseEntity.SpawnAsMapEntity();
        }
        DebugEx.Log((object)("Map Spawned " + (object)objectsOfType.Length + " entities"), (StackTraceLogType)0);
        foreach (BaseEntity baseEntity in objectsOfType)
        {
            if (Object.op_Inequality((Object)baseEntity, (Object)null))
            {
                baseEntity.PostMapEntitySpawn();
            }
        }
    }
Ejemplo n.º 15
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);
                }
            }
        }
    }
Ejemplo n.º 16
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);
        }
    }
Ejemplo n.º 17
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);
        }
    }
Ejemplo n.º 18
0
 public bool NeedsProcessing(GameObject go)
 {
     return(!go.CompareTag("NoPreProcessing") && (PrefabPreProcess.HasComponents <IPrefabPreProcess>(go.get_transform()) || PrefabPreProcess.HasComponents <IPrefabPostProcess>(go.get_transform()) || PrefabPreProcess.HasComponents <IEditorComponent>(go.get_transform()) || !this.isClientside && (((IEnumerable <System.Type>)PrefabPreProcess.clientsideOnlyTypes).Any <System.Type>((Func <System.Type, bool>)(type => PrefabPreProcess.HasComponents(go.get_transform(), type))) || PrefabPreProcess.HasComponents <IClientComponentEx>(go.get_transform())) || !this.isServerside && (((IEnumerable <System.Type>)PrefabPreProcess.serversideOnlyTypes).Any <System.Type>((Func <System.Type, bool>)(type => PrefabPreProcess.HasComponents(go.get_transform(), type))) || PrefabPreProcess.HasComponents <IServerComponentEx>(go.get_transform()))));
 }