コード例 #1
0
        public void Reset()
        {
            // It's possible that this is called before awake
            InitializeCollectionsIfNecessary();

            PlayButton.gameObject.SetActive(false);
            LobbyName.text = "";

            // Cleanup teams
            foreach (var team in Teams)
            {
                TeamsPool.Store(team.Value);
                team.Value.Reset();
            }

            Teams.Clear();

            // Cleanup users
            foreach (var user in Users)
            {
                UsersPool.Store(user.Value);
                user.Value.Reset();
            }

            Users.Clear();

            // Clear the chat
            if (Chat != null)
            {
                Chat.Clear();
            }
        }
コード例 #2
0
 public void CancelInternal(Task task)
 {
     if (!_active.Contains(task))
     {
         return;
     }
     _active.Remove(task);
     _taskPool.Store(task);
 }
コード例 #3
0
 public void RemoveObserver(int entity, int messageType, System.Action handler)
 {
     if (!_entityEvents.TryGetValue(entity, out var hub))
     {
         return;
     }
     hub.RemoveObserver(messageType, handler);
     if (hub.Count == 0)
     {
         _entityEvents.Remove(entity);
         _eventPool.Store(hub);
     }
 }
コード例 #4
0
ファイル: RulesSystem.cs プロジェクト: FuzzySlipper/Framework
        public T Post <T>(T context) where T : struct, IRuleEvent
        {
            _eventLog.Add(context);
            var list = _listPool.New();

            _globalHandlers.TryGetValue(typeof(T), out var globalList);
            if (globalList != null)
            {
                list.AddRange(globalList);
            }
            if (context.Origin.RuleEvents != null)
            {
                list.AddRange(context.Origin.RuleEvents.Handlers);
            }
            if (context.Target != context.Origin && context.Target.RuleEvents != null)
            {
                list.AddRange(context.Target.RuleEvents.Handlers);
            }
            if (context.Action != null &&
                context.Action.RuleEvents != null)
            {
                list.AddRange(context.Action.RuleEvents.Handlers);
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is IRuleEventStart <T> startHandler)
                {
                    if (!startHandler.CanRuleEventStart(ref context))
                    {
                        _listPool.Store(list);
                        return(context);
                    }
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is IRuleEventRun <T> handler)
                {
                    handler.RuleEventRun(ref context);
                }
            }
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i] is IRuleEventEnded <T> endHandler)
                {
                    endHandler.RuleEventEnded(ref context);
                }
            }
            _listPool.Store(list);
            return(context);
        }
コード例 #5
0
ファイル: ItemInventory.cs プロジェクト: Peng2017/Framework
 public bool Remove(Entity entity)
 {
     if (!Contains(entity))
     {
         return(false);
     }
     _array.Remove(entity);
     if (_entityLookup.TryGetValue(entity, out var cached))
     {
         _cachePool.Store(cached);
         _entityLookup.Remove(entity);
     }
     ProcessEntityRemoval(entity);
     OnRefreshItemList.SafeInvoke();
     return(true);
 }
コード例 #6
0
            private IEnumerator SetTargetText()
            {
                var tr = _floating.transform;

                tr.position           = _start;
                _floating._text.text  = _text;
                _floating._text.color = _color ?? _floating._defaultColor;
                _floating._moveTween.Restart(tr.position, _end, _duration);
                _floating._colorTween.Restart(0, 1, _duration);
                _timeoutTimer.RestartTimer();
                while (_floating._moveTween.Active)
                {
                    _floating._text.color = Color.Lerp(_floating._defaultColor, _floating._endColor, _floating._colorTween.Get());
                    tr.position           = _floating._moveTween.Get();
                    tr.LookAt(tr.position + Player.Cam.transform.rotation * Vector3.forward, PlayerCamera.Tr.rotation * Vector3.up);
                    //_text.fontSize = Vector3.Distance(transform.position, Player.Cam.transform.position) * 0.35f;
                    if (!_timeoutTimer.IsActive)
                    {
                        break;
                    }
                    yield return(null);
                }
                ItemPool.Despawn(_floating.gameObject);
                _floating    = null;
                _color       = null;
                SourcePrefab = null;
                NewPrefab    = null;
                _pool.Store(this);
            }
コード例 #7
0
 private void ClearSavedMuscles()
 {
     for (int i = 0; i < _currentMuscles.Count; i++)
     {
         _musclePool.Store(_currentMuscles[i]);
     }
     _currentMuscles.Clear();
 }
