public void CannotUnslotIfUnattached() { var small = this.SlottableRequiring(2); var unslot = new GameEvent_Unslot(null, this.slottedContainer, small); Assert.Throws <ArgumentException>(() => this.slottedContainer.HandleEvent(unslot)); }
private void HandleUnslot(GameEvent_Unslot ev) { if (ev.ExecutorEntity == this.Parent) { if (!this.storedEntities.Contains(ev.EntityToUnslot)) { throw new ArgumentException("Cannot detach unattached item " + ev.EntityToUnslot.ToString() + "!"); } this.storedEntities.Remove(ev.EntityToUnslot); ev.Completed = true; } }
public void CanUnslot() { var small = this.SlottableRequiring(2); var ev = new GameEvent_Slot(this.slottedContainer, this.slottedContainer, small); this.slottedContainer.HandleEvent(ev); var unslot = new GameEvent_Unslot(this.slottedContainer, this.slottedContainer, small); this.slottedContainer.HandleEvent(unslot); Assert.IsTrue(unslot.Completed); Assert.AreEqual(this.containerSize, this.slottedContainer.GetComponentOfType <Component_SlottedContainer>().SlotsRemaining); }
private void HandleUnslot(GameEvent_Unslot ev) { if (ev.ExecutorEntity == this.Parent) { if (this.attachedEntity != ev.EntityToUnslot) { throw new ArgumentException("Cannot unmount unmounted item " + ev.EntityToUnslot.ToString() + "!"); } this.attachedEntity = null; ev.EntityToUnslot.GetComponentOfType <Component_Attachable>().Notify_Detached(); ev.Completed = true; } }