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); }
public UseRecyclableComponent(RecyclableComponent dependency) { Dependency = dependency; }