コード例 #8
0
        public bool Remove(Entity entity)
        {
            if (!Contains(entity))
            {
                return(false);
            }
            _array.Remove(entity);
            if (_entityLookup.TryGetValue(entity, out var cached))
            {
                _cachePool.Store(cached);
                _entityLookup.Remove(entity);
            }
            entity.Get <InventoryItem>()?.SetContainer(null);
            entity.ParentId = -1;
            var msg = new ContainerStatusChanged(null, entity);

            entity.Post(msg);
            this.GetEntity().Post(msg);
            return(true);
        }
コード例 #9
0
 public void ClearAll()
 {
     _threadLock.EnterWriteLock();
     foreach (var cell in _cells)
     {
         _cellPool.Store(cell.Value);
     }
     _cellKeys.Clear();
     _cells.Clear();
     _oldPlayerOccupied.Clear();
     _oldPlayerWalkable.Clear();
     CellsCount = 0;
     _threadLock.ExitWriteLock();
 }
コード例 #10
0
ファイル: UIInventory.cs プロジェクト: FuzzySlipper/Framework
            public override void OnComplete()
            {
                var itemDragDrop = NewPrefab.GetComponent <UIItemDragDrop>();

                itemDragDrop.RectTransform.SetParent(_inventory._grid);
                itemDragDrop.Index = _index;
                itemDragDrop.SetItem(_item);
                _inventory._slots[_index] = itemDragDrop;

                _item        = null;
                _inventory   = null;
                SourcePrefab = null;
                NewPrefab    = null;
                _pool.Store(this);
            }
コード例 #11
0
 public static void Remove(ITurnBasedUnit unit)
 {
     if (_queueActivate.Contains(unit))
     {
         _queueActivate.Remove(unit);
     }
     else
     {
         var node = GetNode(unit);
         if (node != null)
         {
             _active.Remove(node);
             _nodePool.Store(node);
         }
     }
 }
コード例 #12
0
        //public void AddAnimation1(SpriteAnimation animation, SpriteRenderer renderer, bool unscaled) {
        //    var node = _pool1.New();
        //    node.Setup(renderer, animation, unscaled);
        //    _current1.Add(node);
        //}

        public void OnSystemUpdate(float dt, float unscaledDt)
        {
            var time = TimeManager.TimeUnscaled;

            for (int i = _current.Count - 1; i >= 0; i--)
            {
                _current[i].UpdateSpriteFrame(time);
                if (_current[i].Finished)
                {
                    _pool.Store(_current[i]);
                    _current.RemoveAt(i);
                }
            }
            //for (int i = _current1.Count - 1; i >= 0; i--) {
            //    _current1[i].UpdateMesh();
            //    if (_current1[i].Finished) {
            //        _pool1.Store(_current1[i]);
            //        _current1.RemoveAt(i);
            //    }
            //}
        }
コード例 #13
0
ファイル: LoadingUi.cs プロジェクト: Avatarchik/ProjectVerse
        protected virtual void OnLoadingFinished(EventsChannel.Promise promise)
        {
            LoadingUiItem item;

            _visibleLoadingItems.TryGetValue(promise.EventId, out item);

            if (item == null)
            {
                return;
            }

            // Remove the item
            _visibleLoadingItems.Remove(promise.EventId);
            _pool.Store(item);

            // if everything is done loading, we can disable the loading view
            if (_visibleLoadingItems.Count == 0)
            {
                gameObject.SetActive(false);
            }
        }
コード例 #14
0
            private IEnumerator SetTargetText()
            {
                var tr = _floating.transform;

                tr.position          = _start;
                _floating._text.text = _text;
                _floating._moveTween.Restart(tr.position, _end, _duration);
                _floating._colorTween.Restart(0, 1, _duration);
                _timeoutTimer.RestartTimer();
                while (_floating._moveTween.Active)
                {
                    _floating._text.color = Color.Lerp(_startColor, _floating._endColor, _floating._colorTween.Get());
                    tr.position           = _floating._moveTween.Get();
                    yield return(null);
                }
                ItemPool.Despawn(_floating.gameObject);
                _floating    = null;
                _parent      = null;
                _icon        = null;
                SourcePrefab = null;
                NewPrefab    = null;
                _pool.Store(this);
            }
コード例 #15
0
 public override void Pool()
 {
     _actionPool.Store(this);
 }
コード例 #16
0
 public static void Store(MenuAction t1)
 {
     _actionPool.Store(t1);
 }