Custom CompProperties?

Started by noobonthisforum, September 07, 2017, 06:41:10 PM

Previous topic - Next topic

noobonthisforum

Does anyone know how to make them or does someone have a template, I thought it would be easy but I spent 3 hours of just repeating myself and getting no where so I'm stuck with having to harvest woolly dragons

CannibarRechter

You need to do them in C#, I think. To see how that's done, get Jec's tools, and look at how he implemented the various Comps. A pretty easy one to understand is CompOversizedWeapon.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

noobonthisforum

Thank you!! I didn't know it involved using another language, now I feel silly ::) ::) ::)

Distman

It depends, do you want to expand the properties of an existing Comp or make a new one from scratch?
The latter is more simple imo.

Properties:

public class CompProperties_Consumable : CompProperties
    {
        public int SomeInt;
        public float SomeFloat;

         public CompProperties_Consumable()
        {
            this.compClass = typeof(CompConsumable);
        }
    }

The public CompProperties_Consumable() function basically expose the variables for easy access in the Comp.

Comp:

public class CompConsumable : ThingComp
    {
        public CompProperties_Consumable Props
        {
            get
            {
                return (CompProperties_Consumable)this.props;
            }
        }

        public void Consume()
        {
            Messages.Message("SomeInt is " + this.Props.SomeInt, MessageSound.Silent);
            Messages.Message("SomeFloat is " + this.Props.SomeFloat, MessageSound.Silent);
        }
    }

noobonthisforum

I think I would have to make a new one because I want to change the shear and wool texts in game, If i was to do that would I need to use C#?

Distman

I think you have to explain more thorough...

noobonthisforum

So I've been using
<li Class="CompProperties_Shearable">
        <woolDef>Chemfuel</woolDef>
        <shearIntervalDays>5</shearIntervalDays>
        <woolAmount>400</woolAmount>
      </li>
But in game it shows up as shear wool etc, but what I'm planning on doing is to change it so in game it changes to extract/harvest.

CannibarRechter

I believe you'll need a custom C# comp for that. Comp shearable produces wool. The code is super clear, it has a ThingDef for wool hard coded.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

noobonthisforum


Distman

While this is the perfect first mod project, Shear Wool text is handled elsewhere. Some jobdriver or... I don't know what classes handle pawn interactions.

The comp only handles the ref to the resource def and checking if a pawn is ready to be sheared. Wool growing is most likely handled by a pawn related class.

CannibarRechter

Indeed if what is wanted is to make a Wool that has its own non-wool name with a custom graphic this can be done in Xml only, this can indeed be done, as I have done it. Not sure what I was thinking

I'll respond this weekend with an example. One of my A14 mods did this
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

CannibarRechter

Okay, looking at my old mod, what you do is put a comp like this on the animal:
<comps>
      <li Class="CompProperties_Shearable">
        <woolDef>Thrumbory</woolDef>
        <shearIntervalDays>1</shearIntervalDays>
        <woolAmount>35</woolAmount>
      </li>   
</comps>


You then define a ThingDef. Mine inherited from ResourceBase. It has nothing to do with wool. When you "shear" the Thrumbo, it produces "thrumbory," like ivory. It can be used to make things.

CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

noobonthisforum

Oh didn't know you could just replace the name for custom items but I'll definitely experiment a bit more

CannibarRechter

You can't just repeat the name you also have to make a thing. Thrumbory is a resource I defined in my game. It's like ivory. You can make things from it.
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects