Beispiel #1
0
        private void _buffAdd()
        {
            var type = typeof(TestBuff);

            for (int i = 0; i < 5000; i++)
            {
                var i1   = i;
                var buff = _buffManage.CreateAndAddBuff(type, _entity, x => { ((TestBuff)x).name = i1.ToString(); });
            }
        }
Beispiel #2
0
        public override void Execute(IEntity entity)
        {
            BuffManager.GetBuffs(entity, x => x.MechanicsType == MechanicsType.Health, _buffs);

            var buff = _buffs[0];

            if (buff.Value <= 0)
            {
                BuffManager.CreateAndAddBuff <Death>(entity, null);
            }
        }
        public void 添加buff_引用缓存()
        {
            var type = typeof(TestBuff);

            _startMemory = GC.GetTotalMemory(false);

            for (int i = 0; i < 5000; i++)
            {
                var i1 = i;
                _buffManage.CreateAndAddBuff(type, _entity, /*x => { ((TestBuff) x).name = i1.ToString();}*/ null);
            }
            _setEndMemory();
            Debug.Log($"{_startMemory} and {_endMemory} = {(_endMemory - _startMemory)}");
            List <IBuffDataComponent> buffs = new List <IBuffDataComponent>();

            _buffManage.GetBuffs(_entity, buffs);

            Assert.GreaterOrEqual(buffs.Count, 5000);
        }
        public override void Execute(IEntity entity)
        {
            BuffManager.GetBuffs(entity, _continuousBuffs);
            for (var i = 0; i < _continuousBuffs.Count; i++)
            {
                var buff = _continuousBuffs[i];

                if (buff.LastTriggerTime - buff.Duration >= buff.TriggerInterval)
                {
                    buff.LastTriggerTime = buff.Duration;

                    BuffManager.CreateAndAddBuff <T>(entity, x =>
                    {
                        x.Maker = buff.Maker;
                        x.Type  = buff.Type;
                        x.Value = buff.Value;
                    });
                }
            }
        }