示例#1
0
        internal void CollectStack(EntityStack stackToCollect)
        {
            int id = stackToCollect.Id;

            // find first stack of same type
            foreach (Slot slot in Slots)
            {
                if (slot.Content.Id == id && !slot.IsFull)
                {
                    stackToCollect.TransferAll(slot.Content);
                    if (stackToCollect.IsEmpty)
                    {
                        return;
                    }
                }
            }

            // find first empty slot
            foreach (Slot slot in Slots)
            {
                if (slot.IsEmpty)
                {
                    slot.Content.Id = id;
                    stackToCollect.TransferAll(slot.Content);
                    return;
                }
            }
        }
示例#2
0
        internal void CollectStack(EntityStack stackToCollect)
        {
            int id = stackToCollect.Id;
            // find first stack of same type
            foreach (Slot slot in Slots)
            {
                if (slot.Content.Id == id && !slot.IsFull)
                {
                    stackToCollect.TransferAll(slot.Content);
                    if (stackToCollect.IsEmpty)
                        return;
                }
            }

            // find first empty slot
            foreach (Slot slot in Slots)
            {
                if (slot.IsEmpty)
                {
                    slot.Content.Id = id;
                    stackToCollect.TransferAll(slot.Content);
                    return;
                }
            }
        }
示例#3
0
 internal bool TransferAll(EntityStack destinationStack)
 {
     if (destinationStack.Count + Count > 64)
     {
         return(false);
     }
     TransferEntities(destinationStack, Count);
     return(true);
 }
示例#4
0
        internal void Swap(EntityStack swapStack)
        {
            int tempCount = this.count;
            int tempId    = this.Id;

            this.count      = swapStack.count;
            this.Id         = swapStack.Id;
            swapStack.count = tempCount;
            swapStack.Id    = tempId;
        }
示例#5
0
 internal void TransferEntities(EntityStack destinationStack, int transferCount)
 {
     if (!Compatible(destinationStack))
     {
         return;
     }
     destinationStack.Id = this.Id;
     if (destinationStack.Count + transferCount > 64)
     {
         transferCount = 64 - destinationStack.Count;
     }
     destinationStack.Add(transferCount);
     Remove(transferCount);
 }
示例#6
0
 internal void ThrowStack(EntityStack stack)
 {
     // drop items in crafting table and in hand...
     if (stack.IsEmpty)
     {
         return;
     }
     stack.Position    = Position + EyePosition;
     stack.Position.Y -= (float)(MathLibrary.GlobalRandom.NextDouble() * 0.5f);
     stack.Velocity    = Direction * 0.1f;
     stack.Yaw         = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Pitch       = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Velocity.X += (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0);
     stack.Velocity.Z += (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0);
     stack.Velocity.Y  = 0.2f + (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0);
     World.Instance.SpawnStack(stack);
     throwStackDelay = 20;
 }
示例#7
0
 internal Recepe Output(int id, int count)
 {
     Product = new EntityStack(id, count);
     return(this);
 }
示例#8
0
 internal void ThrowStack(EntityStack stack)
 {
     // drop items in crafting table and in hand...
     if (stack.IsEmpty)
         return;
     stack.Position = Position + EyePosition;
     stack.Position.Y -= (float)(MathLibrary.GlobalRandom.NextDouble() * 0.5f);
     stack.Velocity = Direction * 0.1f;
     stack.Yaw = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Pitch = (float)(MathLibrary.GlobalRandom.NextDouble() * Math.PI);
     stack.Velocity.X += (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0);
     stack.Velocity.Z += (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0);
     stack.Velocity.Y = 0.2f + (float)0.05f * (float)(MathLibrary.GlobalRandom.NextDouble() * 2.0 - 1.0);
     World.Instance.SpawnStack(stack);
     throwStackDelay = 20;
 }
示例#9
0
 internal void TransferEntities(EntityStack destinationStack, int transferCount)
 {
     if (!Compatible(destinationStack))
         return;
     destinationStack.Id = this.Id;
     if (destinationStack.Count + transferCount > 64)
     {
         transferCount = 64 - destinationStack.Count;
     }
     destinationStack.Add(transferCount);
     Remove(transferCount);
 }
示例#10
0
 internal bool TransferAll(EntityStack destinationStack)
 {
     if (destinationStack.Count + Count > 64)
         return false;
     TransferEntities(destinationStack, Count);
     return true;
 }
示例#11
0
 internal void Swap(EntityStack swapStack)
 {
     int tempCount = this.count;
     int tempId = this.Id;
     this.count = swapStack.count;
     this.Id = swapStack.Id;
     swapStack.count = tempCount;
     swapStack.Id = tempId;
 }
示例#12
0
 internal void ReplaceWithEmptyCompatibleStack(EntityStack stackInHand)
 {
     ReplaceWith(stackInHand.Id, 0);
 }
示例#13
0
 internal void ReplaceWith(EntityStack newStack)
 {
     Id = newStack.Id;
     count = newStack.Count;
 }
示例#14
0
 internal bool Compatible(EntityStack otherStack)
 {
     return otherStack.Id == Id || this.Id == 0 || otherStack.Id == 0;
 }
示例#15
0
 internal void SpawnStack(EntityStack stack)
 {
     PositionChunk positionChunk = PositionChunk.CreateFrom(stack.Position);
     Chunk chunk = GetChunk(positionChunk);
     chunk.AddEntity(stack);
 }
示例#16
0
 internal Recepe Output(int id, int count)
 {
     Product = new EntityStack(id, count);
     return this;
 }
示例#17
0
 internal bool Compatible(EntityStack otherStack)
 {
     return(otherStack.Id == Id || this.Id == 0 || otherStack.Id == 0);
 }
示例#18
0
 internal void ReplaceWithEmptyCompatibleStack(EntityStack stackInHand)
 {
     ReplaceWith(stackInHand.Id, 0);
 }
示例#19
0
 internal void ReplaceWith(EntityStack newStack)
 {
     Id    = newStack.Id;
     count = newStack.Count;
 }