📊 Arquitetura
O EventTracker segue o padrão Publish/Subscribe. Quando um evento é disparado, todos os listeners registrados para aquele tipo são notificados automaticamente.
Criando um EventListener
using Sims3.Gameplay.EventSystem;
namespace SeuMod.EventListeners
{
public class RelationshipChangeListener : EventListener
{
public override ListenerAction ProcessEvent(Event e)
{
if (e is RelationshipEvent relEvent)
{
SimDescription simA = relEvent.SimDescriptionA;
SimDescription simB = relEvent.SimDescriptionB;
// Sua lógica aqui
LogRelationshipChange(simA, simB);
return ListenerAction.KeepListening;
}
return ListenerAction.KeepListening;
}
public override bool DoesEventApply(Event e)
{
return e.Id == EventTypeId.kRelationshipLTRChanged;
}
}
}
Registrando Listeners
// No ModMain.cs
private static RelationshipChangeListener sListener;
private static void OnWorldLoadFinished(object sender, EventArgs e)
{
sListener = new RelationshipChangeListener();
EventTracker.AddListener(EventTypeId.kRelationshipLTRChanged, sListener);
}
// Limpeza (importante!)
public static void Cleanup()
{
if (sListener != null)
{
EventTracker.RemoveListener(EventTypeId.kRelationshipLTRChanged, sListener);
}
}
Principais Eventos
kSimCreatedkSimDeathkAgedUpkCareerChangedkSkillGainedkTraitGainedkBuffAddedkBuffRemovedkRelationshipLTRChangedkSocialEventkWooHookMarriagekDivorcekPregnancykBirthkInteractionSuccessExemplo: Detectar WooHoo
public class WooHooDetector : EventListener
{
public override ListenerAction ProcessEvent(Event e)
{
if (e.Id == EventTypeId.kWooHoo)
{
WooHooEvent wooEvent = e as WooHooEvent;
Sim simA = wooEvent.SimA as Sim;
Sim simB = wooEvent.SimB as Sim;
// Adicionar buff especial
if (simA != null)
{
simA.BuffManager.AddElement(
BuffNames.FeelingVeryConfident,
Origin.FromCustomSource
);
}
if (simB != null)
{
simB.BuffManager.AddElement(
BuffNames.FeelingVeryConfident,
Origin.FromCustomSource
);
}
}
return ListenerAction.KeepListening;
}
public override bool DoesEventApply(Event e)
{
return e.Id == EventTypeId.kWooHoo;
}
}