Skip to content

Instantly share code, notes, and snippets.

@Mehni
Created February 2, 2019 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mehni/b3f46b3b08f70cd74746a46f89d2d7a8 to your computer and use it in GitHub Desktop.
Save Mehni/b3f46b3b08f70cd74746a46f89d2d7a8 to your computer and use it in GitHub Desktop.
Re: Request for (source code/comments) for RW wiki modding tutorial
Re: Request for (source code/comments) for RW wiki modding tutorial
Tynan Sylvester
Fri 2019-02-01 18:05
Thanks for making those useful resources! To the questions
ThingComp.PostPrintOnto(SectionLayer layer)
It's so the ThingComp can print polygons onto the SectionLayer. SectionLayer is part of the "chunked" graphics printing system that allows us to efficiently render non-moving objects by printing them on a shared mesh and drawing them in one call. All Things have a Print method for this; PostPrintOnto is just the ThingComp hook to participate in Print.
ThingComp.CompPrintForPowerGrid(SectionLayer layer)
Same as above, but allows printing images on the power grid.
CompProperties.ResolveReferences(ThingDef parentDef)
Part of the def loading process. Loading involves multiple stages, one of which is "ResolveReferences". Lots of defs have a ResolveReferences method. This is the CompProperties way of participating in that.
I also noticed this article: https://rimworldwiki.com/wiki/Modding_Tutorials/Custom_Comp_Classes
It should be noted that "comp" or "component" isn't actually a format concept in the code; it's a design pattern that we use repeatedly in different places. So the different comps follow the same pattern but they're generally not linked in the code in any way. It's a way to have functionality we can use on different objects. E.g. various Things need a "lifetime" after which they vanish, but we don't want "lifetime" count-down code in every Thing, so the solution is to have a component we can include in only those things where it's needed. It's a common pattern in games.
On Fri, Feb 1, 2019 at 4:39 PM Mehni wrote:
Hi Ty,
The last few weeks I've updated some of the Modding Tutorials on the official RimWorld wiki. Anyway, I'm now proud to say it now boasts articles for DefModExtensions, the link between C# and XML, the cause of common XML errors and how to resolve them, Mod Settings and much more.
So here's my request; there are some things for the ThingComp article that elude me. I would very much appreciate the source code for 'em, or some clarification. Maybe even a wiki edit.
These are:
ThingComp.PostPrintOnto(SectionLayer layer)
Not a clue. Power uses it to show the connection wire. From what I can tell only the SectionLayer_ThingsGeneral is fed into it as an argument, so its general use escapes me.
ThingComp.CompPrintForPowerGrid(SectionLayer layer)
Not a clue. Power uses it, but only on buildings. Similar to PostPrintOnto, but with SectionLayer_ThingsPowerGrid instead.
CompProperties.ResolveReferences(ThingDef parentDef)
Not a clue. Used for Resolving references, obviously, but dunno the use.
Thanks in advance,
Mehni
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment