internal class XUiC_RemoveSilencerPopupRebirth : XUiController { public XUiV_Label SilencerLabel; public XUiV_Panel SilencerPanel; public override void Init() { //Log.Out("XUiC_SilencerPopupRebirth-Init START"); base.Init(); SilencerPanel = (XUiV_Panel)GetChildById("SilencerPopup").ViewComponent; ((XUiC_SimpleButton)SilencerPanel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancelSilencer_OnPressed; ((XUiC_SimpleButton)SilencerPanel.Controller.GetChildById("btnConfirm")).OnPressed += BtnConfirmSilencer_OnPressed; SilencerLabel = (XUiV_Label)SilencerPanel.Controller.GetChildById("SilencerLabel").ViewComponent; //Log.Out("XUiC_SilencerPopupRebirth-Init END"); } public override void OnOpen() { //Log.Out("XUiC_SilencerPopupRebirth-OnOpen START"); EntityPlayer player = xui.playerUI.entityPlayer; var entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); if (entityID == 0) return; var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth; if (myEntity != null) SilencerLabel.Text = string.Format(Localization.Get("ttRetrieveSilencer"), myEntity.EntityName); base.OnOpen(); //Log.Out("XUiC_SilencerPopupRebirth-OnOpen END"); } private void BtnConfirmSilencer_OnPressed(XUiController _sender, int _mouseButton) { //Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed START"); EntityPlayer player = xui.playerUI.entityPlayer; var entityID = 0; if (player.Buffs.HasCustomVar("CurrentNPC")) entityID = (int)player.Buffs.GetCustomVar("CurrentNPC"); if (entityID == 0) return; var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth; if (myEntity != null) { var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal); var playerInventory = uiforPlayer.xui.PlayerInventory; if (playerInventory == null) return; string ID = "modGunSoundSuppressorSilencer"; var item = ItemClass.GetItem(ID); if (item == null) { //Log.Out("XUiC_RemoveSilencerPopupRebirth: Item Not Found: " + ID); return; } var itemStack = new ItemStack(item, 1); if (!playerInventory.AddItem(itemStack, true)) player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero); ItemActionAttack itemActionRanged = myEntity.inventory.GetHoldingGun(); string weaponName = myEntity.inventory.holdingItem.GetItemName().ToLower().Trim(); if (weaponName == "gunnpcsmg5") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "smg_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "smg_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "smg_fire_end"; } else if (weaponName == "gunnpcpipepistol") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_pistol_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_pistol_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcpipeshotgun") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_shotgun_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_shotgun_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcpiperifle") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_rifle_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_rifle_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcpipemg") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_smg_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_smg_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcm60") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "m60_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "m60_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "m60_fire_end"; } else if (weaponName == "gunnpcpistol") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "Pistol_Fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "Pistol_Fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcdpistol") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "desertvulture_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "desertvulture_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcak47") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "ak47_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "ak47_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "ak47_fire_end"; } else if (weaponName == "gunnpctrifle") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "tacticalar_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "tacticalar_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpchrifle") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "sniperrifle_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "sniperrifle_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcsrifle") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "sharpshooter_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "sharpshooter_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcpshotgun") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pump_shotgun_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pump_shotgun_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } else if (weaponName == "gunnpcashotgun") { myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "autoshotgun_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "autoshotgun_fire"; myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = ""; } myEntity.inventory.ForceHoldingItemUpdate(); myEntity.Buffs.RemoveBuff("FuriousRamsayNPCSilencer"); } xui.playerUI.windowManager.Close(windowGroup.ID); //Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed END"); } private void BtnCancelSilencer_OnPressed(XUiController _sender, int _mouseButton) { //Log.Out("XUiC_SilencerPopupRebirth-BtnCancelSilencer_OnPressed START"); SilencerPanel.IsVisible = false; xui.playerUI.windowManager.Close(windowGroup.ID); //Log.Out("XUiC_SilencerPopupRebirth-BtnCancelSilencer_OnPressed END"); } public override void OnClose() { //Log.Out("XUiC_SilencerPopupRebirth-OnClose START"); if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog")) xui.playerUI.windowManager.Close("dialog"); base.OnClose(); //Log.Out("XUiC_SilencerPopupRebirth-OnClose END"); } }