RimWorld

RimWorld

Animal Gear
Dylan  [developer] 8 Aug, 2021 @ 1:00pm
Migrating armors defs
re: the idea of def conversion.
The catch is that armors come in normal size and large size now. The universal armors are a one-size-fits all (since that's what they originally were).

If such a conversion feature were added to the framework, the logic would look like this:

- detect an animal wearing Apparel_AnimalScarf
- check animal body size. If greater than 1.0, check Apparel_LargeAnimalScarf, otherwise check Apparel_SmallAnimalScarf
- check if this def has the animal listed in the tags.
- if it does, it's supported and the def could be switched over.

Of course, this logic is specific to my mod and I imagine you'd prefer the framework be more generic. Encoding and parsing this logic into the dev note is plausible, but could take some thinking.
Last edited by Dylan; 8 Aug, 2021 @ 1:00pm
< >
Showing 1-15 of 25 comments
Dylan  [developer] 8 Aug, 2021 @ 1:02pm 
editing etc.
<devNote>this stuff</devNote>
makes things a bit easier
Dylan  [developer] 8 Aug, 2021 @ 1:03pm 
as long as I can determine it that way it should be fine, I would detect if your mod is active, the devNote thing was just another field I recently come to be aware of that has no use ingame
Owlchemist 8 Aug, 2021 @ 1:04pm 
It's worth noting that the tags would only exist under one def or the other.

<devNote>Apparel_SmallAnimalScarf,Apparel_LargeAnimalScarf</devNote>

If the universal armor had this node, the framework would look through the comma separated list. It would pick the first def it finds that has a matching animal tag.
Last edited by Owlchemist; 8 Aug, 2021 @ 1:04pm
Owlchemist 8 Aug, 2021 @ 1:06pm 
Oh, this may be a better idea for logic:

if the devNote says "legacy" then:

- Look at the ParentName of this def. Find ever other def that also has this same ParentName. Go through them and pick the first def that has a matching animal tag.
Last edited by Owlchemist; 8 Aug, 2021 @ 1:07pm
Dylan  [developer] 8 Aug, 2021 @ 1:08pm 
Originally posted by Owlchemist:
Oh, this may be a better idea for logic:

if the devNote says "legacy" ...

makes sense, that way it would be very fast to look at devNote to see if something has to be done at all.
I see so Apparel_SmallAnimalScarf and Apparel_LargeAnimalScarf exist right now so I could already test this
Last edited by Dylan; 8 Aug, 2021 @ 1:10pm
Owlchemist 8 Aug, 2021 @ 1:12pm 
While we're on the topic of improving legacy functionality, the following would be great:

If the legacy devnote is detected AND it cannot find placeholder texture (missing file), just fallback to a transparent dummy texture included in the framework itself. That way I wouldn't need to include thousands upon thousands of 4x4 pixel dummy textures in the mod xD
Last edited by Owlchemist; 8 Aug, 2021 @ 1:13pm
Dylan  [developer] 8 Aug, 2021 @ 1:16pm 
Originally posted by Owlchemist:
While we're on the topic of improving legacy functionality, the following would be great: ..

I will have a look at it.
Would it not be enough to just point all legacy ones at the one 4x4 empty one if they are only there to be replaced (or would there be ones that actually have a graphic?)
Owlchemist 8 Aug, 2021 @ 1:17pm 
Well now that you mention it... yes I suppose that would make sense. The only instance of this being bad is if armor graphics only existed for legacy armor but not the proper armor. But why would I be doing that for? xD
Dylan  [developer] 8 Aug, 2021 @ 1:21pm 
I mean it should not be a problem to just have this in the framework, maybe even better to just put it in as a fallback if no texture is found -> load a 4x4 always and be done with it.

edit: But it could be in addtion and just still load the 4x4 with the legacy note always to be fast ^^
Last edited by Dylan; 8 Aug, 2021 @ 1:22pm
Owlchemist 8 Aug, 2021 @ 2:11pm 
One more optimization idea on the topic of legacy stuff: Right now the way it's trying to work is to basically list every animal def that exists throughout the workshop. That list is hundreds upon hundreds of critters long and not really practical to try and keep up with. Since it's one-size-fits all, there's really no reason to list everything individually.

If anything, what would be more useful is an exceptions list to exclude a few select entities (like for example mechs, which can technically be treated as animals)
Dylan  [developer] 8 Aug, 2021 @ 2:23pm 
Makes sense, I have thought about that before aswell, it would need to have some new info aswell to not brake other things, so maybe a tag like <li>AnimalBlacklist</li> after <li>Animal</li> like <li>AnimalCUTOUTCOMPLEX</li> ?

edit: maybe even better: start a name with _ to exclude it (?) special ones like _MECHANOIDS could be in there which would check for "IsFlesh" (?)
Last edited by Dylan; 8 Aug, 2021 @ 2:25pm
Owlchemist 8 Aug, 2021 @ 2:27pm 
Starting it with ! would be a bit more industry standard for exclusions, if that's allowable.
Owlchemist 8 Aug, 2021 @ 2:30pm 
If you're thinking about making special categories though, checking race/thinkTreeMain = animal should, afaik, cover all animals.
Dylan  [developer] 8 Aug, 2021 @ 3:27pm 
I will test it with "!"

I will see if I can get a version out tomorrow with most/all that we mentioned here (as long as it does not impede on existing functions)

The normal check right now is already "pawn.RaceProps.Animal"
Dylan  [developer] 9 Aug, 2021 @ 1:32pm 
Ok, I just updated the AnimalGear-mod (Version 1.3.0.8):

- New Option to fallback to a generic empty texture if no animal specific one is found (that way it is not required to have empty ones for all of them) [On by default]

- New Option to automatically replace gear with known replacements on map load (the old gear needs a devNote like this in its ThingDef: <devNote>legacy[Apparel_SmallAnimalScarf,Apparel_LargeAnimalScarf]</devNote> which then replaces this gear with 'Apparel_SmallAnimalScarf' or 'Apparel_LargeAnimalScarf' if one of those has the animal listed in its Tags - this does not perform any checks and switches the def, so make sure the replacement works correctly) [On by default]

I tested it with the scarfs and it worked well:
<ThingDef ParentName="AnimalScarfBase"> <defName>Apparel_AnimalScarf</defName> <label>universal pet scarf</label> <devNote>legacy[Apparel_SmallAnimalScarf,Apparel_LargeAnimalScarf]</devNote> <description>A stylish accessory for cool, laid back animals.</description> <statBases> <WorkToMake>1800</WorkToMake> <MaxHitPoints>50</MaxHitPoints> <MarketValue>50</MarketValue> <Mass>0.1</Mass> </statBases> <costStuffCount>50</costStuffCount> <apparel> <tags> <li>Animal</li> <!-- <li>AnimalCUTOUTCOMPLEX</li> --> <li>AnimalALL</li> </tags> </apparel> </ThingDef>
<devNote>legacy[Apparel_SmallAnimalScarf,Apparel_LargeAnimalScarf]</devNote>
and
<li>AnimalALL</li>
are the only changes.
I forgot about 'AnimalALL' that way you would not need the names, but it also will never really work with a texture (the option does not load them) but maybe that is enough if you will have them replaced anyway.

I can not see the 'ParentName' once ingame, so I now did it with the brackets having a list of the replacements.
It does work very well and I could even switch it out in a way that keeps all of the stats (it should work as long as the items still have the same basis / no strange classes and even fallback to replacing it with something similar otherwise)

The empty texture fallback seemed to work good aswell, but is maybe not needed with 'AnimalALL' (?)
Last edited by Dylan; 9 Aug, 2021 @ 1:34pm
< >
Showing 1-15 of 25 comments
Per page: 1530 50