예제 #1
0
        private static void CCModifyStat(ConCommandArgs args)
        {
            if (args.Count < 1)
            {
                TILER2Plugin._logger.LogError("t2_stat: missing argument 1 (stat ID)!");
                return;
            }
            if (args.Count < 2)
            {
                TILER2Plugin._logger.LogError("t2_stat: missing argument 2 (stat value)!");
                return;
            }
            var searchStr  = args.TryGetArgString(0);
            var searchList = debugStatArgsFields.Where(x => x.Name == searchStr);

            if (searchList.Count() == 0)
            {
                TILER2Plugin._logger.LogError($"t2_stat: could not find stat with name \"{searchStr}\"!");
                return;
            }
            float?setVal = args.TryGetArgFloat(1);

            if (!setVal.HasValue)
            {
                TILER2Plugin._logger.LogError($"t2_stat: argument 2 (stat value) is badly formatted!");
                return;
            }
            searchList.First().SetValue(fixedDebugStatArgs, setVal.Value);
        }
예제 #2
0
        private static void CCSetEggSkillsConfig(ConCommandArgs args)
        {
            //Start with empty code
            string code = string.Empty;

            //If there are too many args, tell them
            if (args.Count > 1)
            {
                LogToConsole("Invald args");
            }
            //If the right amount of args, get the string they give us
            else if (args.Count == 1)
            {
                code = args.TryGetArgString(0);
            }
            //If 0 args, grab it from their clipboard
            else
            {
                code = GUIUtility.systemCopyBuffer;
            }
            //Minor polish so spaces don't implode the system
            code.Trim();
            //For every char in the code
            foreach (char _ in code)
            {
                //If it isn't supposed to be there
                if (!Conversions.CHARS.Contains(_))
                {
                    //Yell at them and gtfo
                    LogToConsole("Invalid character : " + _);
                    return;
                }
            }
            //If it all works fine try to set the config with the code
            LoadConfigCode(code);
        }
예제 #3
0
        private static void CCEvoSetItem(ConCommandArgs args)
        {
            if (args.Count < 1)
            {
                TILER2Plugin._logger.LogError("evo_setitem: missing argument 1 (item ID)!");
                return;
            }
            int icnt;

            if (args.Count > 1)
            {
                int?icntArg = args.TryGetArgInt(1);
                if (!icntArg.HasValue || icntArg < 0)
                {
                    TILER2Plugin._logger.LogError("evo_setitem: argument 2 (item count) must be a positive integer!");
                    return;
                }
                icnt = (int)icntArg;
            }
            else
            {
                icnt = 1;
            }

            ItemIndex item;
            string    itemSearch = args.TryGetArgString(0);

            if (itemSearch == null)
            {
                TILER2Plugin._logger.LogError("evo_setitem: could not read argument 1 (item ID)!");
                return;
            }
            else if (int.TryParse(itemSearch, out int itemInd))
            {
                item = (ItemIndex)itemInd;
                if (!ItemCatalog.IsIndexValid(item))
                {
                    TILER2Plugin._logger.LogError("evo_setitem: argument 1 (item ID as integer ItemIndex) is out of range; no item with that ID exists!");
                    return;
                }
            }
            else
            {
                var results = ItemCatalog.allItems.Where((ind) => {
                    var iNameToken = ItemCatalog.GetItemDef(ind).nameToken;
                    var iName      = Language.GetString(iNameToken);
                    return(iName.ToUpper().Contains(itemSearch.ToUpper()));
                });
                if (results.Count() < 1)
                {
                    TILER2Plugin._logger.LogError("evo_setitem: argument 1 (item ID as string ItemName) not found in ItemCatalog; no item with a name containing that string exists!");
                    return;
                }
                else
                {
                    if (results.Count() > 1)
                    {
                        TILER2Plugin._logger.LogWarning("evo_setitem: argument 1 (item ID as string ItemName) matched multiple items; using first.");
                    }
                    item = results.First();
                }
            }

            Inventory inv = MonsterTeamGainsItemsArtifactManager.monsterTeamInventory;

            if (inv == null)
            {
                TILER2Plugin._logger.LogError("evo_setitem: Artifact of Evolution must be enabled!");
                return;
            }

            int diffCount = icnt - inv.GetItemCount(item);

            inv.GiveItem(item, diffCount);
            TILER2Plugin._logger.LogMessage("evo_setitem: " + (diffCount > 0 ? "added " : "removed ") + Mathf.Abs(diffCount) + "x " + Language.GetString(ItemCatalog.GetItemDef(item).nameToken));
        }
