internal static void ModifySpawn(CreatureSpawner spawner, GameObject spawn)
    {
        var template = LocalSpawnerManager.GetTemplate(spawner);

        if (template is null)
        {
#if DEBUG
            Log.LogTrace($"Found no config for {spawn}.");
#endif
            return;
        }

        Log.LogTrace($"Applying modifiers to spawn {spawn.name}");

        var spawnZdo = ComponentCache.GetZdo(spawn);

        if (template.Modifiers is not null)
        {
            foreach (var modifier in template.Modifiers)
            {
                try
                {
                    modifier?.Modify(spawn, spawnZdo);
                }
                catch (Exception e)
                {
                    Log.LogError($"Error while attempting to apply modifier '{modifier?.GetType()?.Name}' to local spawner '{spawner.name}'", e);
                }
            }
        }
    }
    internal static bool CheckConditionsValid(CreatureSpawner spawner)
    {
#if DEBUG && VERBOSE
        Log.LogTrace($"Testing conditions of spawner '{spawner.name}:{spawner.transform.position}'");
#endif

        var template = LocalSpawnerManager.GetTemplate(spawner);

        if (template is not null && !template.Enabled)
        {
            return(false);
        }

        if (template?.SpawnConditions is null)
        {
            return(true);
        }

        var spawnerZdo = ComponentCache.GetZdo(spawner);

        if (spawnerZdo is null)
        {
            return(true);
        }

        SpawnSessionContext context = new(spawnerZdo);

        foreach (var condition in template.SpawnConditions)
        {
            try
            {
                var validCondition = condition?.IsValid(context) ?? true;

                if (!validCondition)
                {
#if DEBUG && VERBOSE
                    Log.LogTrace($"Local Spawner '{spawner.name}', Invalid condition '{condition.GetType().Name}'");
#endif
                    return(false);
                }
            }
            catch (Exception e)
            {
                Log.LogError($"Error while attempting to check spawn condition '{condition?.GetType()?.Name}' for local spawner '{spawner.name}'. Ignoring condition", e);
            }
        }

        return(true);
    }
 internal static float GetChanceToLevelUp(float defaultChance, CreatureSpawner spawner)
 => LocalSpawnerManager.GetTemplate(spawner)?.LevelUpChance ?? defaultChance;