Exemplo n.º 1
0
    public static void LoadGeneratedOre(List <Type> types)
    {
        Type typeFromHandle         = typeof(IOreConfig);
        HashSet <SimHashes> hashSet = new HashSet <SimHashes>();

        foreach (Type type in types)
        {
            if (typeFromHandle.IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface)
            {
                object     obj       = Activator.CreateInstance(type);
                IOreConfig oreConfig = obj as IOreConfig;
                SimHashes  elementID = oreConfig.ElementID;
                if (elementID != SimHashes.Void)
                {
                    hashSet.Add(elementID);
                }
                GameObject gameObject = oreConfig.CreatePrefab();
                KPrefabID  component  = gameObject.GetComponent <KPrefabID>();
                Assets.AddPrefab(component);
            }
        }
        List <Element> elements = ElementLoader.elements;

        foreach (Element item in elements)
        {
            if (item != null && !hashSet.Contains(item.id))
            {
                if (item.substance != null && (UnityEngine.Object)item.substance.anim != (UnityEngine.Object)null)
                {
                    GameObject gameObject2 = null;
                    if (item.IsSolid)
                    {
                        gameObject2 = EntityTemplates.CreateSolidOreEntity(item.id, null);
                    }
                    else if (item.IsLiquid)
                    {
                        gameObject2 = EntityTemplates.CreateLiquidOreEntity(item.id, null);
                    }
                    else if (item.IsGas)
                    {
                        gameObject2 = EntityTemplates.CreateGasOreEntity(item.id, null);
                    }
                    if ((UnityEngine.Object)gameObject2 != (UnityEngine.Object)null)
                    {
                        KPrefabID component2 = gameObject2.GetComponent <KPrefabID>();
                        Assets.AddPrefab(component2);
                    }
                }
                else
                {
                    Debug.LogError("Missing substance or anim for element [" + item.name + "]");
                }
            }
        }
    }