边缘世界 RimWorld

边缘世界 RimWorld

Animal Gear
Dylan  [开发者] 2021 年 8 月 8 日 下午 1:00
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.
最后由 Dylan 编辑于; 2021 年 8 月 8 日 下午 1:00
< >
正在显示第 1 - 15 条,共 25 条留言
Dylan  [开发者] 2021 年 8 月 8 日 下午 1:02 
editing etc.
<devNote>this stuff</devNote>
makes things a bit easier
Dylan  [开发者] 2021 年 8 月 8 日 下午 1:03 
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 2021 年 8 月 8 日 下午 1:04 
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.
最后由 Owlchemist 编辑于; 2021 年 8 月 8 日 下午 1:04
Owlchemist 2021 年 8 月 8 日 下午 1:06 
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.
最后由 Owlchemist 编辑于; 2021 年 8 月 8 日 下午 1:07
Dylan  [开发者] 2021 年 8 月 8 日 下午 1:08 
引用自 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
最后由 Dylan 编辑于; 2021 年 8 月 8 日 下午 1:10
Owlchemist 2021 年 8 月 8 日 下午 1:12 
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
最后由 Owlchemist 编辑于; 2021 年 8 月 8 日 下午 1:13
Dylan  [开发者] 2021 年 8 月 8 日 下午 1:16 
引用自 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 2021 年 8 月 8 日 下午 1:17 
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  [开发者] 2021 年 8 月 8 日 下午 1:21 
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 ^^
最后由 Dylan 编辑于; 2021 年 8 月 8 日 下午 1:22
Owlchemist 2021 年 8 月 8 日 下午 2:11 
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  [开发者] 2021 年 8 月 8 日 下午 2:23 
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" (?)
最后由 Dylan 编辑于; 2021 年 8 月 8 日 下午 2:25
Owlchemist 2021 年 8 月 8 日 下午 2:27 
Starting it with ! would be a bit more industry standard for exclusions, if that's allowable.
Owlchemist 2021 年 8 月 8 日 下午 2:30 
If you're thinking about making special categories though, checking race/thinkTreeMain = animal should, afaik, cover all animals.
Dylan  [开发者] 2021 年 8 月 8 日 下午 3:27 
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  [开发者] 2021 年 8 月 9 日 下午 1:32 
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' (?)
最后由 Dylan 编辑于; 2021 年 8 月 9 日 下午 1:34
< >
正在显示第 1 - 15 条,共 25 条留言
每页显示数: 1530 50