private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            orig(self, activator);

            var shopTerminal = self.GetComponent <ShopTerminalBehavior>();
            var user         = UsersHelper.GetUser(activator);

            if (shopTerminal && user && CheckIfCostTypeIsItem(self.costType))
            {
                if (!watchedPrintedItems.ContainsKey(user.id))
                {
                    watchedPrintedItems[user.id] = new PrintedItems();
                }
                watchedPrintedItems[user.id].AddPrintedItem(shopTerminal.itemTier);
            }
        }
Example #2
0
        private void PingerController_SetCurrentPing(On.RoR2.PingerController.orig_SetCurrentPing orig, PingerController self, PingerController.PingInfo newPingInfo)
        {
            orig(self, newPingInfo);

            var user = UsersHelper.GetUser(self);
            var item = newPingInfo.targetGameObject?.GetComponent <GenericPickupController>();

            if (item && user)
            {
                watchedPingedItems[user.id] = item.GetInstanceID();
            }
            else if (user)
            {
                watchedPingedItems.Remove(user.id);
            }
        }
        private void PlayerCharacterMasterController_OnBodyDeath(On.RoR2.PlayerCharacterMasterController.orig_OnBodyDeath orig, PlayerCharacterMasterController self)
        {
            orig(self);

            Stage.instance.usePod = false;

            var user = UsersHelper.GetUser(self.master);

            if (user)
            {
                if (CheckIfCanTimedRespawn(self.master))
                {
                    usersTimedRespawn.StartTimedRespawn(user);
                }
                else if (IsTimedRespawnBlocked)
                {
                    switch (RespawnType)
                    {
                    case RespawnType.Teleporter:
                        if (PluginConfig.RespawnOnTPEnd.Value)
                        {
                            ChatHelper.UserWillRespawnAfterTPEvent(user.userName);
                        }
                        break;

                    case RespawnType.Mithrix:
                        if (PluginConfig.RespawnOnMithrixEnd.Value)
                        {
                            ChatHelper.UserWillRespawnAfterMithrixFight(user.userName);
                        }
                        break;

                    case RespawnType.Artifact:
                        if (PluginConfig.RespawnOnArtifactTrialEnd.Value)
                        {
                            ChatHelper.UserWillRespawnAfterArtifactTrial(user.userName);
                        }
                        break;
                    }
                }
            }
        }
Example #4
0
        // If "orig" method is fired, GenericPickupController_AttemptGrant will happen next
        private void GenericPickupController_OnInteractionBegin(On.RoR2.GenericPickupController.orig_OnInteractionBegin orig, GenericPickupController self, Interactor activator)
        {
            if (!CheckIfCurrentStageQualifyForSharing() ||
                !CheckIfItemQualifyForSharing(self.pickupIndex))
            {
                orig(self, activator);
                return;
            }

            var user = UsersHelper.GetUser(activator);

            // get item
            if (printedItemsWatcher.CheckIfUserHasPrintedItems(user, self.pickupIndex) ||
                CheckIfUserCanPickItem(user))
            {
                orig(self, activator);
                return;
            }
            // give random item to lowest cost player
            else if (PluginConfig.HowToHandleItemDisproportion.Value == HowToHandleItemDisproportion.GiveRandomItemToLowestCostsPlayer)
            {
                orig(self, activator);
                return;
            }
            // share item
            else if (pingedItemsWatcher.TryConsumeItemPingedByUser(user, self))
            {
                var userWithLeastItems           = InventoryCostCounter.GetUserWithLeastItemsCosts().user;
                var userWithLeastItemsInteractor = UsersHelper.GetUserInteractor(userWithLeastItems);

                if (userWithLeastItemsInteractor)
                {
                    self.OnInteractionBegin(userWithLeastItemsInteractor);
                }
            }
            // can't pick item
            else if (user)
            {
                ChatHelper.PlayerHasTooManyItems(user.userName);
            }
        }
        private CharacterBody CharacterMaster_Respawn(On.RoR2.CharacterMaster.orig_Respawn orig, CharacterMaster self, Vector3 footPosition, Quaternion rotation)
        {
            usersTimedRespawn.ResetTimedRespawn(UsersHelper.GetUser(self));

            return(orig(self, footPosition, rotation));
        }