예제 #1
0
        public static void AddSubstance(SubstanceEntry entry, SubstanceTable substanceTable)
        {
            Log.Spam($"Adding substance {entry.elementId}");

            SimHashes elementHash = SimHashUtil.CreateHash(entry.elementId);

            if (entry.baseSubstance == null)
            {
                Log.Error($"Missing baseSubstance for substance {entry.elementId}");
                return;
            }

            var baseSubstance = substanceTable.GetSubstance((SimHashes)Hash.SDBMLower(entry.baseSubstance));

            if (baseSubstance == null)
            {
                Log.Error($"Invalid baseSubstance {entry.baseSubstance} for substance {entry.elementId}");
                return;
            }

            Color32 color        = entry.color ?? baseSubstance.colour;
            Color32 uiColor      = entry.uiColor ?? baseSubstance.uiColour;
            Color32 conduitColor = entry.conduitColor ?? baseSubstance.conduitColour;

            var substance = ModUtil.CreateSubstance(entry.elementId, entry.state, baseSubstance.anim, baseSubstance.material, color, uiColor, conduitColor);

            substanceTable.GetList().Add(substance);
        }
예제 #2
0
 public static Substance CreateSubstance(Substance source)
 {
     return(ModUtil.CreateSubstance(
                name: Id,
                state: Element.State.Liquid,
                kanim: source.anim,
                material: source.material,
                colour: color,
                ui_colour: color,
                conduit_colour: color
                ));
 }
예제 #3
0
 public static Substance CreateBloodSubstance(Substance source)
 {
     return(ModUtil.CreateSubstance(
                name: "Blood",
                state: Element.State.Liquid,
                kanim: source.anim,
                material: source.material,
                colour: BLOOD_RED,
                ui_colour: BLOOD_RED,
                conduit_colour: BLOOD_RED
                ));
 }
예제 #4
0
 public static Substance CreateFrozenBloodSubstance(Material sourceMaterial, KAnimFile sourceAnim)
 {
     return(ModUtil.CreateSubstance(
                name: "FrozenBlood",
                state: Element.State.Solid,
                kanim: sourceAnim,
                material: CreateFrozenBloodMaterial(sourceMaterial),
                colour: BLOOD_RED,
                ui_colour: BLOOD_RED,
                conduit_colour: BLOOD_RED
                ));
 }
예제 #5
0
 public static Substance CreateFrozenSubstance(Material sourceMaterial, KAnimFile sourceAnim)
 {
     return(ModUtil.CreateSubstance(
                name: IDFrozen,
                state: Element.State.Solid,
                kanim: sourceAnim,
                material: CreateFrozenMaterial(sourceMaterial),
                colour: ElementFrozenColor,
                ui_colour: ElementFrozenColor,
                conduit_colour: ElementFrozenColor
                ));
 }
예제 #6
0
        public static Substance CreateSolidSubstance(string id, Material source, string anim, Texture2D materialTexture)
        {
            KAnimFile kanim = Assets.GetAnim(anim);

            return(ModUtil.CreateSubstance(
                       name: id,
                       state: Element.State.Solid,
                       kanim: kanim,
                       material: CreateSolidMaterial(id, source, materialTexture),
                       colour: White,
                       ui_colour: White,
                       conduit_colour: White
                       ));
        }
예제 #7
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));
        }
예제 #8
0
 public static Substance CreateSubstance(string name, Element.State state, KAnimFile kanim, Material material, Color32 colour)
 {
     return(ModUtil.CreateSubstance(name, state, kanim, material, colour, colour, colour));
 }