209 lines
10 KiB
C#
209 lines
10 KiB
C#
internal class XUiC_AddSilencerPopupRebirth : 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("ttGiveSilencer"), 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)
|
|
{
|
|
//Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed 1");
|
|
return;
|
|
}
|
|
|
|
var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
|
if (myEntity != null)
|
|
{
|
|
|
|
//Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed 2");
|
|
|
|
ItemValue item = ItemClass.GetItem("modGunSoundSuppressorSilencer", false);
|
|
ItemClass itemClass = item.ItemClass;
|
|
if (itemClass != null)
|
|
{
|
|
|
|
//Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed 3");
|
|
|
|
int itemCount = player.bag.GetItemCount(item, -1, -1, false);
|
|
int itemCount2 = player.inventory.GetItemCount(item, false, -1, -1);
|
|
if (itemCount + itemCount2 > 0)
|
|
{
|
|
|
|
//Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed 4");
|
|
if (itemCount2 > 0)
|
|
{
|
|
//Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed 5");
|
|
player.inventory.DecItem(item, 1, false);
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("XUiC_SilencerPopupRebirth-BtnConfirmSilencer_OnPressed 6");
|
|
player.bag.DecItem(item, 1, false);
|
|
}
|
|
|
|
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_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "smg_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "silencefiller";
|
|
}
|
|
else if (weaponName == "gunnpcpipepistol")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pistol_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pistol_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcpipeshotgun")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcpiperifle")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "hunting_rifle_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "hunting_rifle_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcpipemg")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "m60_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "m60_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "silencefiller";
|
|
}
|
|
else if (weaponName == "gunnpcm60")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "m60_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "m60_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "silencefiller";
|
|
}
|
|
else if (weaponName == "gunnpcpistol")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pistol_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pistol_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcdpistol")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcak47")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "ak47_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "ak47_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "silencefiller";
|
|
}
|
|
else if (weaponName == "gunnpctrifle")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "ak47_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "ak47_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "silencefiller";
|
|
}
|
|
else if (weaponName == "gunnpchrifle")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "hunting_rifle_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "hunting_rifle_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcsrifle")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "sniperrifle_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "sniperrifle_s_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_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
else if (weaponName == "gunnpcashotgun")
|
|
{
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pump_shotgun_s_fire";
|
|
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
|
}
|
|
|
|
myEntity.inventory.ForceHoldingItemUpdate();
|
|
myEntity.Buffs.AddBuff("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");
|
|
}
|
|
} |