Пример #1
0
 private static void Postfix(ref List <ElementLoader.ElementEntry> __result)
 {
     PipLib.Logger.Info("Loading elements...");
     foreach (var mod in PipLib.Mods)
     {
         ElementManager.CollectElements(System.IO.Path.Combine(PLUtil.GetAssemblyDir(mod.GetType()), PLUtil.DIR_ELEMENTS), __result);
     }
     ElementManager.RegisterSubstances();
     Debug.Log("Ignore any messages below about \"missing substance for element\"!");
 }
Пример #2
0
        /// <summary>
        /// Creates a substance from the given element entry
        /// </summary>
        /// <param name="entry">The entry</param>
        /// <returns></returns>
        public static Substance CreateSubstance(ElementLoader.ElementEntry entry)
        {
            var state = entry.state;
            var id    = GetElementID(entry);
            var ext   = entry is ElementEntryExtended ? (ElementEntryExtended)entry : null;

            var material         = ElementManager.GetBaseMaterialForState(state, substanceTable);
            var materialOverride = ext != null ? ext.material : null;

            if (material == null)
            {
                string materialName = id.ToLower();
                var    tex          = Assets.GetTexture(materialOverride ?? materialName);
                if (tex != null)
                {
                    material.mainTexture = tex;
                }
                else
                {
                    ElementManager.Logger.Verbose("No material texture '{0}', using default: {1}", materialName, material.mainTexture.name);
                }
                material.name = materialName;
            }

            // get anim
            var       animName = ((ext != null ? ext.anim : null) ?? id.ToLower()) + PLUtil.SUFFIX_ANIM;
            KAnimFile animFile = Assets.Anims.Find(a => a.name == animName);

            if (animFile == null)
            {
                animFile = ElementManager.GetDefaultKAnimForState(state, substanceTable);
                if (state == Element.State.Solid)
                {
                    Logger.Verbose("No anim '{0}' found for {1}, using default: {2}", animName, id, animFile.name);
                }
            }

            // colors
            var color        = CreateColor32(ext != null ? ext.color : null);
            var uiColor      = CreateColor32(ext != null ? ext.colorUI ?? ext.color : null);
            var conduitColor = CreateColor32(ext != null ? ext.colorUI ?? ext.color : null);

            Logger.Verbose("Created Substance: {0}({1})", id, (int)GetElementHash(entry));
            return(ModUtil.CreateSubstance(id, state, animFile, material, color, uiColor, conduitColor));
        }
Пример #3
0
 private static void Postfix()
 {
     ElementManager.RegisterAttributes();
 }