8,756
edits
m (mark as stub) |
(added section about extending populations) |
||
Line 24: | Line 24: | ||
== Additional Info == | == Additional Info == | ||
Here's a thread on Steam where I discuss using encounter and population tables: http://steamcommunity.com/app/333640/discussions/3/358415738194955181/ | Here's a thread on Steam where I discuss using encounter and population tables: http://steamcommunity.com/app/333640/discussions/3/358415738194955181/ | ||
==Modifying Existing Popualtions== | |||
To modify existing populations, use <code>PopulationManager.cs</code> to load the changes on game boot up. | |||
<syntaxhighlight lang="c#"> | |||
// Helper method to fudge into the most common/simple pop tables. | |||
public static bool AddToPopTable(string table, params PopulationItem[] items) { | |||
PopulationInfo info; | |||
if (!PopulationManager.Populations.TryGetValue(table, out info)) | |||
return false; | |||
// If this is a single group population, add to that group. | |||
if (info.Items.Count == 1 && info.Items[0] is PopulationGroup) { | |||
var group = info.Items[0] as PopulationGroup; | |||
group.Items.AddRange(items); | |||
return true; | |||
} | |||
info.Items.AddRange(items); | |||
return true; | |||
} | |||
// Usage in IPart constructor slapped on dummy XML object | |||
public class SomeInitialiser : IPart | |||
{ | |||
public SomeInitialiser() { | |||
AddToPopTable("RandomLiquid", new PopulationObject { Blueprint = "SomeLiquid" }); | |||
AddToPopTable("RandomFaction", new PopulationObject { Blueprint = "SomeFaction" }); | |||
AddToPopTable("LairOwners_Saltdunes", new PopulationTable { Name = "DynamicObjectsTable:SomeCreature", Weight = 5 }); | |||
} | |||
} | |||
</syntaxhighlight> |