Hi there, so I'm learning how to mod rimworld and am loving it so far as I just love to code in general. The C# code I am great at, and almost really have no issues relating to that in specific. XML is however unfortunately not my strongest suit but I am working on it, and I had some questions that would help me greatly.
1. What is a Def: I understand the basic concept of a def, how xml reads it. Basically if I am right something has a "def" that determines the properties of that object. And for defs to be used either a new instance needs to be created with new MyDef(); and added to an object as a field. OR initialized via the in game def makers. When done via the second way it would seem that it does not create a new instance of the def, but an object referencing the def. As for my questions...
a) Is it possible to create a new instance of a def that is loaded from XML. Say for example I want to do some minor modifications to the def of Mote_Smoke during run time. I have tried to make an object itself and then modify the properties of the def after it is initialized from ThingMaker. However this seems to still use a reference to the graphics data of Mote_Smoke as well as its def.mote properties. As if I change them "vanilla" smoke functions like the changed smoke.
So onto my questions about each thing, I'll try to keep them organized. Sorry for my noobiness.
**Defs**
**Things**
**WorldObjects**
Thanks again for all the help, you guys are a great community and I'm loving learning to mod for the game and hope to publish something soon!
1. What is a Def: I understand the basic concept of a def, how xml reads it. Basically if I am right something has a "def" that determines the properties of that object. And for defs to be used either a new instance needs to be created with new MyDef(); and added to an object as a field. OR initialized via the in game def makers. When done via the second way it would seem that it does not create a new instance of the def, but an object referencing the def. As for my questions...
a) Is it possible to create a new instance of a def that is loaded from XML. Say for example I want to do some minor modifications to the def of Mote_Smoke during run time. I have tried to make an object itself and then modify the properties of the def after it is initialized from ThingMaker. However this seems to still use a reference to the graphics data of Mote_Smoke as well as its def.mote properties. As if I change them "vanilla" smoke functions like the changed smoke.
So onto my questions about each thing, I'll try to keep them organized. Sorry for my noobiness.
**Defs**
- Is it possible to create instances of defs declared in XML and in C# in WhateverDefOf?
- Is it possible to save a def created on runtime if given a unique defName?
- Similar to Above, will the properties of that def save if they are modified for a certain object
- Is it only possible to add defs to the database during the defloading phase?
**Things**
- What "is" a thing: Say I want with just a texture or mote effect but no "world interaction properties" like say a plain red orb that draws on the map and follows the nearest pawn slowly, would that be a thing as it has a position?
- Is it Possible for thing to exist without a map, say its a thing that should be persistent but cannot be moved with the colonist on colony transfer, can that thing exist with no map until a new one to place it is found?
- Drawing of things: What determines where and what layer the thing is drawn on/in the map. Referring to the previous red orb say I want it to draw above floors but "under" walls and pawns, is there a way to do that?. Would I assign the visibility of the object during runtime based on what is in it's cell, or is there a better way using drawing layers?
- Collision of things: Referring again to the orb example, will just moving the orb by its position every x ticks allow the orb to have "no collision". While I would like this thing to become invisible "under" certain objects. I do not want it to affect the objects it passes through in anyway.
- When should you use Thing vs WorldObject vs Comps: I know that things have more data with regards to position and other things relating to the map. But say I want to create an object that ticks, and is attached to a pawn and persists from map to map. Would it be best to use a comp in that situation or a world object?
**WorldObjects**
- WorldObject Tick Tracking: What determines how world objects tick? I see an override method here but TickManager.RegisterThings() only takes a Thing and not a WorldObject
Thanks again for all the help, you guys are a great community and I'm loving learning to mod for the game and hope to publish something soon!