private static void Postfix()
        {
            Debug.Log("Easy spawner: Easy spawner loading assets");
            EasySpawnerPlugin.LoadAsset(EasySpawnerPlugin.assetBundleName);
            Debug.Log("Easy spawner: Easy spawner loaded assets");

            if (EasySpawnerPlugin.prefabNames.Count == 0)
            {
                if (!ZNetScene.instance)
                {
                    Debug.LogError("EasySpawner: Can't load prefab due to ZNetScene.instance is null");
                }
                else
                {
                    foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
                    {
                        EasySpawnerPlugin.prefabNames.Add(prefab.name);
                        EasySpawnerMenu.PrefabStates.Add(prefab.name, new PrefabState());
                    }

                    EasySpawnerPlugin.prefabNames.Sort();
                    EasySpawnerPlugin.LoadFavourites();
                }
            }
        }
예제 #2
0
        private void FavouritePrefab(bool favourite, PrefabItem caller)
        {
            string name = caller.GetName();

            PrefabStates[name].isFavourite = favourite;

            EasySpawnerPlugin.SaveFavourites();
            RebuildPrefabDropdown();
        }
예제 #3
0
        private static void Postfix()
        {
            Debug.Log("Easy spawner: Easy spawner loading assets");
            EasySpawnerPlugin.LoadAsset(EasySpawnerPlugin.assetBundleName);
            Debug.Log("Easy spawner: Easy spawner loaded assets");

            if (EasySpawnerPlugin.prefabNames.Count == 0)
            {
                if (!ZNetScene.instance)
                {
                    Debug.LogError("EasySpawner: Can't load prefab due to ZNetScene.instance is null");
                }
                else
                {
                    foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
                    {
                        string localizedName = "";

                        if (prefab.TryGetComponent(out ItemDrop itemDrop))
                        {
                            localizedName = Localization.instance.Localize(itemDrop.m_itemData.m_shared.m_name).Trim();
                        }

                        if (prefab.TryGetComponent(out Piece piece))
                        {
                            localizedName = Localization.instance.Localize(piece.m_name).Trim();
                        }

                        EasySpawnerPlugin.prefabNames.Add(prefab.name);
                        EasySpawnerMenu.PrefabStates.Add(prefab.name, new PrefabState()
                        {
                            localizedName = localizedName
                        });
                    }

                    EasySpawnerPlugin.prefabNames.Sort(NameComparator);
                    EasySpawnerPlugin.LoadFavourites();
                }
            }
        }
예제 #4
0
        private void SpawnButtonPress()
        {
            if (SelectedPrefabName == null)
            {
                return;
            }
            string prefabName      = SelectedPrefabName;
            bool   pickup          = PutInInventoryToggle.isOn;
            bool   ignoreStackSize = IgnoreStackSizeToggle.isOn;
            Player player          = Player.m_localPlayer;

            if (!Int32.TryParse(AmountField.text, out int amount) || amount < 1)
            {
                amount = 1;
            }
            if (!Int32.TryParse(LevelField.text, out int level) || level < 1)
            {
                level = 1;
            }

            //If not local player selected in player dropdown then get the Player object for selected player, if player not found then player will stay as local player
            if (!PlayerDropdown.options[PlayerDropdown.value].text.Equals(player.GetPlayerName()))
            {
                pickup = false;//Cannot place items in other players inventories

                foreach (Player playerCheck in Player.GetAllPlayers())
                {
                    if (playerCheck.GetPlayerName().Equals(PlayerDropdown.options[PlayerDropdown.value].text))
                    {
                        player = playerCheck;
                        break;
                    }
                }
            }

            EasySpawnerPlugin.SpawnPrefab(prefabName, player, amount, level, pickup, ignoreStackSize);
        }
예제 #5
0
 private static void Prefix()
 {
     EasySpawnerPlugin.DestroyMenu();
 }