Пример #1
0
        public static void OpenMenu(Players.Player player, PlayerClickedData playerClickData)
        {
            if (ItemTypes.IndexLookup.TryGetIndex(SchematicTool.NAME, out var schematicItem) &&
                playerClickData.TypeSelected == schematicItem)
            {
                if (player.ActiveColony == null)
                {
                    PandaChat.Send(player, _localizationHelper, "ErrorOpening", ChatColor.red);
                    return;
                }

                if (!_awaitingClick.ContainsKey(player))
                {
                    SendMainMenu(player);
                }
                else
                {
                    var tuple = _awaitingClick[player];
                    _awaitingClick.Remove(player);

                    switch (tuple.Item1)
                    {
                    case SchematicClickType.Build:
                        Vector3Int location = playerClickData.GetVoxelHit().BlockHit.Add(0, 1, 0);
                        var        args     = new JSONNode();
                        args.SetAs("constructionType", GameLoader.NAMESPACE + ".SchematicBuilder");
                        args.SetAs(SchematicBuilderLoader.NAME + ".SchematicName", tuple.Item2);
                        args.SetAs(SchematicBuilderLoader.NAME + ".Rotation", tuple.Item3);

                        if (SchematicReader.TryGetSchematic(tuple.Item2, player.ActiveColony.ColonyID, location, out var schematic))
                        {
                            if (tuple.Item3 >= Schematic.Rotation.Right)
                            {
                                schematic.Rotate();
                            }

                            if (tuple.Item3 >= Schematic.Rotation.Back)
                            {
                                schematic.Rotate();
                            }

                            if (tuple.Item3 >= Schematic.Rotation.Left)
                            {
                                schematic.Rotate();
                            }

                            var maxSize = location.Add(schematic.XMax - 1, schematic.YMax - 1, schematic.ZMax - 1);
                            AreaJobTracker.CreateNewAreaJob("pipliz.constructionarea", args, player.ActiveColony, location, maxSize);
                            AreaJobTracker.SendData(player);
                        }

                        break;

                    case SchematicClickType.Archetect:

                        break;
                    }
                }
            }
        }
        public static void ConnectedBlockInfo(Players.Player player, PlayerClickedData playerClickData)
        {
            //Only launch on RIGHT click
            if (player == null || playerClickData.ClickType != PlayerClickedData.EClickType.Right || player.ActiveColony == null)
            {
                return;
            }

            if (playerClickData.HitType == PlayerClickedData.EHitType.Block &&
                ItemTypes.IndexLookup.TryGetIndex(GameLoader.NAMESPACE + ".ConnectedBlockTool", out var toolItem) &&
                playerClickData.TypeSelected == toolItem &&
                ConnectedBlockSystem.BlockLookup.TryGetValue(ItemId.GetItemId(playerClickData.GetVoxelHit().TypeHit), out var cSType))
            {
                PandaChat.Send(player, "Side Hit: " + playerClickData.GetVoxelHit().SideHit);
                PandaChat.Send(player, "Connected Sides: " + string.Join(", ", cSType.ConnectedBlock.Connections.Select(c => c.ToString()).ToArray()));
                PandaChat.Send(player, "Origin Sides: " + string.Join(", ", cSType.ConnectedBlock.Origin.Select(c => c.ToString()).ToArray()));                PandaChat.Send(player, "BlockRotationDegrees: " + cSType.ConnectedBlock.BlockRotationDegrees.ToString());
                PandaChat.Send(player, "RotationAxis: " + cSType.ConnectedBlock.RotationAxis.ToString());
            }
        }
Пример #3
0
 public static void OnPlayerClicked(Players.Player player, PlayerClickedData playerClickData)
 {
     if (playerClickData.ClickType == PlayerClickedData.EClickType.Right &&
         playerClickData.HitType == PlayerClickedData.EHitType.Block &&
         World.TryGetTypeAt(playerClickData.GetVoxelHit().BlockHit, out ushort blockHit) &&
         blockHit == ColonyBuiltIn.ItemTypes.BERRYBUSH)
     {
         var inv = player.Inventory;
         inv.TryAdd(ColonyBuiltIn.ItemTypes.BERRY, 1);
     }
 }
