Core Keeper Modding SDK exposes a "built in" mechanism to inform mods about a spawning object.
When a save of Core Keeper is loaded, all objects are considered spawning, this means you can effectively modify data of all objects in the world, current and future.
API.Server.OnObjectCreated on the Server, which works on Dedicated Servers; Single player games and for Host on multiplayer game. This is the event you should use to react and modify the data of entities that load into the game or will be spawned, for example if you want to change the HealthCD of every PlayerGrave this is the one you want.
API.Client.OnObjectSpawnedOnClient is the Client equivalent, mind that only visual data changes make sense to use it, other data like changing health will not work.
As of v1.1.2.10
API.Server.OnObjectCreated is an event with a signature of void OnObjectCreated(Entity entity, EntityManager entityManager)
Be very careful with amount of work you do inside this callback, it's called by the system on every entity that is considered an Object (has IsObjectCD) once.
All entities which trigger this event should have ObjectDataCD but it's not guarded by the event system.
Example usage
public class Playground : IMod
{
public void EarlyInit()
{
API.Server.OnObjectCreated += OnObjectCreated;
}
public void Init()
{
}
public void ModObjectLoaded(UnityEngine.Object obj)
{
}
public void Shutdown()
{
API.Server.OnObjectCreated -= OnObjectCreated;
}
public void Update()
{
}
bool IMod.CanBeUnloaded() => true;
private void OnObjectCreated(Entity entity, EntityManager manager)
{
var objectCD = manager.GetComponentData<ObjectDataCD>(entity);
if(objectCD.objectID == ObjectID.PlayerGrave)
{
// It's a grave!
}
else
{
// It's some other object with ObjectDataCD
}
}
}