How to have a different out of fuel icon

Started by SenaCat, March 19, 2017, 05:41:58 PM

Previous topic - Next topic

SenaCat

So I'm probably overstepping my bounds here but I'm curious for myself. https://ludeon.com/forums/index.php?topic=29662.msg319707#msg319707 is a thread with a mod by Thyme that adds a chemfuel powered generator. They lamented that the generator still used the out of fuel log icon. So I made them a chemfuel version of the icon, but I've dug anywhere I can possibly think of that would control what icon the generator uses for the out of fuel state. No joy. Is it stuck in a dll somewhere?

RawCode

icon itself is not inside DLL, all resources are stored inside "asset" file.

your first stop is "CompRefuelable" (you will need dnspy or similar tool)
(in any case you will need "source" to implement code injection or custom logic)

SenaCat

Quote from: RawCode on March 20, 2017, 01:09:53 AM
icon itself is not inside DLL, all resources are stored inside "asset" file.

your first stop is "CompRefuelable" (you will need dnspy or similar tool)
(in any case you will need "source" to implement code injection or custom logic)

Yeah, I got the icon done, so that's sorted. As for the code behind CompRefuelable, where's that actually located so I can go get at it? I did happen to find it called in a .cs for a joy object added by a mod.public CompRefuelable refuelableComp; But it's an object I've not used yet because it's got some extra requirements to use it. Looking at this code, I'm not seeing where it'd call up the graphic. So I imagine this modded item will be something to reference, at least.

I never did like C#, but I know enough to be dangerous, don't be shy with your explanations if need be.

RawCode

there is no "shy"
i never spoonfeed as long as no proof of work is provided

please open code of CompRefuelable and read it fully, if you do not understand something, ask your question and it will be answered.

SenaCat

Quote from: RawCode on March 21, 2017, 03:39:29 AM
there is no "shy"
i never spoonfeed as long as no proof of work is provided

please open code of CompRefuelable and read it fully, if you do not understand something, ask your question and it will be answered.

That's what I'm asking. Where's CompRefuelable kept? Once I can get into it then I can probably figure it out. I've found references elsewhere to it, but they weren't very helpful.

jimthenoob

I think it should be located inside of the "Assembly-CSharp" file located @:  ~/RimWorld/RimWorldWin_data/Managed/Assembly-CSharp.DLL .

SenaCat

Quote from: jimthenoob on March 22, 2017, 04:51:35 PM
I think it should be located inside of the "Assembly-CSharp" file located @:  ~/RimWorld/RimWorldWin_data/Managed/Assembly-CSharp.DLL .

Found it, thank you. So I have public override void PostDraw()
{
base.PostDraw();
if (!this.HasFuel && this.Props.drawOutOfFuelOverlay)
{
this.parent.Map.overlayDrawer.DrawOverlay(this.parent, OverlayTypes.OutOfFuel);
}
}


Which is my main interest. The original modder has the generator in an .xml, but I'm assuming that this is going to need to be .cs. Is it possible to slip this code into the original .xml, or does it need to go to it's own .cs? And if that's the case, do I need to define the entire generator in there, or does the .xml's ThingDef cover the basics and I just need the .cs to cover this modification? And with OverlayTypes.OutOfFuel, how would I specify the OutOfChemfuel.png in it's place?

RawCode

open DrawOverlay and read it's source code, you will see how "outoffuel" image is actually binded and rendered.

then you will need custom CompRefuelable that accept only chemfuel and draw your custom out of fuel image.

SenaCat

Quote from: RawCode on March 22, 2017, 06:25:10 PM
open DrawOverlay and read it's source code, you will see how "outoffuel" image is actually binded and rendered.

then you will need custom CompRefuelable that accept only chemfuel and draw your custom out of fuel image.

Alright, so I'll need to build my CompRefuelable, probably tomorrow but I have what I need there I think. As for the graphic asset itself, I have a .png done. When I see private static readonly Material OutOfFuelMat = MaterialPool.MatFrom("UI/Overlays/OutOfFuel", ShaderDatabase.MetaOverlay); in OverlayDrawer, is it assuming that OutOfFuel is a .png? And if so, to follow their file path, would I want it to be "Chemfuel Generator\UI\Overlays\OutOfChemfuel.png?" in my mod folder?

[attachment deleted by admin due to age]

RawCode

this is not advised because will affect all fuel based objects, including ones that accepts wood.

if you want "proper" mod you need custom CompRefuelable

SenaCat

Quote from: RawCode on March 22, 2017, 10:10:48 PM
this is not advised because will affect all fuel based objects, including ones that accepts wood.

if you want "proper" mod you need custom CompRefuelable

I think you misunderstood me. I'm planning on making a custom CompRefuelable. I'm just making sure I understand where the OutOfChemfuel image is going to need to go within the generator mod's folder. I.e. the finished mod would be "Rimworld/Mods/Chemfuel Generator\UI\Overlays\OutOfChemfuel.png"

RawCode

you can place it anywhere, just make sure that your code have same path

SenaCat

Quote from: RawCode on March 23, 2017, 03:48:44 AM
you can place it anywhere, just make sure that your code have same path

Alright. So I'm building my CompRefuelable. In regards to the code in DrawOverlay that pulls the .png from the proper folder, assigns it to a Material and sets that Material to be the one used when out of fuel. Do I take that and put it into my version of CompRefuelable?

RawCode

copypaste payload of DrawOverlay directly into your class and adjust bindings.

DrawOverlay is static prebind class and it will not accept new overlays without code injection.

Cayprol

Hi, I know this is a old thread, but as I am trying to learn how to do the exact same thing, I suppose there's no point to start a new topic.

Since I cloned the original CompRefuelable and change all names to CompRefuelableChem while creating a new method in this class with everything identical to DrawOverlay.

I don't understand how vanilla graphics are bind to this method and the way to adjust it.
        public void DrawOverlay(Thing t, OverlayTypes overlayType)
        {
            if (OverlayDrawer.overlaysToDraw.ContainsKey(t))
            {
                Dictionary<Thing, OverlayTypes> dictionary;
                Dictionary<Thing, OverlayTypes> expr_17 = dictionary = OverlayDrawer.overlaysToDraw;
                OverlayTypes overlayTypes = dictionary[t];
                expr_17[t] = (overlayTypes | overlayType);

            }
            else
            {
                OverlayDrawer.overlaysToDraw.Add(t, overlayType);
            }
        }

Could anyone possibly explain it more into details to me.
particularly why it is using a bitwise operator?
Thank you.