CampaignEvents
Start events
OnNewGameCreatedEvent
Only when new game is started
CampaignEvents.OnNewGameCreatedEvent.AddNonSerializedListener(this, new Action<CampaignGameStarter>(this.OnNewGameCreated));
OnSessionLaunchedEvent
On new game + on old game loaded
CampaignEvents.OnSessionLaunchedEvent.AddNonSerializedListener(this, new Action<CampaignGameStarter>(this.OnSessionLaunched));
Periodic events
HourlyTickEvent
Every hour
DailyTickEvent
Every day
WeeklyTickEvent
Every week (7 days)
Template
using System;
using TaleWorlds.CampaignSystem;
namespace Your_Workspace
{
internal class TemplateBehavior : CampaignBehaviorBase
{
public static TemplateBehavior? Instance { get; set; }
readonly bool _debug = false;
public TemplateBehavior()
{
Instance = this;
}
public override void SyncData(IDataStore dataStore) { }
public override void RegisterEvents()
{
CampaignEvents.OnSessionLaunchedEvent.AddNonSerializedListener(this, new Action<CampaignGameStarter>(this.OnSessionLaunched));
CampaignEvents.OnNewGameCreatedEvent.AddNonSerializedListener(this, new Action<CampaignGameStarter>(this.OnNewGameCreated));
CampaignEvents.HourlyTickEvent.AddNonSerializedListener(this, HourlyTickEvent);
CampaignEvents.DailyTickEvent.AddNonSerializedListener(this, DailyTickEvent);
CampaignEvents.WeeklyTickEvent.AddNonSerializedListener(this, WeeklyTickEvent);
}
private void OnNewGameCreated(CampaignGameStarter starter)
{
}
private void OnSessionLaunched(CampaignGameStarter starter)
{
}
private void HourlyTickEvent()
{
}
private void DailyTickEvent()
{
}
private void WeeklyTickEvent()
{
}
}
}