예제 #1
0
        //Chance Shrine
        private static void ShrineChanceBehavior_AddShrineStack(On.RoR2.ShrineChanceBehavior.orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
        {
            orig(self, activator);
            var characterBody = activator.GetComponent <CharacterBody>();

            if (characterBody)
            {
                var inv = characterBody.inventory;
                if (inv)
                {
                    if (inv.GetItemCount(ExtraShrineRollItemIndex) > 0 && Util.CheckRoll(ItemProcChance * inv.GetItemCount(ExtraShrineRollItemIndex), characterBody.master))
                    {
                        Xoroshiro128Plus rng    = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong);
                        PickupIndex      none   = PickupIndex.none;
                        PickupIndex      value  = rng.NextElementUniform <PickupIndex>(Run.instance.availableTier1DropList);
                        PickupIndex      value2 = rng.NextElementUniform <PickupIndex>(Run.instance.availableTier2DropList);
                        PickupIndex      value3 = rng.NextElementUniform <PickupIndex>(Run.instance.availableTier3DropList);
                        PickupIndex      value4 = rng.NextElementUniform <PickupIndex>(Run.instance.availableEquipmentDropList);
                        WeightedSelection <PickupIndex> weightedSelection = new WeightedSelection <PickupIndex>(8);
                        weightedSelection.AddChoice(none, self.failureWeight);
                        weightedSelection.AddChoice(value, self.tier1Weight);
                        weightedSelection.AddChoice(value2, self.tier2Weight);
                        weightedSelection.AddChoice(value3, self.tier3Weight);
                        weightedSelection.AddChoice(value4, self.equipmentWeight);
                        PickupIndex pickupIndex = weightedSelection.Evaluate(rng.nextNormalizedFloat);
                        bool        flag        = pickupIndex == PickupIndex.none;
                        if (flag)
                        {
                            Chat.AddMessage("<color=\"green\">Lucky Default Sphere <style=cShrine>has rolled the shrine an additional time for:</style><color=\"white\"> Nothing.");
                        }
                        else
                        {
                            Chat.AddMessage($"<color=\"green\">Lucky Default Sphere <style=cShrine>has rolled the shrine an additional time for:</style><color=\"white\"> {Language.GetString(PickupCatalog.GetPickupDef(pickupIndex).nameToken)}");
                            PickupDropletController.CreatePickupDroplet(pickupIndex, self.dropletOrigin.position, self.dropletOrigin.forward * 20f);
                        }
                    }
                }
            }
        }
 void AddShrineStack(On.RoR2.ShrineChanceBehavior.orig_AddShrineStack orig, ShrineChanceBehavior shrineChangeBehavior, Interactor interactor)
 {
     DropList.SetDropLists(RoR2.Run.instance.availableTier1DropList, RoR2.Run.instance.availableTier2DropList, RoR2.Run.instance.availableTier3DropList, RoR2.Run.instance.availableEquipmentDropList);
     orig(shrineChangeBehavior, interactor);
     DropList.RevertDropLists();
 }