Пример #1
0
 private void RemoveAspect([NotNull] Aspect affinity)
 {
     _aspects.Remove(affinity);
     try
     {
         affinity.PostRemove();
         AspectRemoved?.Invoke(this, affinity);
     }
     catch (Exception e)
     {
         Log.Error($"caught {e.GetType().Name} while removing aspect {affinity.Label}/{affinity.def.defName}\n{e}");
     }
 }
Пример #2
0
        /// <summary>
        ///     called every tick after it's parent is updated
        /// </summary>
        public override void CompTick()
        {
            base.CompTick();

            if (_rmCache.Count != 0)
            {
                foreach (Aspect affinity in _rmCache) //remove the affinities here so we don't invalidate the enumerator below
                {
                    _aspects.Remove(affinity);
                    affinity.PostRemove();
                    AspectRemoved?.Invoke(this, affinity);
                }

                _rmCache.Clear();
            }

            foreach (Aspect affinity in _aspects)
            {
                affinity.PostTick();
            }
        }