/// <summary> /// Queues a spell to cast on this Foe. /// </summary> /// <param name="spell">Spell to cast.</param> public void QueueSpell(SpellReference spell) { if (spellQueue == null) { spellQueue = new List <SpellReference>(); } spellQueue.Add(spell); }
public override void RestoreSaveData(object dataIn) { if (dataIn == null) { return; } SaveData_v1 data = (SaveData_v1)dataIn; spell = data.spell; foeSymbol = data.foeSymbol; }
public void CastSpellQueue(Foe foe, DaggerfallEntityBehaviour enemyEntityBehaviour) { // Validate if (!enemyEntityBehaviour || foe == null || foe.SpellQueue == null || foeSpellQueuePosition == foe.SpellQueue.Count) { return; } // Target entity must be alive if (enemyEntityBehaviour.Entity.CurrentHealth == 0) { return; } // Get effect manager on enemy EntityEffectManager enemyEffectManager = enemyEntityBehaviour.GetComponent <EntityEffectManager>(); if (!enemyEffectManager) { return; } // Cast queued spells on foe from current position for (int i = foeSpellQueuePosition; i < foe.SpellQueue.Count; i++) { SpellReference spell = foe.SpellQueue[i]; EntityEffectBundle spellBundle = null; // Create classic or custom spell bundle if (string.IsNullOrEmpty(spell.CustomKey)) { // Get classic spell data SpellRecord.SpellRecordData spellData; if (!GameManager.Instance.EntityEffectBroker.GetClassicSpellRecord(spell.ClassicID, out spellData)) { continue; } // Create classic spell bundle settings EffectBundleSettings bundleSettings; if (!GameManager.Instance.EntityEffectBroker.ClassicSpellRecordDataToEffectBundleSettings(spellData, BundleTypes.Spell, out bundleSettings)) { continue; } // Create classic spell bundle spellBundle = new EntityEffectBundle(bundleSettings, enemyEntityBehaviour); } else { // Create custom spell bundle - must be previously registered to broker try { EntityEffectBroker.CustomSpellBundleOffer offer = GameManager.Instance.EntityEffectBroker.GetCustomSpellBundleOffer(spell.CustomKey); spellBundle = new EntityEffectBundle(offer.BundleSetttings, enemyEntityBehaviour); } catch (Exception ex) { Debug.LogErrorFormat("QuestResourceBehaviour.CastSpellQueue() could not find custom spell offer with key: {0}, exception: {1}", spell.CustomKey, ex.Message); } } // Assign spell bundle to enemy if (spellBundle != null) { enemyEffectManager.AssignBundle(spellBundle, AssignBundleFlags.BypassSavingThrows); } } // Set index positon to end of queue foeSpellQueuePosition = foe.SpellQueue.Count; }