private void AddSkillBuffToUnit(Soldier s) { if (s == null || !s.Alive()) { return; } List <AttributeEffect> attributeEffects = new List <AttributeEffect>(); for (int i = 0; i < base.attributeEffects.Count; i++) { int buffId = base.attributeEffects[i]; AttributeEffect ae = GenerateAttributeEffect(buffId); // Notice skill the buff has been detached for some reason, maybe the unit has been dead ae.RegisterNoticeGiverDestroyMethod((b) => { if (attributeEffectOwnerDic.ContainsKey(b.taker.id)) { attributeEffectOwnerDic[b.taker.id].Remove(b); if (attributeEffectOwnerDic[b.taker.id].Count == 0) { attributeEffectOwnerDic.Remove(b.taker.id); } } }); ae.Attach(owner, s); attributeEffects.Add(ae); } attributeEffectOwnerDic.Add(s.id, attributeEffects); }
public override void Attach(LogicUnit g, LogicUnit t) { base.Attach(g, t); if (t.type == LogicUnitType.Soldier) { soldier = (Soldier)t; if (ownerDebuff.sneerEffect == null && soldier != null && soldier.Alive()) { if (!soldier.GetFlag(SoldierAttributeFlags.BanSkill)) { soldier.SetFlag(SoldierAttributeFlags.BanSkill); } soldier.skillHandler.SetHandlerEnabled(false); if (!soldier.GetFlag(SoldierAttributeFlags.BanCommand)) { soldier.SetFlag(SoldierAttributeFlags.BanCommand); } ownerDebuff.sneerEffect = this; soldier.ClearPathRender(); soldier.Chase(g); } } else { DebugUtils.LogError(DebugUtils.Type.AI_AttributeEffect, string.Format("{0} {1} can't handle debuff now!", t.type, t.id)); } }