Exemple #1
0
        // Called when a module is unmounted on the module mount
        protected virtual void OnModuleUnmounted(Module module)
        {
            Damageable damageable = module.GetComponent <Damageable>();

            if (damageable != null)
            {
                // Unlink this
                damageable.onDamaged.RemoveListener(OnDamageableModuleDamaged);
                damageable.onHealed.RemoveListener(OnDamageableModuleHealed);
                damageable.onDestroyed.RemoveListener(OnDamageableModuleDestroyed);
                damageable.onRestored.RemoveListener(OnDamageableModuleRestored);

                for (int i = 0; i < damageReceivers.Count; ++i)
                {
                    damageReceivers[i].SetDamageable(null);
                }
            }
        }
        // Called when a module is unmounted on the module mount
        protected virtual void OnModuleUnmounted(Module module)
        {
            Damageable damageable = module.GetComponent <Damageable>();

            if (damageable != null)
            {
                // Unlink this
                damageable.onDamaged.RemoveListener(OnDamageableModuleDamaged);
                damageable.onHealed.RemoveListener(OnDamageableModuleHealed);
                damageable.onDestroyed.RemoveListener(OnDamageableModuleDestroyed);
                damageable.onRestored.RemoveListener(OnDamageableModuleRestored);

                for (int i = 0; i < damageReceivers.Count; ++i)
                {
                    damageReceivers[i].onDamaged.RemoveListener(damageable.Damage);
                    damageReceivers[i].onHealed.RemoveListener(damageable.Heal);
                    damageReceivers[i].onCollision.RemoveListener(damageable.OnCollision);

                    DamageReceiver damageReceiver = damageReceivers[i];     // Can't create lambda expressions from a list element without errors
                    damageable.onDestroyed.RemoveListener(delegate { damageReceiver.SetActivation(false); });
                    damageable.onRestored.RemoveListener(delegate { damageReceiver.SetActivation(true); });
                }
            }
        }
Exemple #3
0
 protected virtual void Reset()
 {
     damageable = GetComponent <Damageable>();
 }