Пример #1
0
        /// <summary>
        /// A special case for ThreatMonitor+Grudge.Calm due to the source being a struct.
        /// </summary>
        private static PopFX SpawnFXThreat(PopFXManager instance, Sprite icon, string text,
                                           Transform targetTransform, float lifetime, bool track_target)
        {
            PopFX popup = null;

            if (ToastControlPopups.Options.Forgiveness)
            {
                popup = instance.SpawnFX(icon, text, targetTransform, lifetime, track_target);
            }
            return(popup);
        }
 protected override void OnSpawn()
 {
     base.OnSpawn();
     ready = true;
     if (!GenericGameSettings.instance.disablePopFx)
     {
         for (int i = 0; i < 20; i++)
         {
             PopFX item = CreatePopFX();
             Pool.Add(item);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Common transpiled target method for each use of PopFXManager.SpawnFX.
        /// </summary>
        private static PopFX SpawnFXShort(PopFXManager instance, Sprite icon, string text,
                                          Transform targetTransform, float lifetime, bool track_target, object source)
        {
            PopFX popup = null;
            bool  show  = true;

            try {
                // Parameter count cannot be reduced - in order to conform with Klei method
                show = ToastControlPopups.ShowPopup(source, text);
            } catch (Exception e) {
                // Sometimes this gets executed on a background thread and unhandled exceptions
                // cause a CTD
                PUtil.LogException(e);
            }
            if (show)
            {
                popup = instance.SpawnFX(icon, text, targetTransform, lifetime, track_target);
            }
            return(popup);
        }
    public PopFX SpawnFX(Sprite icon, string text, Transform target_transform, Vector3 offset, float lifetime = 1.5f, bool track_target = false, bool force_spawn = false)
    {
        if (GenericGameSettings.instance.disablePopFx)
        {
            return(null);
        }
        if (Game.IsQuitting())
        {
            return(null);
        }
        Vector3 vector = offset;

        if ((Object)target_transform != (Object)null)
        {
            vector += target_transform.GetPosition();
        }
        if (!force_spawn)
        {
            int cell = Grid.PosToCell(vector);
            if (!Grid.IsValidCell(cell) || !Grid.IsVisible(cell))
            {
                return(null);
            }
        }
        PopFX popFX = null;

        if (Pool.Count > 0)
        {
            popFX = Pool[0];
            Pool[0].gameObject.SetActive(true);
            Pool[0].Spawn(icon, text, target_transform, offset, lifetime, track_target);
            Pool.RemoveAt(0);
        }
        else
        {
            popFX = CreatePopFX();
            popFX.gameObject.SetActive(true);
            popFX.Spawn(icon, text, target_transform, offset, lifetime, track_target);
        }
        return(popFX);
    }
 public void RecycleFX(PopFX fx)
 {
     Pool.Add(fx);
 }