protected override void OnEnterCombat() { base.OnEnterCombat(); if (m_target != null) { // add Target into threat collection m_threatCollection.AddNewIfNotExisted(m_target); } }
public void TestThreatCollection() { var collection = new ThreatCollection(); var npc1 = CreateDummy(1); var npc2 = CreateDummy(2); var npc3 = CreateDummy(3); collection.AddNewIfNotExisted(npc1); Assert.AreEqual(npc1, collection.CurrentAggressor); collection.AddNewIfNotExisted(npc2); Assert.AreEqual(npc1, collection.CurrentAggressor); collection[npc2] = 10000; Assert.AreEqual(npc2, collection.CurrentAggressor); collection[npc3] = 1000000; Assert.AreEqual(npc3, collection.CurrentAggressor); collection[npc3] = 1; Assert.AreEqual(npc2, collection.CurrentAggressor); Assert.AreEqual(3, collection.Size); collection.Remove(npc2); Assert.AreEqual(npc3, collection.CurrentAggressor); collection.Remove(npc3); Assert.AreEqual(npc1, collection.CurrentAggressor); collection.Remove(npc1); Assert.AreEqual(null, collection.CurrentAggressor); }