Пример #4
0
        public static void OnPlayerClicked(Players.Player player, PlayerClickedData playerClickData)
        {
            if (playerClickData.ClickType == PlayerClickedData.EClickType.Right &&
                playerClickData.HitType == PlayerClickedData.EHitType.Block &&
                ItemTypes.TryGetType(playerClickData.GetVoxelHit().TypeHit, out ItemTypes.ItemType itemHit))
            {
                var baseType = itemHit.GetRootParentType();

                if (baseType.Categories != null &&
                    baseType.Categories.Count != 0 &&
                    baseType.Categories.Contains("door", StringComparer.CurrentCultureIgnoreCase))
                {
                    ushort replacement = ColonyBuiltIn.ItemTypes.AIR;

                    if (itemHit.Name == baseType.RotatedXMinus)
                    {
                        replacement = ItemId.GetItemId(baseType.RotatedZMinus);
                    }
                    else if (itemHit.Name == baseType.RotatedZMinus)
                    {
                        replacement = ItemId.GetItemId(baseType.RotatedXMinus);
                    }
                    else if (itemHit.Name == baseType.RotatedXPlus)
                    {
                        replacement = ItemId.GetItemId(baseType.RotatedZPlus);
                    }
                    else if (itemHit.Name == baseType.RotatedZPlus)
                    {
                        replacement = ItemId.GetItemId(baseType.RotatedXPlus);
                    }

                    if (replacement != ColonyBuiltIn.ItemTypes.AIR)
                    {
                        ServerManager.TryChangeBlock(playerClickData.GetVoxelHit().BlockHit, replacement, new BlockChangeRequestOrigin(player));
                    }
                }
            }
        }
Пример #5
0
        public static void OpenMenu(Players.Player player, PlayerClickedData playerClickData)
        {
            //Only launch on RIGHT click
            if (player == null || playerClickData.ClickType != PlayerClickedData.EClickType.Right || playerClickData.HitType != PlayerClickedData.EHitType.Block || player.ActiveColony == null)
            {
                return;
            }

            var voxel   = playerClickData.GetVoxelHit();
            var itemHit = ItemId.GetItemId(voxel.TypeHit);

            if (StorageFactory.CrateTypes.ContainsKey(itemHit.Name) &&
                StorageFactory.CrateLocations.TryGetValue(player.ActiveColony, out var positions) &&
                positions.ContainsKey(voxel.BlockHit))
            {
                LastCrateClick[player] = voxel.BlockHit;
                NetworkMenuManager.SendServerPopup(player, MainMenu(player));
            }
        }
Пример #6
0
 public static void PlaceItem(Players.Player player, PlayerClickedData data)
 {
     if (data.TypeSelected == ItemTypes.GetType(Nach0ColonyBuiltIn.ItemTypes.COMMANDTOOL).ItemIndex)
     {
         PlayerClickedData.VoxelHit voxelData = data.GetVoxelHit();
         if (data.ClickType == PlayerClickedData.EClickType.Left)
         {
             SendCommandUI.SendUI(player);
         }
         else if (data.ClickType == PlayerClickedData.EClickType.Right)
         {
             if (PlayerClickedData.EHitType.Block == data.HitType && voxelData.SideHit == VoxelSide.yPlus)
             {
                 if (commandUIInteraction.item_placer_dict.ContainsKey(player))
                 {
                     ServerManager.TryChangeBlock(voxelData.PositionBuild, ItemTypes.GetType(commandUIInteraction.item_placer_dict[player]).ItemIndex, player);
                 }
             }
         }
     }
 }
Пример #7
0
        public static void OnPlayerClicked(Players.Player player, PlayerClickedData boxedData)
        {
            if (boxedData.ClickType == PlayerClickedData.EClickType.Right)
            {
                if (boxedData.HitType == PlayerClickedData.EHitType.Block)
                {
                    string itemname = ItemTypes.IndexLookup.GetName(boxedData.GetVoxelHit().TypeHit);
                    if (itemname.Contains("Geo Dasher"))
                    {
                        NetworkUI.NetworkMenu menu = new NetworkUI.NetworkMenu();
                        menu.LocalStorage.SetAs("header", "Geo Dasher");
                        menu.Width  = 600;
                        menu.Height = 400;

                        List <ValueTuple <NetworkUI.IItem, int> > items = new List <ValueTuple <IItem, int> >
                        {
                            ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.InputField("teleporterID"), 200),
                            (new NetworkUI.Items.ButtonCallback("PG.RotNC.Teleporter.SetKey", new NetworkUI.LabelData("Set Teleporter Key", UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200),
                            (new NetworkUI.Items.DropDown("Availability", "PG.RotNC.Teleporter.Availability", new List <string>()
                            {
                                "public", "private", "spawn"
                            }), 200)
                        };
                        menu.Items.Add(new NetworkUI.Items.HorizontalRow(items));
                        menu.LocalStorage.SetAs("PG.RotNC.Teleporter.SetKey", 0);
                        menu.LocalStorage.SetAs("PG.RotNC.Teleporter.Availability", 0);

                        menu.Items.Add(new NetworkUI.Items.Line(UnityEngine.Color.black));

                        items = new List <ValueTuple <IItem, int> >
                        {
                            ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.InputField("gototeleporter"), 200),
                            (new NetworkUI.Items.ButtonCallback("PG.RotNC.Teleporter.GoToKey", new NetworkUI.LabelData("Go To Key", UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200)
                        };
                        menu.Items.Add(new NetworkUI.Items.HorizontalRow(items));
                        menu.LocalStorage.SetAs("PG.RotNC.Teleporter.GoToKey", 0);

                        menu.Items.Add(new NetworkUI.Items.Line(UnityEngine.Color.black));

                        foreach (var colony in player.Colonies)
                        {
                            if (TeleporterManager.GetKey(colony.ColonyID, out string output))
                            {
                                items = new List <ValueTuple <IItem, int> >
                                {
                                    ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.Label(colony.Name), 200),
                                    ValueTuple.Create <NetworkUI.IItem, int>(new NetworkUI.Items.Label(output), 200)
                                };
                                menu.Items.Add(new NetworkUI.Items.HorizontalRow(items));
                            }
                        }

                        if (itemname.Contains("x-"))
                        {
                            Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(-1, 0, 0);
                            menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos));
                        }
                        if (itemname.Contains("x+"))
                        {
                            Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(1, 0, 0);
                            menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos));
                        }
                        if (itemname.Contains("z-"))
                        {
                            Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(0, 0, -1);
                            menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos));
                        }
                        if (itemname.Contains("z+"))
                        {
                            Vector3Int pos = boxedData.GetVoxelHit().BlockHit.Add(0, 0, 1);
                            menu.LocalStorage.SetAs("location", NewColonyAPI.Helpers.Utilities.Vector3IntToNode(pos));
                        }
                        NetworkUI.NetworkMenuManager.SendServerPopup(player, menu);
                        return;
                    }
                }
