internal class XUiC_DismissEntityRebirth : XUiController { public XUiV_Label Label; public XUiV_Panel Panel; public int EntityID = -1; public string EntityName = ""; 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("btnUnload")).OnPressed += BtnUnload_OnPressed; Label = (XUiV_Label)Panel.Controller.GetChildById("Label").ViewComponent; } public override void OnOpen() { EntityPlayer player = xui.playerUI.entityPlayer; 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("ttDismissEntity"), myEntity.EntityName); } else { Label.Text = string.Format(Localization.Get("ttDismissNPC"), RebirthVariables.NPCName); } base.OnOpen(); } private void BtnUnload_OnPressed(XUiController _sender, int _mouseButton) { EntityPlayer player = xui.playerUI.entityPlayer; var myEntity = player.world.GetEntity(EntityID) as EntityNPCRebirth; if (myEntity != null) { if (!SingletonMonoBehaviour.Instance.IsServer) { SingletonMonoBehaviour.Instance.SendToServer(NetPackageManager.GetPackage().Setup(myEntity.entityId), false); } else { //Log.Out("XUiC_DismissEntityRebirth-BtnUnload_OnPressed REMOVE HIRE/OWNED ENTITY, hire: " + myEntity.entityId); if (myEntity.Buffs.GetCustomVar("$Leader") > 0) { myEntity.lootDropProb = 0; GameManager.Instance.DropContentOfLootContainerServer(BlockValue.Air, new Vector3i(myEntity.position), myEntity.entityId); //RebirthUtilities.DropBackpack(myEntity); } RebirthManager.RemoveHire(myEntity.entityId, true); player.Companions.Remove(myEntity); myEntity.bWillRespawn = false; GameManager.Instance.World.RemoveEntity(myEntity.entityId, EnumRemoveEntityReason.Unloaded); } GameManager.ShowTooltip(GameManager.Instance.World.GetPrimaryPlayer().PlayerUI.xui.playerUI.entityPlayer, myEntity.EntityName + " " + Localization.Get("ttHireDimissed")); } else { RebirthManager.RemoveHire(EntityID, true); } //Log.Out("XUiC_DismissEntityRebirth-BtnUnload_OnPressed 6"); 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(); } }