public static void ShowWindow(int windowID) { firstNetworkUser = PlayerCharacterMasterController.instances[0].networkUser; firstPlayer = PlayerCharacterMasterController.instances[0].master; var viewModel = AugmentShop.GetShopViewModel(firstPlayer.netId); GUILayout.BeginHorizontal(); foreach (var item in viewModel.Items) { var itemDef = ItemCatalog.GetItemDef(item.ItemIndex); GUILayout.Label($"Item name: {itemDef.name}, Points to spend: {item.PointsToSpend}"); foreach (var augment in item.Augments) { if (GUILayout.Button(new GUIContent(augment.Name, itemDef.pickupIconTexture))) { AugmentResolver.TryAddOrUpgradeAugmentToPlayer(firstPlayer.netId, itemDef.itemIndex, augment.AugmentId); Chat.AddMessage($"{firstNetworkUser.userName} unlocked augment {augment.Name}"); } } } GUILayout.EndHorizontal(); }
private static void InventoryHook(On.RoR2.GenericPickupController.orig_GrantItem orig, GenericPickupController self, CharacterBody body, Inventory inventory) { var networkIdentity = body.master.netId; var item = PickupCatalog.GetPickupDef(self.pickupIndex); var itemDef = ItemCatalog.GetItemDef(item.itemIndex); var itemCount = inventory.GetItemCount(itemDef.itemIndex); var itemCost = Application.Config.ConfigResolver.ItemCount(itemDef.tier); var canAdd = itemCount > 1 && itemCount % itemCost == 0; if (canAdd) { var augments = AugmentResolver.ListAugmentsForItem(itemDef.itemIndex); if (augments != null && augments.Any()) { AugmentResolver.TryAddOrUpgradeAugmentToPlayer(networkIdentity, itemDef.itemIndex, augments.FirstOrDefault().Value.Id); } } orig(self, body, inventory); }
public override void Activate() { if (_isActive) { return; } _isActive = true; IL.RoR2.CharacterBody.MushroomItemBehavior.FixedUpdate += (ILContext.Manipulator)(il => { var ilCursor = new ILCursor(il); ilCursor.GotoNext(MoveType.Before, (Func <Instruction, bool>)(x => x.MatchCallvirt <RoR2.CharacterBody>("GetNotMoving"))); ilCursor.Remove(); ilCursor.EmitDelegate <Func <CharacterBody, bool> >((cb) => { if (!AugmentResolver.IsAugmentActiveForPlayer(ItemType, Id, cb.master.netId)) { return(cb.GetNotMoving()); } if (_stopwatch == null) { _stopwatch = new Stopwatch(); _stopwatch.Start(); return(false); } var timeSinceMovement = cb.GetFieldValue <float>("notMovingStopwatch"); if (timeSinceMovement >= 2) { _stopwatch.Restart(); return(true); } if (!(_stopwatch.ElapsedMilliseconds <= DurationMilliSeconds)) { return(false); } if (timeSinceMovement > 0) { _stopwatch.Restart(); } return(true); }); }); On.RoR2.CharacterBody.MushroomItemBehavior.FixedUpdate += (On.RoR2.CharacterBody.MushroomItemBehavior.hook_FixedUpdate)((orig, self) => { orig.Invoke(self); var fieldValue = self.GetFieldValue <GameObject>("mushroomWard"); if (fieldValue != null) { fieldValue.transform.position = self.body.footPosition; } }); }