예제 #4
0
        private static void ConCmdYeet(ConCommandArgs args)
        {
            if (!args.senderBody)
            {
                _logger.LogError("ConCmdYeet: called by nonexistent player!");
                return;
            }
            if (args.Count < 1)
            {
                _logger.LogError("ConCmdYeet: not enough arguments! Need at least 1 (item ID), received 0.");
                return;
            }

            bool isEquipment = args.TryGetArgBool(1) ?? false;

            if (isEquipment ? preventEquipment : preventItems)
            {
                return;
            }

            int    rawInd;
            string itemSearch = args.TryGetArgString(0);

            if (itemSearch == null)
            {
                _logger.LogError("ConCmdYeet: could not read first argument (item ID)!");
                return;
            }
            else if (int.TryParse(itemSearch, out rawInd))
            {
                if (isEquipment)
                {
                    if (!EquipmentCatalog.IsIndexValid((EquipmentIndex)rawInd))
                    {
                        _logger.LogError("ConCmdYeet: first argument (equipment ID as integer EquipmentIndex) is out of range; no equipment with that ID exists!");
                        return;
                    }
                }
                else
                {
                    if (!ItemCatalog.IsIndexValid((ItemIndex)rawInd))
                    {
                        _logger.LogError("ConCmdYeet: first argument (item ID as integer ItemIndex) is out of range; no item with that ID exists!");
                        return;
                    }
                }
            }
            else
            {
                if (isEquipment)
                {
                    var results = EquipmentCatalog.allEquipment.Where((searchInd) => {
                        var iNameToken = EquipmentCatalog.GetEquipmentDef(searchInd).nameToken;
                        var iName      = Language.GetString(iNameToken);
                        return(iName.ToUpper().Contains(itemSearch.ToUpper()));
                    });
                    if (results.Count() < 1)
                    {
                        _logger.LogError("ConCmdYeet: first argument (equipment ID as string EquipmentName) not found in EquipmentCatalog; no equipment with a name containing that string exists!");
                        return;
                    }
                    else
                    {
                        if (results.Count() > 1)
                        {
                            _logger.LogWarning("ConCmdYeet: first argument (item ID as string EquipmentName) matched multiple equipments; using first.");
                        }
                        rawInd = (int)results.First();
                    }
                }
                else
                {
                    var results = ItemCatalog.allItems.Where((searchInd) => {
                        var iNameToken = ItemCatalog.GetItemDef(searchInd).nameToken;
                        var iName      = Language.GetString(iNameToken);
                        return(iName.ToUpper().Contains(itemSearch.ToUpper()));
                    });
                    if (results.Count() < 1)
                    {
                        _logger.LogError("ConCmdYeet: first argument (item ID as string ItemName) not found in ItemCatalog; no item with a name containing that string exists!");
                        return;
                    }
                    else
                    {
                        if (results.Count() > 1)
                        {
                            _logger.LogWarning("ConCmdYeet: first argument (item ID as string ItemName) matched multiple items; using first.");
                        }
                        rawInd = (int)results.First();
                    }
                }
            }

            float throwForce = Mathf.Lerp(lowThrowForce, highThrowForce, Mathf.Clamp01(args.TryGetArgFloat(2) ?? 0f));

            if (isEquipment)
            {
                if (args.senderBody.inventory.GetEquipmentIndex() != (EquipmentIndex)rawInd)
                {
                    _logger.LogWarning("ConCmdYeet: someone's trying to drop an equipment they don't have");
                    return;
                }

                var edef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)rawInd);
                args.senderBody.inventory.SetEquipmentIndex(EquipmentIndex.None);
                args.senderBody.inventory.RemoveItem((ItemIndex)rawInd);

                PickupDropletController.CreatePickupDroplet(
                    PickupCatalog.FindPickupIndex((EquipmentIndex)rawInd),
                    args.senderBody.inputBank.aimOrigin,
                    args.senderBody.inputBank.aimDirection * throwForce);
            }
            else
            {
                int count;
                if (Compat_TILER2.enabled)
                {
                    count = Compat_TILER2.GetRealItemCount(args.senderBody.inventory, (ItemIndex)rawInd);
                }
                else
                {
                    count = args.senderBody.inventory.GetItemCount((ItemIndex)rawInd);
                }
                if (count < 1)
                {
                    _logger.LogWarning("ConCmdYeet: someone's trying to drop an item they don't have any of");
                    return;
                }

                var idef = ItemCatalog.GetItemDef((ItemIndex)rawInd);
                if (idef.hidden || !idef.canRemove || (idef.tier == ItemTier.Lunar && preventLunar) || idef.tier == ItemTier.NoTier)
                {
                    return;
                }
                args.senderBody.inventory.RemoveItem((ItemIndex)rawInd);

                var obj = GameObject.Instantiate(PickupDropletController.pickupDropletPrefab, args.senderBody.inputBank.aimOrigin, Quaternion.identity);
                obj.AddComponent <PickupDropletNoCommandFlag>();
                obj.GetComponent <PickupDropletController>().NetworkpickupIndex = PickupCatalog.FindPickupIndex((ItemIndex)rawInd);
                var rbdy = obj.GetComponent <Rigidbody>();
                rbdy.velocity = args.senderBody.inputBank.aimDirection * throwForce;
                rbdy.AddTorque(Random.Range(150f, 120f) * Random.onUnitSphere);
                NetworkServer.Spawn(obj);
            }
        }