Ludeon Forums

Ludeon Forums

  • October 18, 2019, 07:25:54 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: How to have a different out of fuel icon  (Read 1684 times)

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
How to have a different out of fuel icon
« on: March 19, 2017, 05:41:58 PM »

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?
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1560
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #1 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)
Logged

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
Re: How to have a different out of fuel icon
« Reply #2 on: March 20, 2017, 09:00:52 PM »

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.
Code: [Select]
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.
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1560
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #3 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.
Logged

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
Re: How to have a different out of fuel icon
« Reply #4 on: March 22, 2017, 04:19:49 PM »

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.
Logged

jimthenoob

  • Drifter
  • **
  • Posts: 51
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #5 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 .
Logged

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
Re: How to have a different out of fuel icon
« Reply #6 on: March 22, 2017, 06:06:31 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
Code: [Select]
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
Code: [Select]
OverlayTypes.OutOfFuel, how would I specify the OutOfChemfuel.png in it's place?
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1560
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #7 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.
Logged

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
Re: How to have a different out of fuel icon
« Reply #8 on: March 22, 2017, 09:32:36 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
Code: [Select]
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]
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1560
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #9 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
Logged

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
Re: How to have a different out of fuel icon
« Reply #10 on: March 22, 2017, 10:36:44 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"
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1560
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #11 on: March 23, 2017, 03:48:44 AM »

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

SenaCat

  • Muffalo
  • *
  • Posts: 14
  • Survival Cat
    • View Profile
Re: How to have a different out of fuel icon
« Reply #12 on: March 23, 2017, 04:52:57 PM »

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?
Logged

RawCode

  • Super Tester
  • Planetologist
  • ***
  • Posts: 1560
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #13 on: March 23, 2017, 09:54:51 PM »

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.
Logged

Cayprol

  • Muffalo
  • *
  • Posts: 5
  • Refugee
    • View Profile
Re: How to have a different out of fuel icon
« Reply #14 on: July 24, 2017, 12:52:00 AM »

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.
Code: [Select]
        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.
Logged
Pages: [1] 2