private void DestroyComponent(BasePlayer player)
        {
            ZoneEditor editor = player.GetComponent <ZoneEditor>();

            if (editor != null)
            {
                editor.OnPlayerDeath();
                zoneEditors.Remove(editor);
                UnityEngine.Object.Destroy(editor);
            }
        }
        private void OnLootEntityEnd(BasePlayer player, BaseCombatEntity entity)
        {
            if (player == null || entity == null)
            {
                return;
            }

            ZoneEditor editor = player.GetComponent <ZoneEditor>();

            if (editor != null)
            {
                editor.OnLootEntityEnd(entity);
            }
        }
        private void CanvasZonePainter_RectangleCreated(object sender, Drawing.Events.RectangleEventArgs e)
        {
            SideControlPanel.Controls.Remove(CurrentZoneEditor);

            var selectedZoneType = ZoneType.Team;//(ZoneType)ZoneTypeComboBox.SelectedItem;
            var zone             = ZoneFacade.CreateNewZone(selectedZoneType, e.Rectangle);

            var editor = EditorPanelCache.RequestEditor(zone);

            editor.ZoneTypeChanged += this.Editor_ZoneTypeChanged;
            editor.Modified        += this.Editor_Modified;

            CurrentZoneEditor = editor;

            SideControlPanel.Controls.Add(editor);
        }
