Setup - ilikegoodfood/CommunityLib GitHub Wiki
In order to develop a mod that is dependant on the CommunityLib, you first need to download the latest release, either directly from this github repository, or from the Steam Worskshop.
Once downloaded, go into your mod's code project, in your preffered IDE, and add the CommunityLib.dll as a reference. Make sure to set the reference's properties so that it isn't cloned when you compile your mod.
In Visual Studio, this is done by selecting the reference in the Solution Explorer and setting Copy Local to false.
For a detailed explination of what the Complete Example is doing and why, see Integration > Finding a Mod.
The Integrations page also contains details and code templates, describing how dependent and non-dependent mods can interact with the Community Library's systems.
Complete Example
using Assets.Code;
using Assets.Code.Modding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace ExampleMod
{
public class ExampleModKernel
{
private static CommunityLib.ModCore comLib;
public static CommunityLib.ModCore getComLib()
{
return comLib;
}
public override void beforeMapGen(Map map)
{
getModkernels(map);
}
public override void afterLoading(Map map)
{
getModKernels(map);
}
// Template using a Switch statement
private void getModKernels (Map map)
{
foreach (ModKernel kernel in map.mods)
{
switch (kernel.GetType().Namespace)
{
case "CommunityLib"
if (kernel is CommunityLib.ModCore core)
{
comLib = kernel;
}
break;
default:
break;
}
}
}
// Template using an else if construction
private void getModKernels (Map map)
{
foreach (ModKernel kernel in map.mods)
{
if (kernel.GetType().Namespace == "CommunityLib" && kernel is CommunityLib.ModCore core)
{
comLib = kernel;
}
}
}
// Use only one of the two options above
}
}
Now that you have a reference to the CommunityLib ModKernel, you can access the AgentAI, or register your CommunityLib.Hooks
, or use any of the Community Library's other features as desired.
The next step is to look through the rest of the features.