Files
zzz_REBIRTH__Utils/Scripts/XUIC/NPCs/XUiC_ShowStatsPopupRebirth - Copy.cs
2025-06-04 16:44:53 +09:30

290 lines
11 KiB
C#

internal class XUiC_ShowStatsPopupRebirth : XUiController
{
public XUiV_Label NPCName;
public XUiV_Label NPCPlayerHireLevel;
public XUiV_Label NPCLevel;
public XUiV_Label NPCMiningLevel;
public XUiV_Label NPCFaction;
public XUiV_Label NPCHireCost;
public XUiV_Label NPCRespawnCost;
public XUiV_Label NPCHealth;
public XUiV_Label NPCInventoryCapacity;
public XUiV_Label NPCArmor;
public XUiV_Label NPCKills;
public XUiV_Label NPCWeapon;
public XUiV_Label NPCAmmo;
public XUiV_Label NPCMagazineSize;
public XUiV_Label NPCShotsPerRound;
public XUiV_Panel Panel;
public override void Init()
{
//Log.Out("XUiC_ShowStatsPopupRebirth-Init START");
base.Init();
Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent;
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancel_OnPressed;
NPCName = (XUiV_Label)Panel.Controller.GetChildById("NPCName").ViewComponent;
NPCPlayerHireLevel = NPCLevel = (XUiV_Label)Panel.Controller.GetChildById("NPCPlayerHireLevel").ViewComponent;
NPCLevel = (XUiV_Label)Panel.Controller.GetChildById("NPCLevel").ViewComponent;
NPCMiningLevel = (XUiV_Label)Panel.Controller.GetChildById("NPCMiningLevel").ViewComponent;
NPCFaction = (XUiV_Label)Panel.Controller.GetChildById("NPCFaction").ViewComponent;
NPCHireCost = (XUiV_Label)Panel.Controller.GetChildById("NPCHireCost").ViewComponent;
NPCRespawnCost = (XUiV_Label)Panel.Controller.GetChildById("NPCRespawnCost").ViewComponent;
NPCHealth = (XUiV_Label)Panel.Controller.GetChildById("NPCHealth").ViewComponent;
NPCInventoryCapacity = (XUiV_Label)Panel.Controller.GetChildById("NPCInventoryCapacity").ViewComponent;
NPCArmor = (XUiV_Label)Panel.Controller.GetChildById("NPCArmor").ViewComponent;
NPCKills = (XUiV_Label)Panel.Controller.GetChildById("NPCKills").ViewComponent;
NPCWeapon = (XUiV_Label)Panel.Controller.GetChildById("NPCWeapon").ViewComponent;
NPCAmmo = (XUiV_Label)Panel.Controller.GetChildById("NPCAmmo").ViewComponent;
NPCMagazineSize = (XUiV_Label)Panel.Controller.GetChildById("NPCMagazineSize").ViewComponent;
NPCShotsPerRound = (XUiV_Label)Panel.Controller.GetChildById("NPCShotsPerRound").ViewComponent;
//Log.Out("XUiC_ShowStatsPopupRebirth-Init END");
}
public override void OnOpen()
{
//Log.Out("XUiC_ShowStatsPopupRebirth-OnOpen 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_ShowStatsPopupRebirth-OnOpen 1");
xui.playerUI.windowManager.Close(windowGroup.ID);
return;
}
var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
if (myEntity == null)
{
//Log.Out("XUiC_ShowStatsPopupRebirth-OnOpen 2");
xui.playerUI.windowManager.Close(windowGroup.ID);
return;
}
int minClass = 1;
if (myEntity.EntityClass.Properties.Values.ContainsKey("PlayerLevelRestriction"))
{
minClass = int.Parse(myEntity.EntityClass.Properties.Values["PlayerLevelRestriction"]);
}
float flNPCLevel = myEntity.Buffs.GetCustomVar("$FR_NPC_Level");
float flNPCMiningLevel = myEntity.Buffs.GetCustomVar("$FR_NPC_MiningLevel");
//Log.Out("XUiC_ShowStatsPopupRebirth-OnOpen flNPCMiningLevel: " + flNPCMiningLevel);
float flNPCKills = myEntity.Buffs.GetCustomVar("$varNumKills");
float flNPCMagazineSize = myEntity.Buffs.GetCustomVar("$Magsize");
float flNPCBurst = myEntity.Buffs.GetCustomVar("$Burstsize");
string _strRangedWeaponItem = myEntity.inventory.holdingItem.GetItemName();
string _strAmmo = "";
string _strWeaponName = "";
string _strAmmoName = "";
if (myEntity.EntityClass.Properties.Values.ContainsKey("BagItems"))
{
_strWeaponName = Localization.Get(myEntity.EntityClass.Properties.Values["BagItems"]);
}
if (_strRangedWeaponItem == "gunNPCPipePistol")
{
_strAmmo = "ammo9mmBulletBall";
_strAmmoName = "9mm Bullets";
}
if (_strRangedWeaponItem == "gunNPCPipeMG")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
if (_strRangedWeaponItem == "gunNPCPipeRifle")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
if (_strRangedWeaponItem == "gunNPCHRifle")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
if (_strRangedWeaponItem == "gunNPCPipeShotgun")
{
_strAmmo = "ammoShotgunShell";
_strAmmoName = "Shotgun Shells";
}
if (_strRangedWeaponItem == "gunNPCAShotgun")
{
_strAmmo = "ammoShotgunShell";
_strAmmoName = "Shotgun Shells";
}
if (_strRangedWeaponItem == "gunNPCLBow")
{
_strAmmo = "ammoArrowIron";
_strAmmoName = "Iron Arrows";
}
if (_strRangedWeaponItem == "gunNPCXBow")
{
_strAmmo = "ammoCrossbowBoltIron";
_strAmmoName = "Iron Bolts";
}
if (_strRangedWeaponItem == "gunNPCPistol")
{
_strAmmo = "ammo9mmBulletBall";
_strAmmoName = "9mm Bullets";
}
if (_strRangedWeaponItem == "gunNPCDPistol")
{
_strAmmo = "ammo44MagnumBulletBall";
_strAmmoName = ".44 Bullets";
}
if (_strRangedWeaponItem == "gunNPCPShotgun")
{
_strAmmo = "ammoShotgunShell";
_strAmmoName = "Shotgun Shells";
}
if (_strRangedWeaponItem == "gunNPCSMG5")
{
_strAmmo = "ammo9mmBulletBall";
_strAmmoName = "9mm Bullets";
}
if (_strRangedWeaponItem == "gunNPCSRifle")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
if (_strRangedWeaponItem == "gunNPCTRifle")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
if (_strRangedWeaponItem == "gunNPCM60")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
if (_strRangedWeaponItem == "gunNPCAk47")
{
_strAmmo = "ammo762mmBulletBall";
_strAmmoName = "7.62 Ammo";
}
XUiV_Label NPCAmmoLabel = (XUiV_Label)Panel.Controller.GetChildById("NPCAmmoLabel").ViewComponent;
if (NPCAmmoLabel != null)
{
if (_strAmmoName.Trim().Length == 0)
{
NPCAmmoLabel.Position = new Vector2i(-10000, -10000);
XUiV_Label NPCMagazineSizeLabel = (XUiV_Label)Panel.Controller.GetChildById("NPCMagazineSizeLabel").ViewComponent;
if (NPCMagazineSizeLabel != null)
{
NPCMagazineSizeLabel.Position = new Vector2i(-10000, -10000);
}
XUiV_Label NPCShotsPerRoundLabel = (XUiV_Label)Panel.Controller.GetChildById("NPCShotsPerRoundLabel").ViewComponent;
if (NPCShotsPerRoundLabel != null)
{
NPCShotsPerRoundLabel.Position = new Vector2i(-10000, -10000);
}
}
else
{
NPCAmmoLabel.Position = new Vector2i(8, -488);
XUiV_Label NPCMagazineSizeLabel = (XUiV_Label)Panel.Controller.GetChildById("NPCMagazineSizeLabel").ViewComponent;
if (NPCMagazineSizeLabel != null)
{
NPCMagazineSizeLabel.Position = new Vector2i(8, -528);
}
XUiV_Label NPCShotsPerRoundLabel = (XUiV_Label)Panel.Controller.GetChildById("NPCShotsPerRoundLabel").ViewComponent;
if (NPCShotsPerRoundLabel != null)
{
NPCShotsPerRoundLabel.Position = new Vector2i(8, -568);
}
}
}
int numHirecost = 0;
var entityClass = EntityClass.list[myEntity.entityClass];
if (entityClass.Properties.Values.ContainsKey("HireCost"))
{
numHirecost = int.Parse(entityClass.Properties.Values["HireCost"]);
}
numHirecost = numHirecost + (500 * (int)flNPCLevel);
int numRespawnCost = numHirecost + (250 * (int)flNPCLevel);
NPCName.Text = myEntity.EntityName;
NPCPlayerHireLevel.Text = minClass.ToString();
NPCLevel.Text = "" + flNPCLevel;
NPCMiningLevel.Text = "" + flNPCMiningLevel;
NPCFaction.Text = FactionManager.Instance.GetFaction(myEntity.factionId).Name.ToUpper();
float perc = RebirthUtilities.getDiscount(player);
NPCHireCost.Text = "$" + (int)(numHirecost * perc);
NPCRespawnCost.Text = Localization.Get("ttFree"); // "$" + (int)(numRespawnCost * perc);
NPCHealth.Text = myEntity.GetMaxHealth() + " life";
NPCInventoryCapacity.Text = myEntity.lootContainer.GetContainerSize().x * myEntity.lootContainer.GetContainerSize().y + " Slots";
NPCArmor.Text = "" + (int)EffectManager.GetValue(PassiveEffects.PhysicalDamageResist, null, 0f, myEntity, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1);
NPCKills.Text = "" + flNPCKills;
NPCWeapon.Text = "" + _strWeaponName;
NPCAmmo.Text = "" + _strAmmoName;
if (_strAmmoName.Trim().Length > 0)
{
NPCMagazineSize.Text = "" + flNPCMagazineSize;
NPCShotsPerRound.Text = "" + flNPCBurst;
}
else
{
NPCMagazineSize.Text = "";
NPCShotsPerRound.Text = "";
}
base.OnOpen();
//Log.Out("XUiC_ShowStatsPopupRebirth-OnOpen END");
}
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
{
//Log.Out("XUiC_ShowStatsPopupRebirth-BtnConfirm_OnPressed START");
EntityPlayer player = xui.playerUI.entityPlayer;
xui.playerUI.windowManager.Close(windowGroup.ID);
//Log.Out("XUiC_ShowStatsPopupRebirth-BtnConfirm_OnPressed END");
}
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
{
//Log.Out("XUiC_ShowStatsPopupRebirth-BtnCancel_OnPressed START");
EntityPlayer player = xui.playerUI.entityPlayer;
Panel.IsVisible = false;
xui.playerUI.windowManager.Close(windowGroup.ID);
//Log.Out("XUiC_ShowStatsPopupRebirth-BtnCancel_OnPressed END");
}
public override void OnClose()
{
//Log.Out("XUiC_ShowStatsPopupRebirth-OnClose START");
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
xui.playerUI.windowManager.Close("dialog");
base.OnClose();
//Log.Out("XUiC_ShowStatsPopupRebirth-OnClose END");
}
}