Пример #1
0
    public static int MakeDamageIfDamageableGameObject(GameObject gameObject, Damage damage, LogMode logMode = LogMode.Enable)
    {
        // if failed to find the main script, try to find the damageable component directly
        // (some objects may contain NO main script, but do contain the damageable component)
        IDamageableComponent damageable = gameObject.GetComponent <IDamageableComponent>();

        if (damageable != null)
        {
            return(damageable.MakeDamage(damage));
        }
        else
        {
            LogUtils.LogWarningIf(logMode, "{gameObject.name} does NOT contain damageable component");
        }

        return(0);
    }