SHORTTUTORIAL: WorldComponent and GameComponent - roxxploxx/RimWorldModGuide GitHub Wiki

!!!In Progress!!!

Ok, I haven't even looked at this topic yet but ChJees said it's really really neat so I'm going to take his/her word for it. Here's what they have provided. 😄


GameComponent

I think this is GameComponent code. Basically, this is showing how you can store configuration abilities in the save file. i.e. that ExposeData method reads in file information.

<components>
    <li Class="AlienMegaspiderFarm.HiveGameComponent">
        <allowUsingAbilities>True</allowUsingAbilities>
    </li>
</components>
/// <summary>
/// Store game component state.
/// </summary>
public override void ExposeData()
{
    Scribe_Values.Look(ref allowLayingEggs, "allowLayingEggs");
    Scribe_Values.Look(ref allowUsingAbilities, "allowUsingAbilities");
}

These constructors are needed for the GameComponent to not throw a hissy fit:

/// <summary>
/// This Constructor, you need this.
/// </summary>
public HiveGameComponent(Game game)
{
    this.game = game;
}

/// <summary>
/// This Constructor, you need this. Too!
/// </summary>
public HiveGameComponent()
{

}

One with the Game parameter and one empty.

And MapComponent need at least this constructor to work:

public ThrushMapComponent(Map map) : base(map) {  }

MapComponent

⚠️ **GitHub.com Fallback** ⚠️