Example #4
0
    public override void OnInspectorGUI()
    {
        Battlefield zone = (Battlefield)target;

        //base.OnInspectorGUI();
        EditorGUILayout.EnumPopup("Type", zone.Type);

        SerializedProperty hornZone = serializedObject.FindProperty("hornZone");

        EditorGUILayout.PropertyField(hornZone);

        EditorGUILayout.IntField("Morale", zone.Morale);
        EditorGUILayout.IntField("Strength", zone.Strength);

        cards = EditorGUILayout.Foldout(cards, "Cards");
        if (cards)
        {
            ZoneEditor.DrawCardFoldout(zone, ref active);
        }
    }
        private void OnPlayerInput(BasePlayer player, InputState input)
        {
            if (player == null || input == null)
            {
                return;
            }

            ZoneEditor editor = player.GetComponent <ZoneEditor>();

            if (editor == null)
            {
                return;
            }

            if (input.WasJustPressed(BUTTON.USE))
            {
                BaseEntity entity = FindEntityFromRay(player);
                if (entity != null)
                {
                    editor.AccessInventory(entity);
                }
            }
        }
        public static Dictionary <string, ToolboxItem> GetToolboxItems(this ZoneEditor source)
        {
            if (!source?.ControlToolbox?.Sections?.Any() ?? true)
            {
                return(null);
            }

            var tools = new Dictionary <string, ToolboxItem>();

            foreach (var section in source.ControlToolbox.Sections)
            {
                foreach (var toolboxItem in section.Tools)
                {
                    var tool = (ToolboxItem)toolboxItem;

                    if (!tools.ContainsKey(tool.Name))
                    {
                        tools.Add(tool.Name, tool);
                    }
                }
            }

            return(tools);
        }
        private void cmdLoot(BasePlayer player, string command, string[] args)
        {
            if (!permission.UserHasPermission(player.UserIDString, "arena.admin"))
            {
                return;
            }

            if (args.Length == 0)
            {
                SendReply(player, "<color=#939393>Start by navigating to a zone then type <color=#ce422b>/loot edit <zone ID></color>\nNow you are editing a zone. You can add new loot containers or remove existing ones using the commands provided below. If it is a existing loot zone all your previous loot containers will spawn in temporarily\nYou can edit the loot of any container by looking at the container and pressing <color=#ce422b>USE</color>\nWhen you are done editing type <color=#ce422b>/loot save</color> to save what you have done or <color=#ce422b>/loot cancel</color> to forget any changes you have made. All the loot will despawn until a event is played in this zone</color>");
                SendReply(player, "<color=#ce422b>/loot types</color> - Displays all spawnable types and their ID numbers in the ingame console");
                SendReply(player, "<color=#ce422b>/loot edit <zone ID></color> - Start creating, or edit existing, loot spawns for this zone");
                SendReply(player, "<color=#ce422b>/loot add <ID></color> - Create a new loot spawn");
                SendReply(player, "<color=#ce422b>/loot remove</color> - Removes the loot spawn you are looking at");
                SendReply(player, "<color=#ce422b>/loot save</color> - Save the edits you have made");
                SendReply(player, "<color=#ce422b>/loot cancel</color> - Cancel editing a zone");
                return;
            }

            switch (args[0].ToLower())
            {
            case "types":
            {
                int i = 0;
                foreach (var lootType in spawnableTypes)
                {
                    SendEchoConsole(player.net.connection, string.Format("ID: {0} - {1} - Skin: {2}", i, lootType.Key, lootType.Value));
                    i++;
                }
                SendReply(player, "Check your ingame console for a list of loot types");
            }
            break;

            case "save":
            {
                ZoneEditor editor = player.GetComponent <ZoneEditor>();
                if (editor == null)
                {
                    SendReply(player, "You are not currently editing a zone");
                    return;
                }

                storedData.lootSpawns[editor.zoneId] = new List <StoredData.LootSpawn>();

                foreach (BaseEntity entity in editor.zoneEntities)
                {
                    storedData.lootSpawns[editor.zoneId].Add(new StoredData.LootSpawn(entity));
                }

                zoneEditors.Remove(editor);
                UnityEngine.Object.Destroy(editor);
                SaveData();
                SendReply(player, "Zone loot has been saved!");
            }
            break;

            case "cancel":
            {
                ZoneEditor editor = player.GetComponent <ZoneEditor>();
                if (editor == null)
                {
                    SendReply(player, "You are not currently editing a zone");
                    return;
                }

                zoneEditors.Remove(editor);
                UnityEngine.Object.Destroy(editor);
                SendReply(player, "Zone editing has been cancelled!");
            }
            break;

            case "edit":
            {
                if (player.GetComponent <ZoneEditor>())
                {
                    SendReply(player, "You are already editing a zone");
                    return;
                }

                if (args.Length != 2)
                {
                    SendReply(player, "Invalid syntax! <color=#ce422b>/loot edit <zone ID></color>");
                    return;
                }

                if (!ZoneManager)
                {
                    SendReply(player, "ZoneManager is not installed!");
                    return;
                }

                string zoneId  = args[1];
                object success = ZoneManager?.Call("CheckZoneID", zoneId);
                if (success == null)
                {
                    SendReply(player, "You have entered a invalid zone ID");
                    return;
                }

                ZoneEditor editor = player.gameObject.AddComponent <ZoneEditor>();
                editor.zoneId = zoneId;
                zoneEditors.Add(editor);
                if (storedData.lootSpawns.ContainsKey(zoneId))
                {
                    foreach (StoredData.LootSpawn lootSpawn in storedData.lootSpawns[zoneId])
                    {
                        BaseEntity entity = InstantiateEntity(lootSpawn.prefabName, lootSpawn.Position(), Quaternion.Euler(lootSpawn.Rotation()));
                        entity.enableSaving = false;
                        entity.skinID       = lootSpawn.skinId;
                        if (entity is LootContainer)
                        {
                            (entity as LootContainer).BlockPlayerItemInput = false;
                            (entity as LootContainer).onlyAcceptCategory   = ItemCategory.All;
                        }
                        entity.Spawn();

                        if (lootSpawn.lootItems.Length > 0 && entity.GetComponent <StorageContainer>())
                        {
                            ClearContainer(entity);
                            NextTick(() => FillContainer(lootSpawn.lootItems, entity.GetComponent <StorageContainer>()));
                        }
                        editor.zoneEntities.Add(entity);
                    }
                }
                SendReply(player, $"You are now editing the loot for zone: <color=#ce422b>{zoneId}</color>\nBe sure to disable culling whilst your are in edit mode by typing <color=#ce422b>culling.toggle false</color> in the ingame console!");
            }
            break;

            case "add":
            {
                ZoneEditor editor = player.GetComponent <ZoneEditor>();
                if (editor == null)
                {
                    SendReply(player, "You need to start editing a zone before you can add loot");
                    return;
                }

                if (args.Length != 2)
                {
                    SendReply(player, "Invalid syntax! <color=#ce422b>/loot add <ID></color>");
                    return;
                }

                int lootId;
                if (!int.TryParse(args[1], out lootId))
                {
                    SendReply(player, "You must enter a loot ID number as shown in the ingame console");
                    return;
                }

                if (lootId < 0 || lootId > spawnableTypes.Count - 1)
                {
                    SendReply(player, "You have entered a loot ID number that is out of range!");
                    return;
                }

                var spawnableType = spawnableTypes.ElementAt(lootId);
                editor.PlaceNewEntity(spawnableType.Key, spawnableType.Value);
            }
            break;

            case "remove":
            {
                ZoneEditor editor = player.GetComponent <ZoneEditor>();
                if (editor == null)
                {
                    SendReply(player, "You need to start editing a zone before you can remove loot");
                    return;
                }

                BaseEntity entity = FindEntityFromRay(player);
                if (entity == null)
                {
                    SendReply(player, "You need to look at the entity you want to remove from the loot spawns");
                    return;
                }

                editor.RemoveEntity(entity);
            }
            break;

            default:
                break;
            }
        }