using System; namespace MoleMole { public class LevelQALoggingPlugin : BaseActorPlugin { public LevelActor _levelActor; public LevelQALoggingPlugin(LevelActor levelActor) { _levelActor = levelActor; } public override void OnAdded() { Singleton.Instance.RegisterEventListener(_levelActor.runtimeID); Singleton.Instance.RegisterEventListener(_levelActor.runtimeID); Singleton.Instance.RegisterEventListener(_levelActor.runtimeID); Singleton.Instance.RegisterEventListener(_levelActor.runtimeID); Singleton.Instance.RegisterEventListener(_levelActor.runtimeID); } public override void OnRemoved() { Singleton.Instance.RemoveEventListener(_levelActor.runtimeID); Singleton.Instance.RemoveEventListener(_levelActor.runtimeID); Singleton.Instance.RemoveEventListener(_levelActor.runtimeID); Singleton.Instance.RemoveEventListener(_levelActor.runtimeID); Singleton.Instance.RemoveEventListener(_levelActor.runtimeID); } public override bool ListenEvent(BaseEvent evt) { if (evt is EvtAvatarCreated) { return ListenAvatarCreated((EvtAvatarCreated)evt); } if (evt is EvtMonsterCreated) { return ListenMonsterCreated((EvtMonsterCreated)evt); } if (evt is EvtKilled) { return ListenKilled((EvtKilled)evt); } if (evt is EvtAttackLanded) { return ListenAttackLanded((EvtAttackLanded)evt); } if (evt is EvtDamageLanded) { return ListenDamageLanded((EvtDamageLanded)evt); } return false; } private bool ListenAvatarCreated(EvtAvatarCreated evt) { AvatarActor avatarActor = Singleton.Instance.GetActor(evt.avatarID); AvatarActor avatarActor2 = avatarActor; avatarActor2.onAbilityStateAdd = (Action)Delegate.Combine(avatarActor2.onAbilityStateAdd, (Action)delegate(AbilityState state, bool muteDisplay) { DebugLog("{0} 开始Buff/Debuff: {1}", Miscs.GetDebugActorName(avatarActor), state); }); AvatarActor avatarActor3 = avatarActor; avatarActor3.onAbilityStateRemove = (Action)Delegate.Combine(avatarActor3.onAbilityStateRemove, (Action)delegate(AbilityState state) { DebugLog("{0} 停止Buff/Debuff: {1}", Miscs.GetDebugActorName(avatarActor), state); }); AvatarActor avatarActor4 = avatarActor; avatarActor4.onHPChanged = (Action)Delegate.Combine(avatarActor4.onHPChanged, (Action)delegate(float orig, float newValue, float amount) { if (amount > 0f) { DebugLog("{0} 回复HP {1}, 新 HP 值为 {2}", Miscs.GetDebugActorName(avatarActor), amount, newValue); } }); AvatarActor avatarActor5 = avatarActor; avatarActor5.onSPChanged = (Action)Delegate.Combine(avatarActor5.onSPChanged, (Action)delegate(float orig, float newValue, float amount) { if (amount > 0f) { DebugLog("{0} 回复SP {1},新 SP 值为 {2}", Miscs.GetDebugActorName(avatarActor), amount, newValue); } }); BaseMonoAbilityEntity entity = avatarActor.entity; entity.onActiveChanged = (Action)Delegate.Combine(entity.onActiveChanged, (Action)delegate(bool active) { DebugLog("{0} {1}", Miscs.GetDebugActorName(avatarActor), (!active) ? "下场" : "上场"); }); BaseMonoAbilityEntity entity2 = avatarActor.entity; entity2.onCurrentSkillIDChanged = (Action)Delegate.Combine(entity2.onCurrentSkillIDChanged, (Action)delegate(string from, string to) { DebugLog("{0} SkillID 变动为 {1}", Miscs.GetDebugActorName(avatarActor), (to != null) ? to : ""); }); return true; } private bool ListenMonsterCreated(EvtMonsterCreated evt) { MonsterActor monsterActor = Singleton.Instance.GetActor(evt.monsterID); MonsterActor monsterActor2 = monsterActor; monsterActor2.onAbilityStateAdd = (Action)Delegate.Combine(monsterActor2.onAbilityStateAdd, (Action)delegate(AbilityState state, bool muteDisplay) { DebugLog("{0} 开始Buff/Debuff: {1}", Miscs.GetDebugActorName(monsterActor), state); }); MonsterActor monsterActor3 = monsterActor; monsterActor3.onAbilityStateRemove = (Action)Delegate.Combine(monsterActor3.onAbilityStateRemove, (Action)delegate(AbilityState state) { DebugLog("{0} 停止Buff/Debuff: {1}", Miscs.GetDebugActorName(monsterActor), state); }); MonsterActor monsterActor4 = monsterActor; monsterActor4.onHPChanged = (Action)Delegate.Combine(monsterActor4.onHPChanged, (Action)delegate(float orig, float newValue, float amount) { if (amount > 0f) { DebugLog("{0} 回复HP {1}, 新 HP 值为 {2}", Miscs.GetDebugActorName(monsterActor), amount, newValue); } }); BaseMonoAbilityEntity entity = monsterActor.entity; entity.onCurrentSkillIDChanged = (Action)Delegate.Combine(entity.onCurrentSkillIDChanged, (Action)delegate(string from, string to) { DebugLog("{0} SkillID 变动为 {1}", Miscs.GetDebugActorName(monsterActor), (to != null) ? to : ""); }); return true; } private bool ListenKilled(EvtKilled evt) { if (Singleton.Instance.ParseCategory(evt.targetID) == 3 || Singleton.Instance.ParseCategory(evt.targetID) == 4) { DebugLog("{0} 被 {1} 杀死", Miscs.GetDebugActorName(Singleton.Instance.GetActor(evt.targetID)), Miscs.GetDebugActorName(Singleton.Instance.GetActor(evt.killerID))); return true; } return false; } private bool ListenAttackLanded(EvtAttackLanded evt) { ushort num = Singleton.Instance.ParseCategory(evt.targetID); ushort num2 = Singleton.Instance.ParseCategory(evt.attackeeID); if ((num == 3 || num == 4) && (num2 == 3 || num2 == 4)) { DebugLog("{0} 外在攻击到 {1} 成功, 判定 ID {2}, 攻击结果 {3}", Miscs.GetDebugActorName(Singleton.Instance.GetActor(evt.targetID)), Miscs.GetDebugActorName(Singleton.Instance.GetActor(evt.attackeeID)), (evt.animEventID != null) ? evt.animEventID : "", evt.attackResult.GetDebugOutput()); } return true; } private bool ListenDamageLanded(EvtDamageLanded evt) { ushort num = Singleton.Instance.ParseCategory(evt.targetID); ushort num2 = Singleton.Instance.ParseCategory(evt.attackeeID); if ((num == 3 || num == 4) && (num2 == 3 || num2 == 4)) { DebugLog("{0} 内在攻击到 {1} 成功,攻击结果 {2}", Miscs.GetDebugActorName(Singleton.Instance.GetActor(evt.targetID)), Miscs.GetDebugActorName(Singleton.Instance.GetActor(evt.attackeeID)), evt.attackResult.GetDebugOutput()); } return true; } private void DebugLog(string format, params object[] args) { } } }