Пример #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;
 }