private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            CA_Manager[] allManagers = FindObjectsOfType <CA_Manager>();

            for (int i = 0; i < allManagers.Length; i++)
            {
                //-1 = Error; 0 = Same but not idling; 1 = Same and Idling; 2 = Not same; 3 = Not a chest
                int check = allManagers[i].PurchaseInteraction_Receiver(self, activator);
                //Chat.AddMessage("Check: " + check);
                if (check == 1 || check == 3)
                {
                    orig.Invoke(self, activator);
                    break;
                }
                else if (check == 0)
                {
                    break;
                }
            }
        }
示例#2
0
        private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, RoR2.PurchaseInteraction self, RoR2.Interactor activator)
        {
            //Get the lowercase name of the Interacted Object
            string objName = self.gameObject.name.ToLower();

            //Check if its a supported Chest
            if (!objName.Contains("chest1") && !objName.Contains("chest2") && !objName.Contains("goldchest") && !objName.Contains("equipmentbarrel") && !objName.Contains("isclockbox"))
            {
                orig.Invoke(self, activator);
                return;
            }

            //Get the chest type
            //Too lazy and tired to make it prettier
            int chestType = objName.Contains("chest1") ? 0 : objName.Contains("chest2") ? 1 : objName.Contains("goldchest") ? 2 : objName.Contains("isclockbox") ? 3 : -1;

            //Randomly Select Tier
            double tier = GetRandomTier(chestType);

            //Send every client a message that a chest has been opened
            ExampleFuncClient.Invoke(activator.gameObject, check =>
            {
                //Check which client opened the chest and wheter or not he is idling
                Debug.Log("Check: " + check);
                if (check == 0)
                {
                    orig.Invoke(self, activator);
                }
                if (check != 0)
                {
                    return;
                }


                if (objName.Contains("equipmentbarrel"))
                {
                    //Signal the server that a chest has been opened
                    //Give the player that opend it and the chest position
                    ExampleCommandClientCustom.Invoke(x =>
                    {
                        x.Write("Chest");
                        x.Write(activator.gameObject);
                        x.Write(self.gameObject.transform);
                        //Specify tier as Equipment
                        x.Write((double)6);
                    });
                }
                else
                {
                    // RNG Value was above specified percantage values
                    // Cancel the drop

                    /*if (tier == 0)
                     * {
                     *  Debug.Log("Mhh Unlucky you found nothing in this Chest.");
                     *  return;
                     * }*/

                    //Signal the server that a chest has been opened
                    //Give the player that opend it and the chest position
                    ExampleCommandClientCustom.Invoke(x =>
                    {
                        x.Write("Chest");
                        x.Write(activator.gameObject);
                        x.Write(self.gameObject.transform);
                        x.Write(tier);
                    });
                }
            });
        }
示例#3
0
        private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            if (currState != State.Idle)
            {
                return;
            }

            orig.Invoke(self, activator);

            CharacterBody player = activator.GetComponent <CharacterBody>();

            if (!player)
            {
                return;
            }

            CharacterMaster characterMaster = this.gameObject.GetComponent <CharacterMaster>();

            if (!characterMaster)
            {
                return;
            }

            if (player.gameObject == characterMaster.GetBody().gameObject)
            {
                //Debug.Log("Same!");

                string objName = self.gameObject.name.ToLower();
                chestPos     = self.gameObject.transform.position;
                chestForward = self.gameObject.transform.forward;
                Debug.Log(objName);

                if (objName.Contains("chest1"))
                {
                    //Debug.Log("Default Chest");
                    //Default Chest
                    tier1Rate    = config.GetValue(1, ConfigStuff.ChestType.Normal);
                    tier2Rate    = config.GetValue(2, ConfigStuff.ChestType.Normal);
                    tier3Rate    = config.GetValue(3, ConfigStuff.ChestType.Normal);
                    chestOpening = true;
                    currState    = State.Opening;
                }
                else if (objName.Contains("chest2"))
                {
                    //Debug.Log("Large Chest");
                    //Large Chest
                    tier1Rate    = config.GetValue(1, ConfigStuff.ChestType.Large);
                    tier2Rate    = config.GetValue(2, ConfigStuff.ChestType.Large);
                    tier3Rate    = config.GetValue(3, ConfigStuff.ChestType.Large);
                    chestOpening = true;
                    currState    = State.Opening;
                }
                else if (objName.Contains("goldchest"))
                {
                    //Debug.Log("Golden Chest");
                    //Golden Chest
                    tier1Rate    = config.GetValue(1, ConfigStuff.ChestType.Golden);
                    tier2Rate    = config.GetValue(2, ConfigStuff.ChestType.Golden);
                    tier3Rate    = config.GetValue(3, ConfigStuff.ChestType.Golden);
                    chestOpening = true;
                    currState    = State.Opening;
                }
                else if (objName.Contains("isclockbox"))
                {
                    //Debug.Log("Rusty Chest");
                    //Rusty Chest
                    tier1Rate    = config.GetValue(1, ConfigStuff.ChestType.Rusty);
                    tier2Rate    = config.GetValue(2, ConfigStuff.ChestType.Rusty);
                    tier3Rate    = config.GetValue(3, ConfigStuff.ChestType.Rusty);
                    chestOpening = true;
                    currState    = State.Opening;
                }
                else if (objName.Contains("equipmentbarrel"))
                {
                    //Debug.Log("Equipment Barrel");
                    //Equipment Barrel

                    chestOpening = true;
                    currState    = State.Equipment;
                }
            }
        }