Example #1
0
        public static void CCSubmodule(ConCommandArgs args)
        {
            args.CheckArgumentCount(1);
            string module = args.GetArgString(0);

            if (PluginEntry.Modules.ContainsKey(module))
            {
                if (args.Count == 1)
                {
                    Debug.LogFormat($"Module {module} is {(PluginEntry.Modules[module].IsEnabled ? "enabled" : "disabled")}.");
                    return;
                }
                bool?value = args.TryGetArgBool(1);
                if (value.HasValue)
                {
                    PluginEntry.Modules[module].IsEnabled = value.Value;
                }
                else
                {
                    Debug.Log("Cannot parse second argument.");
                }
            }
            else
            {
                Debug.LogFormat("Module not found. Available modules: {0}", string.Join(", ", PluginEntry.Modules.Keys));
            }
        }
Example #2
0
        private static void CcDeadPlayersGetItems(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(DeadPlayersGetItems.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                DeadPlayersGetItems.Value = valid.Value;
                Debug.Log($"Dead player getting shared items set to {DeadPlayersGetItems.Value}");
            }
        }
Example #3
0
        private static void CcBossLoot(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(OverrideBossLootScalingEnabled.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                OverrideBossLootScalingEnabled.Value = valid.Value;
                Debug.Log($"Boss loot scaling disable set to {OverrideBossLootScalingEnabled.Value}.");
            }
        }
Example #4
0
        private static void CcPrinterCauldronFix(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(PrinterCauldronFixEnabled.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                PrinterCauldronFixEnabled.Value = valid.Value;
                Debug.Log($"Printer and cauldron fix set to {PrinterCauldronFixEnabled.Value}.");
            };
        }
Example #5
0
        private static void CcRandomizeSharedPickups(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(RandomizeSharedPickups.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                RandomizeSharedPickups.Value = valid.Value;
                Debug.Log($"Randomize pickups per player set to {RandomizeSharedPickups.Value}.");
            }
        }
Example #6
0
        private static void CcBossShared(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(BossItemsShared.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                BossItemsShared.Value = valid.Value;
                Debug.Log($"Boss item sharing set to {BossItemsShared.Value}.");
            };
        }
Example #7
0
        private static void CcEquipmentShared(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(EquipmentShared.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                EquipmentShared.Value = valid.Value;
                Debug.Log($"Equipment sharing set to {EquipmentShared.Value}.");
            }
        }
Example #8
0
        private static void CcMoneyScalarEnabled(ConCommandArgs args)
        {
            if (args.Count == 0)
            {
                Debug.Log(MoneyScalarEnabled.Value);
                return;
            }
            var valid = args.TryGetArgBool(0);

            if (!valid.HasValue)
            {
                Debug.Log("Couldn't parse to boolean.");
            }
            else
            {
                MoneyScalarEnabled.Value = valid.Value;
                Debug.Log($"Money sharing scalar status set to {MoneyScalarEnabled.Value}.");
            }
        }
Example #9
0
        private static void FinishPose(ConCommandArgs args)
        {
            var cb = args.senderBody;

            if (cb)
            {
                var hc = cb.healthComponent;
                if (hc)
                {
                    if (args.TryGetArgBool(0) == true)
                    {
                        var animator = GetModelAnimator(cb);
                        if (animator)
                        {
                            UnityEngine.Object.DestroyImmediate(animator);
                        }
                    }
                    args.senderMaster.preventGameOver = true;
                    hc.Suicide();
                    args.senderMasterObject.GetComponent <DesCloneCommandComponent>().tryRespawn = true;
                }
            }
        }
Example #10
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);
            }
        }