Пример #8
0
 public static void OnPlayerClicked(Players.Player player, PlayerClickedData clickedData)
 {
     if (Helpers.Player.ExactPermission(player, "Master"))
     {
         if (clickedData.ClickType == PlayerClickedData.EClickType.Left)
         {
             if (clickedData.HitType == PlayerClickedData.EHitType.Block)
             {
                 Helpers.Chat.SendSilent(player, ItemTypes.IndexLookup.GetName(clickedData.GetVoxelHit().TypeHit));
             }
         }
     }
 }
Пример #9
0
        public static void OnPlayerClicked(Players.Player player, PlayerClickedData boxedData)
        {
            if (player == null)
            {
                return;
            }

            if (boxedData.ClickType == PlayerClickedData.EClickType.Right)
            {
                if (boxedData.HitType == PlayerClickedData.EHitType.Block)
                {
                    if (boxedData.GetVoxelHit().TypeHit != BlockTypes.BuiltinBlocks.Types.air.ItemIndex || boxedData.GetVoxelHit().TypeHit != BlockTypes.BuiltinBlocks.Types.water.ItemIndex)
                    {
                        if (boxedData.TypeSelected == ItemTypes.IndexLookup.GetIndex("bucketempty"))
                        {
                            foreach (var item in _fluids)
                            {
                                if (boxedData.GetVoxelHit().TypeHit == item.source)
                                {
                                    FluidManager.Remove(boxedData.GetVoxelHit().BlockHit, EFluids.Water);
                                    if (player.Inventory.TryRemove(boxedData.TypeSelected))
                                    {
                                        if (player.Inventory.TryAdd(ItemTypes.IndexLookup.GetIndex("bucketwater")) == false)
                                        {
                                            if (player.ActiveColony != null)
                                            {
                                                player.ActiveColony.Stockpile.Add(ItemTypes.IndexLookup.GetIndex("bucketwater"));
                                            }
                                            else
                                            {
                                                Helpers.Chat.Send(player, "Inventory is full and no active colony, deleting item!");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (boxedData.TypeSelected == ItemTypes.IndexLookup.GetIndex("bucketwater"))
                        {
                            Vector3Int newPos = boxedData.GetVoxelHit().BlockHit;
                            switch (boxedData.GetVoxelHit().SideHit)
                            {
                            case VoxelSide.xMin:
                                newPos = newPos.Add(-1, 0, 0);
                                break;

                            case VoxelSide.xPlus:
                                newPos = newPos.Add(1, 0, 0);
                                break;

                            case VoxelSide.yMin:
                                newPos = newPos.Add(0, -1, 0);
                                break;

                            case VoxelSide.yPlus:
                                newPos = newPos.Add(0, 1, 0);
                                break;

                            case VoxelSide.zMin:
                                newPos = newPos.Add(0, 0, -1);
                                break;

                            case VoxelSide.zPlus:
                                newPos = newPos.Add(0, 0, 1);
                                break;
                            }
                            if (World.TryGetTypeAt(newPos, out ushort actualType) && actualType == BlockTypes.BuiltinBlocks.Types.air.ItemIndex)
                            {
                                FluidManager.Spread(newPos, EFluids.Water);

                                player.Inventory.TryRemove(ItemTypes.IndexLookup.GetIndex("bucketwater"));
                                if (!player.Inventory.TryAdd(ItemTypes.IndexLookup.GetIndex("bucketempty")))
                                {
                                    if (player.ActiveColony != null)
                                    {
                                        player.ActiveColony.Stockpile.Add(ItemTypes.IndexLookup.GetIndex("bucketempty"));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }