Example #1
0
        private void Awake()
        {
            ClientsCanDrop       = Config.Wrap(section: "", key: "clients_can_drop", description: @"Allows client with the mod installed to drop their own items.", defaultValue: true);
            HostCanDropOthers    = Config.Wrap(section: "", key: "host_can_drop_others", description: @"Allows host drop other players' items.", defaultValue: true);
            ClientsCanDropOthers = Config.Wrap(section: "", key: "clients_can_drop_others", description: @"Allows clients with the mod installed to drop other players' items.", defaultValue: false);

            SceneManager.sceneUnloaded += OnSceneUnloaded;
            var miniRpc = MiniRpc.CreateInstance("com.kookehs.dropitems");

            SendDropItemRequest = miniRpc.RegisterAction(Target.Server, (user, x) => {
                var master = x.ReadGameObject();
                var itemid = x.ReadItemIndex();

                var inventory       = master.GetComponent <Inventory>();
                var characterMaster = master.GetComponent <CharacterMaster>();
                if (inventory == null || characterMaster == null)
                {
                    return;
                }

                if (!IsAllowedToDrop(user, characterMaster))
                {
                    return;
                }

                DropItem(inventory, itemid);
            });
            SendDropEquipmentRequest = miniRpc.RegisterAction(Target.Server, (NetworkUser user, GameObject master) => {
                var inventory       = master.GetComponent <Inventory>();
                var characterMaster = master.GetComponent <CharacterMaster>();
                if (inventory == null || characterMaster == null)
                {
                    return;
                }

                if (!IsAllowedToDrop(user, characterMaster))
                {
                    return;
                }

                DropEquipment(inventory);
            });

            Debug.Log("Loaded DropItemsMod");
        }
Example #2
0
        private void RegisterNetworking()
        {
            var rpc = MiniRpc.CreateInstance(MODUID);

            if (NetRequestDoDamage == null)
            {
                NetRequestDoDamage = rpc.RegisterAction <ServerDamageContainer>(Target.Server, RPCHandleServerDamage);
            }
            if (NetRequestGiveBuff == null)
            {
                NetRequestGiveBuff = rpc.RegisterAction <ServerBuffContainer>(Target.Server, RPCHandleServerBuff);
            }
            if (NetRequestSpawnFx == null)
            {
                NetRequestSpawnFx = rpc.RegisterAction <ClientFxContainer>(Target.Client, RPCHandleClientFx);
            }
            if (NetServerRequestSpawnFx == null)
            {
                NetServerRequestSpawnFx = rpc.RegisterAction <ClientFxContainer>(Target.Server, RPCHandleServerToClientFx);
            }
            if (NetServerRequestAnimBool == null)
            {
                NetServerRequestAnimBool = rpc.RegisterAction <ClientAnimatorBoolContainer>(Target.Server, RPCHandleServerAnimBool);
            }
            if (NetClientRequestAnimBool == null)
            {
                NetClientRequestAnimBool = rpc.RegisterAction <ClientAnimatorBoolContainer>(Target.Client, RPCHandleClientAnimBool);
            }
            if (NetServerRequestAnimFloat == null)
            {
                NetServerRequestAnimFloat = rpc.RegisterAction <ClientAnimatorFloatContainer>(Target.Server, RPCHandleServerAnimFloat);
            }
            if (NetClientRequestAnimFloat == null)
            {
                NetClientRequestAnimFloat = rpc.RegisterAction <ClientAnimatorFloatContainer>(Target.Client, RPCHandleClientAnimFloat);
            }
            if (NetServerRequestAnimTrigger == null)
            {
                NetServerRequestAnimTrigger = rpc.RegisterAction <ClientAnimatorTriggerContainer>(Target.Server, RPCHandleServerAnimTrigger);
            }
            if (NetClientRequestAnimTrigger == null)
            {
                NetClientRequestAnimTrigger = rpc.RegisterAction <ClientAnimatorTriggerContainer>(Target.Client, RPCHandleClientAnimTrigger);
            }
        }
Example #3
0
        private static void HandleFunctionRequest(IRpcAction <Action <NetworkWriter> > response, NetworkUser nu, NetworkReader reader)
        {
            //Logger.Info("HandleFunctionRequest");
            var guid     = reader.ReadUInt32();
            var funcId   = reader.ReadInt32();
            var invokeId = reader.ReadInt32();
            //Logger.Info($"Received function: {guid}[{funcId}] - {invokeId}");
            var func   = Functions[guid][funcId];
            var result = func.Function.Invoke(nu,
                                              func.RequestReceiveType == typeof(NetworkReader)
                    ? reader
                    : reader.ReadObject(func.RequestReceiveType));

            response.Invoke(writer =>
            {
                writer.Write(invokeId);
                writer.WriteObject(result);
            }, nu);
        }
Example #4
0
        public DurabilityPlugin()
        {
            DurabilityConfig.Init(Config);
            DurabilityAssets.Init();
            _miniRpc             = MiniRpc.CreateInstance(ModRpcId);
            _cmdUpdateDurability = _miniRpc.RegisterAction(Target.Client, (Action <NetworkUser, UpdateDurabilityMessage>)OnUpdateDurability);

            On.RoR2.EquipmentSlot.ExecuteIfReady                += EquipmentSlotOnExecuteIfReady;
            On.RoR2.GenericPickupController.GrantEquipment      += GenericPickupControllerOnGrantEquipment;
            IL.RoR2.PickupDropletController.CreatePickupDroplet += PickupDropletControllerOnCreatePickupDroplet;
            IL.RoR2.PickupDropletController.OnCollisionEnter    += PickupDropletControllerOnOnCollisionEnter;

            On.RoR2.UI.EquipmentIcon.Update += EquipmentIconOnUpdate;

            On.RoR2.Console.Awake += (orig, self) =>
            {
                CommandHelper.RegisterCommands(self);
                orig(self);
            };
        }
        public KookehsDropItemMod()
        {
            var miniRpc = MiniRpc.CreateInstance(ModGuid);

            DropItemCommand = miniRpc.RegisterAction(Target.Server, (NetworkUser user, DropItemMessage dropItemMessage) => {
                var master = user.master;
                if (master == null)
                {
                    return;
                }

                var body          = master.GetBody();
                var inventory     = master.inventory;
                var charTransform = body.GetFieldValue <Transform>("transform");

                var pickupIndex = dropItemMessage.IsItem
                                        ? new PickupIndex(dropItemMessage.ItemIndex)
                                        : new PickupIndex(dropItemMessage.EquipmentIndex);

                DropItemHandler.DropItem(charTransform, inventory, pickupIndex);
                DropItemHandler.CreateNotification(body, charTransform, pickupIndex);
            });
        }
Example #6
0
        public static void Initialize(RpcLayer.RpcLayer layer)
        {
            _layer              = layer;
            _layer.ReceivedC2S += x => HandleRpc(Target.Server, x);
            _layer.ReceivedS2C += x => HandleRpc(Target.Client, x);

            On.RoR2.Networking.NetworkMessageHandlerAttribute.CollectHandlers += orig =>
            {
                orig();
                _layer.Initialize();
            };

            Reflection.InvokeMethod(typeof(NetworkMessageHandlerAttribute), "CollectHandlers");

            var instance = CreateInstance(FuncChannelGuid);

            // Request targets client, Response targets server
            _funcResponseS2C = instance.RegisterAction(Target.Server, HandleFunctionResponse);
            _funcRequestS2C  = instance.RegisterAction(Target.Client, (_, x) => HandleFunctionRequest(_funcResponseS2C, null, x));

            // Request targets server, Response targets client
            _funcResponseC2S = instance.RegisterAction(Target.Client, HandleFunctionResponse);
            _funcRequestC2S  = instance.RegisterAction(Target.Server, (nu, x) => HandleFunctionRequest(_funcResponseC2S, nu, x));
        }
Example #7
0
        public RecentItemDropper(MiniRpcInstance miniRpc)
        {
            _cmdDropItem = miniRpc.RegisterAction(Target.Server, (Action <NetworkUser, DropRecentItemMessage>)DoDropItem);

            On.RoR2.GenericPickupController.GrantItem += GenericPickupControllerGrantItem;
        }
        public void BuildItemList(IRpcAction <Action <NetworkWriter> > ExampleCommandHostCustom, ConfigHandler config)
        {
            #region Items

            #region Tier 1

            allItems.Add(new Item("Tier 1 Categorie", 0, Resources.Load <Sprite>("Textures/texSimpleTriangle"), delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Tier1, true));

            int Tier1Price = config.Tier1_Price;

            List <ItemIndex> allTier1Items = ItemCatalog.tier1ItemList;

            for (int i = 0; i < allTier1Items.Count; i++)
            {
                ItemDef     itemDef     = ItemCatalog.GetItemDef(allTier1Items[i]);
                PickupIndex pickupIndex = new PickupIndex(allTier1Items[i]);
                ItemIndex   item        = allTier1Items[i];
                string      name        = Language.GetString(pickupIndex.GetPickupNameToken());
                string      description = Language.GetString(itemDef.pickupToken);

                //Get all string between '<' '>' Character
                string[] testing = Regex.Matches(description, @"\<(.+?)\>")
                                   .Cast <Match>()
                                   .Select(s => s.Groups[1].Value).ToArray();

                //Remove all string from the description
                foreach (string str in testing)
                {
                    description = description.Replace(str, "");
                }
                //Remove '<' '>' Characters
                description = description.Replace("<", "").Replace(">", "");

                allItems.Add(new Item(name, description : description, price : Tier1Price, icon : Resources.Load <Sprite>(itemDef.pickupIconPath), func : delegate(PlayerCharacterMasterController player)
                {
                    Vector3 pos = player.master.GetBodyObject().transform.position;

                    //RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                    ExampleCommandHostCustom.Invoke(x =>
                    {
                        x.Write("CreatePickupDroplet_Item");
                        x.Write(item);
                        x.Write(pos);
                    });

                    int itemIndex             = allItems.FindIndex(a => a.Name == name);
                    allItems[itemIndex].Price = (int)Math.Round((float)allItems[itemIndex].Price * config.Price_Increase);
                    return(0);
                }, categorie: Categories.Tier1));
            }
            #endregion

            #region Tier 2

            allItems.Add(new Item("Tier 2 Categorie", 0, delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Tier2, true));

            int Tier2Price = config.Tier2_Price;

            List <ItemIndex> allTier2Items = ItemCatalog.tier2ItemList;

            for (int i = 0; i < allTier2Items.Count; i++)
            {
                ItemDef     itemDef     = ItemCatalog.GetItemDef(allTier2Items[i]);
                PickupIndex pickupIndex = new PickupIndex(allTier2Items[i]);
                ItemIndex   item        = allTier2Items[i];
                string      name        = Language.GetString(pickupIndex.GetPickupNameToken());
                string      description = Language.GetString(itemDef.pickupToken);

                //Get all string between '<' '>' Character
                string[] testing = Regex.Matches(description, @"\<(.+?)\>")
                                   .Cast <Match>()
                                   .Select(s => s.Groups[1].Value).ToArray();

                //Remove all string from the description
                foreach (string str in testing)
                {
                    description = description.Replace(str, "");
                }
                //Remove '<' '>' Characters
                description = description.Replace("<", "").Replace(">", "");

                allItems.Add(new Item(name, Tier2Price, Resources.Load <Sprite>(itemDef.pickupIconPath), delegate(PlayerCharacterMasterController player)
                {
                    Vector3 pos = player.master.GetBodyObject().transform.position;

                    //RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                    ExampleCommandHostCustom.Invoke(x =>
                    {
                        x.Write("CreatePickupDroplet_Item");
                        x.Write(item);
                        x.Write(pos);
                    });

                    int itemIndex             = allItems.FindIndex(a => a.Name == name);
                    allItems[itemIndex].Price = (int)Math.Round(allItems[itemIndex].Price * config.Price_Increase);
                    return(0);
                }, description, Categories.Tier2));
            }
            #endregion

            #region Tier 3

            allItems.Add(new Item("Tier 3 Categorie", 0, delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Tier3, true));

            int Tier3Price = config.Tier3_Price;

            List <ItemIndex> allTier3Items = ItemCatalog.tier3ItemList;

            for (int i = 0; i < allTier3Items.Count; i++)
            {
                ItemDef     itemDef     = ItemCatalog.GetItemDef(allTier3Items[i]);
                PickupIndex pickupIndex = new PickupIndex(allTier3Items[i]);
                ItemIndex   item        = allTier3Items[i];
                string      name        = Language.GetString(pickupIndex.GetPickupNameToken());
                string      description = Language.GetString(itemDef.pickupToken);

                //Get all string between '<' '>' Character
                string[] testing = Regex.Matches(description, @"\<(.+?)\>")
                                   .Cast <Match>()
                                   .Select(s => s.Groups[1].Value).ToArray();

                //Remove all string from the description
                foreach (string str in testing)
                {
                    description = description.Replace(str, "");
                }
                //Remove '<' '>' Characters
                description = description.Replace("<", "").Replace(">", "");

                allItems.Add(new Item(name, Tier3Price, Resources.Load <Sprite>(itemDef.pickupIconPath), delegate(PlayerCharacterMasterController player)
                {
                    Vector3 pos = player.master.GetBodyObject().transform.position;

                    //RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                    ExampleCommandHostCustom.Invoke(x =>
                    {
                        x.Write("CreatePickupDroplet_Item");
                        x.Write(item);
                        x.Write(pos);
                    });

                    int itemIndex             = allItems.FindIndex(a => a.Name == name);
                    allItems[itemIndex].Price = (int)Math.Round(allItems[itemIndex].Price * config.Price_Increase);
                    return(0);
                }, description, Categories.Tier3));
            }
            #endregion

            #region Lunar

            allItems.Add(new Item("Lunar Categorie", 0, delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Lunar, true));

            int LunarItemPrice = config.Lunar_Price;

            List <ItemIndex> allLunarItems = ItemCatalog.lunarItemList;

            for (int i = 0; i < allLunarItems.Count; i++)
            {
                ItemDef     itemDef     = ItemCatalog.GetItemDef(allLunarItems[i]);
                PickupIndex pickupIndex = new PickupIndex(allLunarItems[i]);
                ItemIndex   item        = allLunarItems[i];
                string      name        = Language.GetString(pickupIndex.GetPickupNameToken());
                string      description = Language.GetString(itemDef.pickupToken);

                //Get all string between '<' '>' Character
                string[] testing = Regex.Matches(description, @"\<(.+?)\>")
                                   .Cast <Match>()
                                   .Select(s => s.Groups[1].Value).ToArray();

                //Remove all string from the description
                foreach (string str in testing)
                {
                    description = description.Replace(str, "");
                }
                //Remove '<' '>' Characters
                description = description.Replace("<", "").Replace(">", "");

                allItems.Add(new Item(name, LunarItemPrice, Resources.Load <Sprite>(itemDef.pickupIconPath), delegate(PlayerCharacterMasterController player)
                {
                    Vector3 pos = player.master.GetBodyObject().transform.position;

                    //RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                    ExampleCommandHostCustom.Invoke(x =>
                    {
                        x.Write("CreatePickupDroplet_Item");
                        x.Write(item);
                        x.Write(pos);
                    });

                    int itemIndex             = allItems.FindIndex(a => a.Name == name);
                    allItems[itemIndex].Price = (int)Math.Round(allItems[itemIndex].Price * config.Price_Increase);
                    return(0);
                }, description, Categories.Lunar));
            }
            #endregion

            #endregion

            #region Equipment

            allItems.Add(new Item("Equipment Categorie", 0, Resources.Load <Sprite>("Textures/texSimpleTriangle"), delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Equipment, true));

            int EquipmentPrice = config.Equipment_Price;

            List <EquipmentIndex> allEquipment = EquipmentCatalog.equipmentList;

            for (int i = 0; i < allEquipment.Count; i++)
            {
                EquipmentDef   itemDef        = EquipmentCatalog.GetEquipmentDef(allEquipment[i]);
                PickupIndex    pickupIndex    = new PickupIndex(allEquipment[i]);
                EquipmentIndex equipmentIndex = allEquipment[i];
                string         name           = Language.GetString(pickupIndex.GetPickupNameToken());
                string         description    = Language.GetString(itemDef.pickupToken);

                //Get all string between '<' '>' Character
                string[] testing = Regex.Matches(description, @"\<(.+?)\>")
                                   .Cast <Match>()
                                   .Select(s => s.Groups[1].Value).ToArray();

                //Remove all string from the description
                foreach (string str in testing)
                {
                    description = description.Replace(str, "");
                }
                //Remove '<' '>' Characters
                description = description.Replace("<", "").Replace(">", "");

                allItems.Add(new Item(name, EquipmentPrice, Resources.Load <Sprite>(itemDef.pickupIconPath), delegate(PlayerCharacterMasterController player)
                {
                    Vector3 pos = player.master.GetBodyObject().transform.position;

                    //RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                    ExampleCommandHostCustom.Invoke(x =>
                    {
                        x.Write("CreatePickupDroplet_Equipment");
                        x.Write(equipmentIndex);
                        x.Write(pos);
                    });

                    int itemIndex             = allItems.FindIndex(a => a.Name == name);
                    allItems[itemIndex].Price = (int)Math.Round(allItems[itemIndex].Price * config.Price_Increase);
                    return(0);
                }, description, Categories.Equipment));
            }

            #endregion

            #region Exp

            allItems.Add(new Item("Exp Categorie", 0, delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Experience, true));

            allItems.Add(new Item("50 XP", 10, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveExperience(50);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddExp");
                    x.Write(player.gameObject);
                    x.Write(50.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "50 XP");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Experience));

            allItems.Add(new Item("250 XP", 25, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveExperience(250);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddExp");
                    x.Write(player.gameObject);
                    x.Write(250.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "250 XP");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Experience));

            allItems.Add(new Item("1K XP", 50, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveExperience(1000);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddExp");
                    x.Write(player.gameObject);
                    x.Write(1000.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "1K XP");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Experience));

            allItems.Add(new Item("10K XP", 400, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveExperience(10000);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddExp");
                    x.Write(player.gameObject);
                    x.Write(10000.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "10K XP");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Experience));
            #endregion

            #region Gold

            allItems.Add(new Item("Money Categorie", 0, delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.Money, true));

            allItems.Add(new Item("150 Gold", 10, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveMoney(150);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddMoney");
                    x.Write(player.gameObject);
                    x.Write(150.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "150 Gold");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Money));

            allItems.Add(new Item("500 Gold", 25, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveMoney(500);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddMoney");
                    x.Write(player.gameObject);
                    x.Write(500.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "500 Gold");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Money));

            allItems.Add(new Item("1K Gold", 40, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveMoney(1000);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddMoney");
                    x.Write(player.gameObject);
                    x.Write(1000.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "1K Gold");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Money));

            allItems.Add(new Item("10K Gold", 380, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GiveMoney(10000);

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("AddMoney");
                    x.Write(player.gameObject);
                    x.Write(10000.0);
                });

                int i             = allItems.FindIndex(a => a.Name == "10K Gold");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.Money));
            #endregion

            #region None
            allItems.Add(new Item("Undefined Categorie", 0, delegate(PlayerCharacterMasterController player)
            {
                return(0);
            }, "", Categories.None, true));

            allItems.Add(new Item("Full HP", 10, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GetBody().healthComponent.health = player.master.GetBody().healthComponent.fullHealth;

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("FullHP");
                    x.Write(player.gameObject);
                });

                int i             = allItems.FindIndex(a => a.Name == "Full HP");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.None));

            allItems.Add(new Item("Full Shield", 10, delegate(PlayerCharacterMasterController player)
            {
                //player.body.healthComponent.health = player.body.healthComponent.fullHealth;
                //player.master.GetBody().healthComponent.health = player.master.GetBody().healthComponent.fullHealth;

                ExampleCommandHostCustom.Invoke(x =>
                {
                    x.Write("FullShield");
                    x.Write(player.gameObject);
                });

                int i             = allItems.FindIndex(a => a.Name == "Full Shield");
                allItems[i].Price = (int)Math.Round(allItems[i].Price * config.Price_Increase);
                return(0);
            }, "", Categories.None));
            #endregion
        }
Example #9
0
        private void RegisterMiniRpcCMDs(MiniRpcInstance miniRpc)
        {
            // This command will be called by a client (including the host), and executed on the server (host)
            ExampleCommandHostCustom = miniRpc.RegisterAction(Target.Server, (user, x) =>
            {
                // This is what the server will execute when a client invokes the IRpcAction

                var str = x.ReadString();

                Debug.Log($"[Host] {user?.userName} sent us: {str}");

                if (str == "Buymenu")
                {
                    //Get a user id, starts from 0

                    List <NetworkUser> instancesList = typeof(NetworkUser).GetFieldValue <List <NetworkUser> >("instancesList");
                    int id = instancesList.IndexOf(user);
                    if (id < 0)
                    {
                        return;
                    }

                    //When the id is bigger than the count add items, with a default value of false
                    if (AllBuyMenuStates.Count - 1 < id)
                    {
                        for (int i = AllBuyMenuStates.Count - 1; i < id; i++)
                        {
                            AllBuyMenuStates.Add(false);
                        }
                    }

                    var doubleVal = x.ReadDouble();

                    bool state = doubleVal == 0.0 ? false : true;

                    AllBuyMenuStates[id] = state;

                    int check = AllBuyMenuStates.FindAll(a => a == true).Count;
                    Debug.Log(check);
                    if (check > 0)
                    {
                        ExampleCommandClientCustom.Invoke(y =>
                        {
                            y.Write("Timescale");
                            y.Write(.25);
                        });
                    }
                    else
                    {
                        ExampleCommandClientCustom.Invoke(y =>
                        {
                            y.Write("Timescale");
                            y.Write(1.0);
                        });
                    }
                }

                if (str == "CreatePickupDroplet_Item")
                {
                    ItemIndex item          = x.ReadItemIndex();
                    PickupIndex pickupIndex = new PickupIndex(item);
                    Vector3 pos             = x.ReadVector3();

                    RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                }

                if (str == "CreatePickupDroplet_Equipment")
                {
                    EquipmentIndex item     = x.ReadEquipmentIndex();
                    PickupIndex pickupIndex = new PickupIndex(item);
                    Vector3 pos             = x.ReadVector3();

                    RoR2.PickupDropletController.CreatePickupDroplet(pickupIndex, pos, Vector3.up * 10f);
                }

                if (str == "AddMoney")
                {
                    GameObject go = x.ReadGameObject();
                    int amount    = (int)x.ReadDouble();
                    PlayerCharacterMasterController playerCharacterMaster = go.GetComponent <PlayerCharacterMasterController>();

                    playerCharacterMaster.master.GiveMoney((uint)amount);
                }

                if (str == "AddExp")
                {
                    GameObject go = x.ReadGameObject();
                    int amount    = (int)x.ReadDouble();
                    PlayerCharacterMasterController playerCharacterMaster = go.GetComponent <PlayerCharacterMasterController>();

                    playerCharacterMaster.master.GiveExperience((uint)amount);
                }

                if (str == "FullHP")
                {
                    GameObject go = x.ReadGameObject();
                    PlayerCharacterMasterController playerCharacterMaster = go.GetComponent <PlayerCharacterMasterController>();

                    playerCharacterMaster.master.GetBody().healthComponent.health = playerCharacterMaster.master.GetBody().healthComponent.fullHealth;
                }

                if (str == "FullShield")
                {
                    GameObject go = x.ReadGameObject();
                    PlayerCharacterMasterController playerCharacterMaster = go.GetComponent <PlayerCharacterMasterController>();

                    playerCharacterMaster.master.GetBody().healthComponent.shield = playerCharacterMaster.master.GetBody().healthComponent.fullShield;
                }
            });

            // This command will be called by the host, and executed on all clients
            ExampleCommandClientCustom = miniRpc.RegisterAction(Target.Client, (user, x) =>
            {
                // This is what all clients will execute when the server invokes the IRpcAction

                var str = x.ReadString();

                Debug.Log($"[Client] Host sent us: {str}");

                if (str == "Reset")
                {
                    playerCharacterMaster = null;
                    //kills = 0;
                    if (this.playerCharacterMaster == null)
                    {
                        this.playerCharacterMaster = LocalUserManager.GetFirstLocalUser().cachedMasterController;
                    }

                    if (this.playerCharacterMaster.GetComponent <PlayerScript>() == null)
                    {
                        this.playerCharacterMaster.gameObject.AddComponent <PlayerScript>();
                        this.playerCharacterMaster.gameObject.GetComponent <PlayerScript>().ExampleCommandHostCustom = this.ExampleCommandHostCustom;
                        this.playerCharacterMaster.gameObject.GetComponent <PlayerScript>().config = config;
                        this.playerCharacterMaster.gameObject.GetComponent <PlayerScript>().AwakeManual();
                    }
                }

                if (str == "Timescale")
                {
                    var floatVal   = (float)x.ReadDouble();
                    Time.timeScale = floatVal;
                }


                if (str == "Kill")
                {
                    GameObject go = x.ReadGameObject();
                    PlayerCharacterMasterController playerCharacterMaster = go.GetComponent <PlayerCharacterMasterController>();

                    /*
                     * if (this.playerCharacterMaster == null)
                     *  this.playerCharacterMaster = LocalUserManager.GetFirstLocalUser().cachedMasterController;
                     */


                    if (playerCharacterMaster == this.playerCharacterMaster)
                    {
                        ++playerCharacterMaster.GetComponent <PlayerScript>().kills;
                        //Chat.AddMessage("Added Kill!\n\rNew Kill count is: " + ++playerCharacterMaster.GetComponent<PlayerScript>().kills);
                    }
                }
            });
        }