Jump to content

Item Drop Texture for Custom Element


Recommended Posts

So I was modding in a new element and it's going good so far but one problem I'm having is that the item that drops from a block of said element when broken has the empty bottle texture. I've been looking into various places to try and see if I can change it but no luck so far so I was wondering if anyone here happened to have any answers.

Link to comment
Share on other sites

First of all it sounds like you did well and it would be nice if you could put your work on a public git repository. It's always easier to talk about code if you know what kind of code you are talking about.

As for the specific question, I can't say I actually know the answer, but it sounds to me like you want to apply a specific kanim. The question is how and I searched a bit in the source. The best I could find is this:

// Def
public static Tuple<Sprite, Color> GetUISprite(object item, string animName = "ui", bool centered = false)
{
	if (item is Substance)
	{
		return Def.GetUISprite(ElementLoader.FindElementByHash((item as Substance).elementID), animName, centered);
	}
	if (item is Element)
	{
		if ((item as Element).IsSolid)
		{
			return new Tuple<Sprite, Color>(Def.GetUISpriteFromMultiObjectAnim((item as Element).substance.anim, animName, centered), Color.white);
		}
		if ((item as Element).IsLiquid)
		{
			return new Tuple<Sprite, Color>(Assets.GetSprite("element_liquid"), (item as Element).substance.uiColour);
		}
		if ((item as Element).IsGas)
		{
			return new Tuple<Sprite, Color>(Assets.GetSprite("element_gas"), (item as Element).substance.uiColour);
		}
		return new Tuple<Sprite, Color>(null, Color.clear);
	}

This indicate the interesting part seems to be (item as Element).substance.anim. The next obvious question is how to actually set anim. It looks like that will take some more digging. You might also run into the issue where we can't actually add custom animations. It's very likely that we will gain that ability in the next release though. If not, then it will severely limit what modders can do if all we have to play with is the default graphics.

It's possible that you can do as we do with buildings, which is to copy the amin from an existing item and then put a postfix on the item drawing code where you overwrite the color if ID == whatever modded item you added.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
×
  • Create New...