예제 #1
0
 private void BlockChanged(Vector3i pos)
 {
     if (entry.GetLinker() != null)
     {
         Vector3i startPosition = Position3i + Vector3i.Up * 3;
         for (int i = -1; i <= 1; i++)
         {
             for (int j = -1; j <= 1; j++)
             {
                 if (pos == startPosition + new Vector3i(i, 0, j))
                 {
                     Type blockType = World.GetBlock(pos).GetType();
                     if (blockType == typeof(EmptyBlock))
                     {
                         continue;
                     }
                     BlockItem       item = BlockItem.CreatingItem(blockType);
                     ConnectorObject obj  = entry.GetLinker().GetFirstValidOutput(this, item.GetType());
                     if (obj == null)
                     {
                         continue;
                     }
                     obj.Output.GetComponent <PublicStorageComponent>().Inventory.TryAddItem(item);
                     World.DeleteBlock(pos);
                 }
             }
         }
     }
 }
예제 #2
0
        public override InteractResult OnActInteract(InteractionContext context)
        {
            List <KeyValuePair <Type, int> > itemsList = new List <KeyValuePair <Type, int> >();

            itemsList = MainEntry.GetLinker().GetAllItemsInput(this);

            foreach (var kvp in itemsList)
            {
                Console.WriteLine($"{kvp.Value} : {kvp.Key.ToString().Split('.').Last()}");
            }
            return(base.OnActInteract(context));
        }
예제 #3
0
        public override void Tick()
        {
            actualMiningTime += WorldObjectManager.TickDeltaTime;
            if (actualMiningTime >= MINING_TIME && Operating)
            {
                Vector3i previousMiningBlock = blockMinedPos;
                blockMinedPos += Rotation.Right.Floor;
                int testPos = 0;
                if (Rotation.Right.Floor.x < 0)
                {
                    testPos = -blockMinedPos.x;
                }
                else if (Rotation.Right.Floor.x > 0)
                {
                    testPos = blockMinedPos.x;
                }
                else if (Rotation.Right.Floor.z < 0)
                {
                    testPos = -blockMinedPos.z;
                }
                else if (Rotation.Right.Floor.z > 0)
                {
                    testPos = blockMinedPos.z;
                }
                if (testPos == (MINING_SIZE / 2) + 1)
                {
                    blockMinedPos += Rotation.Forward.Floor;
                    blockMinedPos += -Rotation.Right.Floor * MINING_SIZE;
                }

                if (Rotation.Forward.Floor.x < 0)
                {
                    testPos = -blockMinedPos.x;
                }
                else if (Rotation.Forward.Floor.x > 0)
                {
                    testPos = blockMinedPos.x;
                }
                else if (Rotation.Forward.Floor.z < 0)
                {
                    testPos = -blockMinedPos.z;
                }
                else if (Rotation.Forward.Floor.z > 0)
                {
                    testPos = blockMinedPos.z;
                }

                if (testPos == MINING_SIZE + 1)
                {
                    blockMinedPos += -Rotation.Up.Floor;
                    blockMinedPos += -Rotation.Forward.Floor * MINING_SIZE;
                }
                Block minedBlock = World.GetBlock(blockMinedPos + Position3i);
                if (minedBlock.Is <Impenetrable>())
                {
                    GetComponent <OnOffComponent>().SetOnOff(Creator.Player, false);
                    blockMinedPos = previousMiningBlock;
                    return;
                }
                Item minedItem = null;
                if (minedBlock.Is <Diggable>())
                {
                    minedItem = BlockItem.CreatingItem(minedBlock.GetType());
                }
                if (minedBlock.Is <Minable>())
                {
                    if (minedBlock is StoneBlock)
                    {
                        minedItem = Item.Create(typeof(StoneItem));
                    }
                    else if (minedBlock is CoalBlock)
                    {
                        minedItem = Item.Create(typeof(CoalItem));
                    }
                    else if (minedBlock is CopperOreBlock)
                    {
                        minedItem = Item.Create(typeof(CopperOreItem));
                    }
                    else if (minedBlock is IronOreBlock)
                    {
                        minedItem = Item.Create(typeof(IronOreItem));
                    }
                    else if (minedBlock is GoldOreBlock)
                    {
                        minedItem = Item.Create(typeof(GoldOreItem));
                    }
                }
                if (minedItem != null && entry.GetLinker() != null)
                {
                    //, minedBlock.Is<Minable>() ? 4 : 1
                    ConnectorObject obj = entry.GetLinker().GetFirstValidOutput(this, minedItem.GetType());
                    if (obj == null)
                    {
                        blockMinedPos = previousMiningBlock;
                        return;
                    }
                    obj.Output.GetComponent <PublicStorageComponent>().Inventory.TryAddItems(minedItem.Type, minedBlock.Is <Minable>() ? 4 : 1);
                }
                World.DeleteBlock(blockMinedPos + Position3i);
                actualMiningTime = 0;
            }
        }