Changing a pawnDef's colours

Started by Alistaire, June 16, 2015, 08:24:41 AM

Previous topic - Next topic

Alistaire

How do I colour animal pawns (a.k.a pawns without a back story) through C#? I can't seem to find a class which handles colours on pawns.

On ThingDefs you can add the <graphicData> tag, which includes a <color> tag to change colours on a thing. The ThingDef class is a child
of the BuildingDef class (for whatever reason), which is child of the Def class. PawnDef is also a child of the Def class, making it kinda
incompatible with ThingDef and with <graphicData>.

Since <pawnDef> uses <standardBodyGraphicPath> and <dessicatedBodyGraphicPath> I get it might be hard to implement a simple
<graphicData> tag in there, but it would be really useful in my case.



Thanks!

Alistaire

#1
Alright, I've been working on code for the past three days. I tried the following things:


  • Add a Comp_Colorable <comps> to the pawnKindDef. This didn't work, because pawnKindDef doesn't inherit ThingWithComps.
  • Change the colour through C# with the Verse.CompColorableUtility.SetColor() method and a Dictionary<string,string> that binds
    certain keywords to hex colour codes, which are then changed into a float colour with Verse.GenColor.FromHex(). Since Pawn
    does inherit ThingWithComps (unlike the PawnKindDef), this should work.
  • Add a Comp_Colorable <comps> to a <race> thingDef. Since thingDef inherits from ThingWithComps, this might work.

I was able to compile my code and start the game a bunch of times, but it gave errors every time. My problem now is that I can't see
the debug window anymore when I activate the mod, meaning I don't even know what the error is this time.

I've attached the full mod + source code to the post. I hope anyone could help me with this amount of information, because I realized
my first post wasn't really descriptive enough really.
EDIT: Apparently there's a 600 kB file size limit. The file is 2.200 kB, and now uploaded to Dropbox.




Since I already uploaded the mod to the post I guess I'll explain what I'm trying to accomplish.

I want to add a new custom incident (with a custom incidentWorker, of course) that (a la Gnomoria) transforms a random piece of rock
rubble into an enemy, specifically the Rock Crab. The type of Rock Crab depends on the type of rubble, and each type of rubble gives the
rockcrab's shells a different amount of hitpoints and in the end the speed will be different for each type of rubble.

The use of the colouring is to lower the amount of sprites I have to make for the monsters. The vanilla rubble rocks are all coloured using
CompColorable, which means I could make a rock crab texture in the same colours of the rubble and then colour that to automatically
generate more monsters. In the end, every rock crab will drop its own type of Carapace too.

The mod is supposed to both increase animal variety and incident variety for the base game in a simple and interesting way. This ultimately
gives the player a reason to clean up the map, build stone masonry and build with bricks, clear parts of the map to make it harder for raiders
to camp the rocks, etc.
I will also implement some more interesting places where rock crabs might show up, rock crab hordes spawning from stockpiled rocks, steel
rubble crabs (with vastly superior armour and very hard to kill) and rockshell armour (a la Runescape). The monster's backstory is pretty
cool too, and the monster can be butchered into "crab meat", which increases food variety.

The mod is obviously inspired by Runescape's Rock Crabs, but I feel like it will add a lot of character to the alien planet in Rimworld.

skullywag

Im still reading this, but ive just spotted the line about the debug window being gone, the output.log file has all the errors in it for the last game session in your rimworld folder.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

skullywag

Just throwing stuff out there as havent really messed with pawns as of yet, but have messed in most other areas, I would think the way to handle this would be to do the same thing the stuff system does and create a mask for the texture in question and then override the draw function of your pawn to use that, unfortunately its gonna involve you writing your own graphics with all the matrix shiz. Im digging around to see if ive got some code to reference, I know ive done it a few times (just not on pawns).
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

isistoy

#4
Quote from: skullywag on June 17, 2015, 08:26:13 AM
Im still reading this, but ive just spotted the line about the debug window being gone, the output.log file has all the errors in it for the last game session in your rimworld folder.
Thanks Skullywag, didn't know about that.
Alistaire: interesting project. Hoping you find a way to achieve this, as we also do pawn creation, but only with the already known basic xml tex path for graphics.
<Stay on the scene like a State machine>