122 lines
4.5 KiB
C#
122 lines
4.5 KiB
C#
using System.Net.NetworkInformation;
|
|
|
|
internal class XUiC_RespawnEntityRebirth : XUiController
|
|
{
|
|
public XUiV_Label Label;
|
|
public XUiV_Panel Panel;
|
|
|
|
public override void Init()
|
|
{
|
|
base.Init();
|
|
Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent;
|
|
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancel_OnPressed;
|
|
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnConfirm")).OnPressed += BtnConfirm_OnPressed;
|
|
Label = (XUiV_Label)Panel.Controller.GetChildById("Label").ViewComponent;
|
|
}
|
|
|
|
public override void OnOpen()
|
|
{
|
|
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)
|
|
{
|
|
int numHirecost = RebirthUtilities.GetHireCost(entityID);
|
|
int flNPCLevel = (int)myEntity.Buffs.GetCustomVar("$FR_NPC_Level");
|
|
numHirecost = numHirecost + (500 * flNPCLevel);
|
|
int numRespawnCost = numHirecost + (250 * (int)flNPCLevel);
|
|
|
|
numRespawnCost = (int)(numRespawnCost * RebirthUtilities.getDiscount(player));
|
|
|
|
Label.Text = string.Format(Localization.Get("ttReportForDuty"), myEntity.EntityName);
|
|
}
|
|
|
|
base.OnOpen();
|
|
}
|
|
|
|
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
|
{
|
|
//Log.Out("XUiC_RespawnEntityRebirth-BtnConfirm_OnPressed START");
|
|
EntityPlayer player = xui.playerUI.entityPlayer;
|
|
bool canRespawn = false;
|
|
|
|
var entityID = 0;
|
|
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
|
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
|
|
|
if (entityID == 0)
|
|
{
|
|
//Log.Out("XUiC_RespawnEntityRebirth-BtnConfirm_OnPressed 1");
|
|
return;
|
|
}
|
|
|
|
var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
|
if (myEntity == null)
|
|
{
|
|
//Log.Out("XUiC_RespawnEntityRebirth-BtnConfirm_OnPressed 2");
|
|
return;
|
|
}
|
|
|
|
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
|
|
var playerInventory = uiforPlayer.xui.PlayerInventory;
|
|
if (playerInventory == null)
|
|
{
|
|
//Log.Out("XUiC_RespawnEntityRebirth-BtnConfirm_OnPressed 4");
|
|
return;
|
|
}
|
|
|
|
canRespawn = true;
|
|
|
|
if (canRespawn)
|
|
{
|
|
EntityNPCRebirth entity = (EntityNPCRebirth)GameManager.Instance.World.GetEntity(entityID);
|
|
|
|
entity.Buffs.SetCustomVar("$FR_NPC_Respawn", 0f);
|
|
entity.factionId = FactionManager.Instance.GetFactionByName("whiteriver").ID;
|
|
entity.isHirable = true;
|
|
|
|
entity.Buffs.RemoveBuff("FuriousRamsayDeathParticle");
|
|
entity.Buffs.RemoveBuff("FuriousRamsayRespawned");
|
|
|
|
//Log.Out("XUiC_RespawnEntityRebirth-BtnConfirm_OnPressed SET TO FOLLOW");
|
|
entity.attackTarget = (EntityAlive) null;
|
|
entity.SetRevengeTarget((EntityAlive) null);
|
|
entity.guardPosition = Vector3.zero;
|
|
entity.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Follow);
|
|
|
|
entity.Buffs.RemoveBuff("FuriousRamsayBuffPauseAttack");
|
|
RebirthManager.UpdateHireInfo(entity.entityId, "order", "guard", Vector3.zero.ToString(), Vector3.zero.ToString());
|
|
RebirthManager.UpdateHireInfo(entity.entityId, "order", "follow");
|
|
|
|
bool blEntityClass = entity.EntityClass.entityClassName.Contains("Survivor");
|
|
|
|
if (entity.NavObject != null)
|
|
{
|
|
entity.NavObject.IsActive = true;
|
|
}
|
|
GameManager.ShowTooltip(GameManager.Instance.World.GetPrimaryPlayer().PlayerUI.xui.playerUI.entityPlayer, entity.EntityName + " " + Localization.Get("ttReportingForDuty"));
|
|
}
|
|
|
|
xui.playerUI.windowManager.Close(windowGroup.ID);
|
|
}
|
|
|
|
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
|
{
|
|
Panel.IsVisible = false;
|
|
xui.playerUI.windowManager.Close(windowGroup.ID);
|
|
}
|
|
|
|
public override void OnClose()
|
|
{
|
|
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
|
xui.playerUI.windowManager.Close("dialog");
|
|
base.OnClose();
|
|
}
|
|
} |