Beispiel #1
0
        public void CannotUnslotIfUnattached()
        {
            var small  = this.SlottableRequiring(2);
            var unslot = new GameEvent_Unslot(null, this.slottedContainer, small);

            Assert.Throws <ArgumentException>(() => this.slottedContainer.HandleEvent(unslot));
        }
Beispiel #2
0
        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;
            }
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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;
            }
        }