bool HasEffectWithIcon(EntityEffectManager.InstancedBundle bundle) { // At least one effect with remaining rounds must want to show an icon foreach (IEntityEffect effect in bundle.liveEffects) { if (effect.Properties.ShowSpellIcon && effect.RoundsRemaining > 0) { return(true); } } return(false); }
void UpdateIcons() { ClearIcons(); // Get all effect bundles currently operating on player EntityEffectManager playerEffectManager = GameManager.Instance.PlayerEffectManager; EntityEffectManager.InstancedBundle[] effectBundles = playerEffectManager.EffectBundles; if (effectBundles == null || effectBundles.Length == 0) { return; } // Sort icons into active spells in self and other icon lists for (int i = 0; i < effectBundles.Length; i++) { EntityEffectManager.InstancedBundle bundle = effectBundles[i]; // Don't add effect icon for instant spells, must have at least 1 round remaining bool showIcon = HasEffectWithIcon(bundle); int maxRoundsRemaining = GetMaxRoundsRemaining(bundle); if (!showIcon || maxRoundsRemaining == 0) { continue; } // Setup icon information and sort into self (player is caster) or other (player not caster) // Need to check where spells cast by RDB actions are placed (e.g. click skull to cast levitate) // And offensive spells the player catches themselves with // Will need to refine how this works as more effects and situations become available ActiveSpellIcon item = new ActiveSpellIcon(); item.displayName = bundle.name; item.iconIndex = bundle.iconIndex; item.poolIndex = i; item.expiring = (maxRoundsRemaining <= 2) ? true : false; if (bundle.caster == null || bundle.caster != GameManager.Instance.PlayerEntityBehaviour) { activeOtherList.Add(item); } else { activeSelfList.Add(item); } } // Update icon panels in pooled collection AlignIcons(activeSelfList, classicSelfStartX, classicSelfStartY, classicIconDim, classicIconDim, classicHorzSpacing); AlignIcons(activeOtherList, classicOtherStartX, classicOtherStartY, classicIconDim, classicIconDim, classicHorzSpacing); }
int GetMaxRoundsRemaining(EntityEffectManager.InstancedBundle bundle) { // Get most remaining rounds of all effects // A spell can have multiple effects with different round durations int maxRoundsRemaining = 0; foreach (IEntityEffect effect in bundle.liveEffects) { if (effect.RoundsRemaining > maxRoundsRemaining) { maxRoundsRemaining = effect.RoundsRemaining; } } return(maxRoundsRemaining); }