Upload from upload_mods.ps1
This commit is contained in:
120
Scripts/XUIC/NPCs/XUiC_GoHomeRebirth.cs
Normal file
120
Scripts/XUIC/NPCs/XUiC_GoHomeRebirth.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using static RebirthManager;
|
||||
|
||||
internal class XUiC_GoHomeRebirth : 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)
|
||||
{
|
||||
Label.Text = string.Format(Localization.Get("ttGotToRespawn"), myEntity.EntityName);
|
||||
}
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_AddSecondClassPopupRebirth-BtnConfirm_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_AddSecondClassPopupRebirth-BtnConfirm_OnPressed 1");
|
||||
return;
|
||||
}
|
||||
|
||||
var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
||||
if (myEntity == null)
|
||||
{
|
||||
//Log.Out("XUiC_AddSecondClassPopupRebirth-BtnConfirm_OnPressed 2");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (hireInfo hire in RebirthManager.playerHires)
|
||||
{
|
||||
if (hire.hireID == myEntity.entityId)
|
||||
{
|
||||
if (hire.reSpawnPosition != new Vector3(0, 0, 0))
|
||||
{
|
||||
//Log.Out("XUiC_AddSecondClassPopupRebirth-BtnConfirm_OnPressed 2");
|
||||
myEntity.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Follow);
|
||||
myEntity.Buffs.AddBuff("buffOrderStay");
|
||||
myEntity.SetRevengeTarget((EntityAlive) null);
|
||||
myEntity.motion = Vector3.zero;
|
||||
myEntity.navigator?.clearPath();
|
||||
myEntity.moveHelper?.Stop();
|
||||
myEntity.speedForward = 0;
|
||||
myEntity.speedStrafe = 0;
|
||||
//myEntity.navigator?.clearPath();
|
||||
myEntity.LeaderUtils.IsTeleporting = true;
|
||||
myEntity.SetPosition(hire.reSpawnPosition, true);
|
||||
myEntity.rotation.y = hire.reSpawnRotation.y;
|
||||
myEntity.ClearDamagedTarget();
|
||||
myEntity.ClearStun();
|
||||
|
||||
bool foundHire = false;
|
||||
|
||||
foreach (chunkObservers observer in observers)
|
||||
{
|
||||
if (observer.entityID == myEntity.entityId)
|
||||
{
|
||||
foundHire = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundHire)
|
||||
{
|
||||
//Log.Out("MinEventActionRespawnEntity-Execute ADDED CHUNK OBSERVER for: " + myEntity.entityId);
|
||||
ChunkManager.ChunkObserver observerRef = GameManager.Instance.AddChunkObserver(hire.reSpawnPosition, false, 3, -1);
|
||||
observers.Add(new chunkObservers(myEntity.entityId, observerRef));
|
||||
}
|
||||
|
||||
myEntity.LeaderUtils.IsTeleporting = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user