Anything with a PARENTNAME type inherits (read: copies) and applies all content from its associated NAME type.Inheritance information is taken from each tag. BaseMakeableGun in turn contains info to make the gun.Ī list representation of how inheritance works in Rimworld's XML might help you out, either early on or to collect your thoughts after reading the above. BaseGun contains the information which is true for all guns: they're part of the WeaponsRanged category, they can be smelted, they can have art. BaseWeapon contains the basic information which is true for all weapons: they can be hauled, equipped, selected. It might help to think of each as a sort of template. It inherits the contents of BaseGun and is inherited by everything with : The next in the file is one with the Name type BaseGun and the ParentName type BaseWeapon. The full BaseWeapon parent only has to be defined once in a file, and can then be inherited (copied) with:Īnother parent is BaseBullet which holds every standard bullet's commonly repeated properties, such as the property that bullets don't use hitpoints: Because there's a lot of tags repeated throughout every thing, this greatly compacts the XML file. Which notifies that this is of the Item category, as opposed to those of the Building category. This way you can write everything you're going to repeat a lot throughout the file in a single location, such as the following: The Name type means the contents of this can be inherited by (read: copied by) another. So what that means is that all the contents of can be used over and over in the various guns, but BaseWeapon itself does not exist in the game - it's an abstract idea! The Abstract type means that contents of this will not be loaded into the game, that after reading and processing the information in this tag it (the game) will finish reading the XML files and discard this tag and its contents, leaving alone (not discarding) anything that might have copied (taken, inherited) the contents of it. The first thing in ThingDefs_Misc\Weapons\BaseWeapons.xml is a with a Name and Abstract type: Therefore, when defining abstracts for a mod, it's advisable to try to avoid overwriting the core abstracts and to instead use unique names that are unlikely to be accidentally used by other mods. Redefining the core abstracts is common cause for mod compatibility issues, because any mod loaded after the abstract has been redefined will use the modified version instead of the core. Note that after update A15, abstracts have been directly inheritable from the core and from other mods. In case this ParentName is incomplete this will crash the game, and you stop it from being loaded into the game with Abstract="True". If something has a ParentName="YourParentName", it takes all contents from Name="YourParentName". Summary: In XML, inheritance is used to decrease redundancy. It's almost certain that doing so will lead to problems so you're better off avoiding using a keyword outside of it's intended purpose as a keyword. In general, you should avoid using a keyword as a property when editing or creating a new. abstract is NOT the same as Abstract when it comes to the Abstract keyword and making that mistake will cause issues. A common mistake is to unintentionally use a different casing. When you write a keyword, it should be written exactly the same each time it's used. For this reason, there are some rules you should be aware of as the breaking of these rules is a common cause for bugs and errors when starting out. A word that is given the role of keyword implies that it has an intended purpose and it's use is reserved only as a keyword. These words are called keywords and they make up part of the languages syntax. Take note of the words Abstract, Name, and Class. You have surely noticed that some of the words in the XML files seem to be used repeatedly. It is important that your file follows this structure to the point where mods won't work with multiple, or a outside of : The rootnode of every def in the game is, followed by the exact type of def (e.g. xml files uses UTF-8 encoding and XML version 1.0, which are the default values for these fields - some XML editors choose to hide this line on editing and then save it on top of the document without ever asking the user about it.Īfter that, the structure of the file consists of and tags:Įach contains something's def (or definition), which can be used to specify each and every modifiable property, e.g for a certain thing (ThingDef). The first thing in this file is the following line: Mods/Core/Defs/ThingDefs_Misc/Weapons_Guns.xml xml file in the Core folder, for example ThingDefs_Misc/Weapons_Guns.xml: Along with how inheritance using Name, ParentName and Abstract works.ĭefault Def structure Standard defs įind a Def. You'll learn the default structure of def files:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |