Exemplo n.º 1
0
        private void Recycle(RecyclableComponent component, float efficiency = 1f)
        {
            if (!string.IsNullOrEmpty(component.Prototype))
            {
                var xform = Transform(component.Owner);

                for (var i = 0; i < Math.Max(component.Amount * efficiency, 1); i++)
                {
                    Spawn(component.Prototype, xform.Coordinates);
                }
            }

            QueueDel(component.Owner);
        }
        public void Recyclable_component_with_on_release_action_not_released_more_than_necessary()
        {
            var count = 0;

            Kernel.Register(Component.For <RecyclableComponent>().LifeStyle.PooledWithSize(1, null)
                            .DynamicParameters((k, d) =>
            {
                count++;
                return(delegate { count--; });
            }));

            RecyclableComponent component = null;

            for (var i = 0; i < 10; i++)
            {
                component = Kernel.Resolve <RecyclableComponent>();
                Container.Release(component);
            }
            Assert.AreEqual(10, component.RecycledCount);
            Assert.AreEqual(0, count);
        }
Exemplo n.º 3
0
		public UseRecyclableComponent(RecyclableComponent dependency)
		{
			Dependency = dependency;
		}
Exemplo n.º 4
0
 public UseRecyclableComponent(RecyclableComponent dependency)
 {
     Dependency = dependency;
 }