Upload from upload_mods.ps1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
|
||||
public class XUiC_QuestTurnInRewardsWindowRebirth : XUiC_QuestTurnInRewardsWindow
|
||||
{
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private bool bCollected = false;
|
||||
}
|
||||
209
Scripts/XUIC/NPCs/XUiC_AddSilencerPopupRebirth.cs
Normal file
209
Scripts/XUIC/NPCs/XUiC_AddSilencerPopupRebirth.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
93
Scripts/XUIC/NPCs/XUiC_ChangeSurvivorNameRebirth.cs
Normal file
93
Scripts/XUIC/NPCs/XUiC_ChangeSurvivorNameRebirth.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
internal class ChangeSurvivorNameRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label Label;
|
||||
public XUiV_Panel Panel;
|
||||
public XUiC_TextInput txtInput;
|
||||
|
||||
|
||||
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;
|
||||
txtInput = (XUiC_TextInput)this.windowGroup.Controller.GetChildById("txtInput");
|
||||
}
|
||||
|
||||
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("ttChangeName"), myEntity.EntityName);
|
||||
txtInput.Text = myEntity.EntityName;
|
||||
}
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
if (txtInput.Text.Trim() == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
//Log.Out("ChangeSurvivorNameRebirth-BtnConfirm_OnPressed BEFORE: " + txtInput.Text.Trim());
|
||||
string newName = txtInput.Text.Trim() + "REBIRTHREBIRTH";
|
||||
myEntity.NewName = newName.Trim();
|
||||
myEntity._strMyName = newName.Trim();
|
||||
myEntity.SetEntityName(newName.Trim());
|
||||
|
||||
if (myEntity.NavObject != null)
|
||||
{
|
||||
myEntity.NavObject.name = txtInput.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.NavObject = NavObjectManager.Instance.RegisterNavObject(EntityClass.list[myEntity.entityClass].NavObject, myEntity, "", false);
|
||||
myEntity.NavObject.name = txtInput.Text.Trim();
|
||||
}
|
||||
//Log.Out("ChangeSurvivorNameRebirth-BtnConfirm_OnPressed AFTER: " + myEntity.EntityName + " / " + myEntity.NavObject.DisplayName + " / " + myEntity._strMyName);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
92
Scripts/XUIC/NPCs/XUiC_DismissEntityRebirth.cs
Normal file
92
Scripts/XUIC/NPCs/XUiC_DismissEntityRebirth.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
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<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageDespawnEntityRebirth>().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();
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
204
Scripts/XUIC/NPCs/XUiC_GoMineRebirth.cs
Normal file
204
Scripts/XUIC/NPCs/XUiC_GoMineRebirth.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
internal class XUiC_GoMineRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label Label;
|
||||
public XUiV_Label Resource;
|
||||
public XUiV_Label ResourceMultiplier;
|
||||
public XUiV_Label GatherType;
|
||||
public XUiV_Panel Panel;
|
||||
public float flSubLevels = 0.1f;
|
||||
public bool bDifferentBiome = false;
|
||||
public string strDuration = "10";
|
||||
|
||||
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;
|
||||
Resource = (XUiV_Label)Panel.Controller.GetChildById("Resource").ViewComponent;
|
||||
ResourceMultiplier = (XUiV_Label)Panel.Controller.GetChildById("ResourceMultiplier").ViewComponent;
|
||||
GatherType = (XUiV_Label)Panel.Controller.GetChildById("GatherType").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;
|
||||
|
||||
string strProperty = RebirthUtilities.GetEntityPropertyValue(entityID, "MiningCost");
|
||||
float numCost = 0f;
|
||||
float numMultiplier = 1f;
|
||||
|
||||
if (strProperty != "")
|
||||
{
|
||||
numCost = int.Parse(strProperty);
|
||||
}
|
||||
|
||||
strProperty = ResourceMultiplier.Text;
|
||||
if (strProperty != "")
|
||||
{
|
||||
numMultiplier = float.Parse(strProperty);
|
||||
}
|
||||
|
||||
numCost = numCost * numMultiplier;
|
||||
|
||||
numCost = (int)(numCost * RebirthUtilities.getDiscount(player));
|
||||
|
||||
BiomeDefinition biomeStandingOn = player.biomeStandingOn;
|
||||
string text = "BIOME";
|
||||
|
||||
text = RebirthUtilities.GetBiomeName(player);
|
||||
|
||||
if (text != "desert" && (Resource.Text == "Sand" || Resource.Text == "Shale"))
|
||||
{
|
||||
bDifferentBiome = true;
|
||||
strDuration = "20";
|
||||
}
|
||||
|
||||
if (myEntity != null)
|
||||
{
|
||||
Label.Text = "";
|
||||
if (text != "desert" && (Resource.Text == "Sand" || Resource.Text == "Shale"))
|
||||
{
|
||||
Label.Text = string.Format(Localization.Get("ttMiningPremium"), myEntity.EntityName, Localization.Get("biome_desert"));
|
||||
numCost = numCost * 1.25f;
|
||||
}
|
||||
|
||||
if (GatherType.Text.ToLower() == "mining")
|
||||
{
|
||||
Label.Text = Label.Text + Localization.Get("ttMiningBetter");
|
||||
|
||||
Label.Text = string.Format(Localization.Get("ttSendToMine"), myEntity.EntityName, Resource.Text, (int)numCost) +
|
||||
string.Format(Localization.Get("ttMiningCostDuration"), EntityUtilities.GetHireCurrency(entityID).ItemClass.GetLocalizedItemName(), strDuration) +
|
||||
Label.Text;
|
||||
}
|
||||
else
|
||||
{
|
||||
Label.Text = string.Format(Localization.Get("ttSendToGather"), myEntity.EntityName, Resource.Text, (int)numCost) +
|
||||
string.Format(Localization.Get("ttMiningCostDuration"), EntityUtilities.GetHireCurrency(entityID).ItemClass.GetLocalizedItemName(), strDuration) +
|
||||
Label.Text;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
string strProperty = RebirthUtilities.GetEntityPropertyValue(entityID, "MiningCost");
|
||||
float numCost = 0f;
|
||||
float numMultiplier = 1f;
|
||||
|
||||
if (strProperty != "")
|
||||
{
|
||||
numCost = int.Parse(strProperty);
|
||||
}
|
||||
|
||||
strProperty = ResourceMultiplier.Text;
|
||||
if (strProperty != "")
|
||||
{
|
||||
numMultiplier = float.Parse(strProperty);
|
||||
}
|
||||
|
||||
numCost = numCost * numMultiplier;
|
||||
|
||||
BiomeDefinition biomeStandingOn = player.biomeStandingOn;
|
||||
string text = "BIOME";
|
||||
if (biomeStandingOn != null)
|
||||
{
|
||||
text = biomeStandingOn.m_sBiomeName;
|
||||
}
|
||||
|
||||
if (text != "desert" && (Resource.Text == "Sand" || Resource.Text == "Shale"))
|
||||
{
|
||||
numCost = numCost * 1.25f;
|
||||
}
|
||||
|
||||
numCost = (int)(numCost * RebirthUtilities.getDiscount(player));
|
||||
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer((EntityPlayerLocal)player);
|
||||
if (uiforPlayer)
|
||||
{
|
||||
if (uiforPlayer.xui.PlayerInventory.GetItemCount(EntityUtilities.GetHireCurrency(myEntity.entityId)) >= (int)numCost)
|
||||
{
|
||||
// Create the stack of currency
|
||||
var stack = new ItemStack(EntityUtilities.GetHireCurrency(myEntity.entityId), (int)numCost);
|
||||
//DisplayLog(" Removing Item: " + stack);
|
||||
uiforPlayer.xui.PlayerInventory.RemoveItems(new[] { stack });
|
||||
|
||||
if (bDifferentBiome)
|
||||
{
|
||||
myEntity.Buffs.AddBuff("FuriousRamsayGoMining" + Resource.Text.Replace(" ", "") + "Premium");
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.Buffs.AddBuff("FuriousRamsayGoMining" + Resource.Text.Replace(" ", ""));
|
||||
}
|
||||
|
||||
int numMiningLevelBefore = (int)myEntity.Buffs.GetCustomVar("$FR_NPC_GoneMiningLevel");
|
||||
myEntity.Buffs.SetCustomVar("$FR_NPC_GoneMiningLevel", myEntity.Buffs.GetCustomVar("$FR_NPC_GoneMiningLevel") + flSubLevels);
|
||||
int numMiningLevelAfter = (int)myEntity.Buffs.GetCustomVar("$FR_NPC_GoneMiningLevel");
|
||||
|
||||
float flNPCMiningLevel = myEntity.Buffs.GetCustomVar("$FR_NPC_MiningLevel");
|
||||
|
||||
if ((numMiningLevelAfter > numMiningLevelBefore) && flNPCMiningLevel < 10)
|
||||
{
|
||||
myEntity.Buffs.SetCustomVar("$FR_NPC_MiningLevel", flNPCMiningLevel + 1f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Audio.Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip((EntityPlayerLocal)player, string.Format(Localization.Get("ttCannotAffordMining"), (int)numCost));
|
||||
ItemValue item = ItemClass.GetItem("casinoCoin", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
player.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
78
Scripts/XUIC/NPCs/XUiC_GoRepairRebirth.cs
Normal file
78
Scripts/XUIC/NPCs/XUiC_GoRepairRebirth.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
internal class XUiC_GoRepairRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label Label;
|
||||
public XUiV_Panel Panel;
|
||||
public float flSubLevels = 0.1f;
|
||||
public bool bDifferentBiome = false;
|
||||
public string strDuration = "25";
|
||||
|
||||
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("ttRepairBlocks"), 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;
|
||||
}
|
||||
|
||||
myEntity.Buffs.AddBuff("FuriousRamsayHelpRepair");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
142
Scripts/XUIC/NPCs/XUiC_HireAnimalPopupRebirth.cs
Normal file
142
Scripts/XUIC/NPCs/XUiC_HireAnimalPopupRebirth.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using Audio;
|
||||
|
||||
internal class XUiC_HireAnimalPopupRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label hireInformationLabel;
|
||||
public XUiV_Panel hireInformationPanel;
|
||||
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
hireInformationPanel = (XUiV_Panel)GetChildById("HireInformationPopup").ViewComponent;
|
||||
((XUiC_SimpleButton)hireInformationPanel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancelHireInformation_OnPressed;
|
||||
((XUiC_SimpleButton)hireInformationPanel.Controller.GetChildById("btnConfirm")).OnPressed += BtnConfirmHireInformation_OnPressed;
|
||||
hireInformationLabel = (XUiV_Label)hireInformationPanel.Controller.GetChildById("HireInformationLabel").ViewComponent;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_HireAnimalPopupRebirth-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;
|
||||
|
||||
int numHirecost = EntityUtilities.GetHireCost(entityID);
|
||||
|
||||
//Log.Out("numHirecost: " + numHirecost);
|
||||
|
||||
if (myEntity != null)
|
||||
hireInformationLabel.Text = string.Format(Localization.Get("ttTakeCare"), myEntity.EntityName, numHirecost) +
|
||||
EntityUtilities.GetHireCurrency(entityID).ItemClass.GetLocalizedItemName() + "?";
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirmHireInformation_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer((EntityPlayerLocal)player);
|
||||
if (uiforPlayer)
|
||||
{
|
||||
|
||||
int numHirecost = EntityUtilities.GetHireCost(entityID);
|
||||
|
||||
if (uiforPlayer.xui.PlayerInventory.GetItemCount(EntityUtilities.GetHireCurrency(myEntity.entityId)) >= numHirecost)
|
||||
{
|
||||
// Create the stack of currency
|
||||
var stack = new ItemStack(EntityUtilities.GetHireCurrency(myEntity.entityId), numHirecost);
|
||||
//DisplayLog(" Removing Item: " + stack);
|
||||
uiforPlayer.xui.PlayerInventory.RemoveItems(new[] { stack });
|
||||
|
||||
// Add the stack of currency to the NPC, and set its orders.
|
||||
EntityUtilities.SetLeaderAndOwner(myEntity.entityId, player.entityId);
|
||||
myEntity.Buffs.AddBuff("buffOrderFollow");
|
||||
|
||||
RebirthManager.AddHire(player.entityId,
|
||||
myEntity.entityId,
|
||||
myEntity.EntityName,
|
||||
myEntity.EntityClass.entityClassName,
|
||||
myEntity.position,
|
||||
myEntity.rotation,
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(0, 0, 0),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
true
|
||||
);
|
||||
|
||||
// If we're going to hire them, they need to wake up.
|
||||
if (myEntity.IsSleeping)
|
||||
myEntity.ConditionalTriggerSleeperWakeUp();
|
||||
|
||||
float flMode = player.Buffs.GetCustomVar("varNPCModMode");
|
||||
float flHalt = player.Buffs.GetCustomVar("varNPCModStopAttacking");
|
||||
|
||||
if (flMode == 0)
|
||||
{
|
||||
myEntity.Buffs.AddBuff("buffNPCModFullControlMode");
|
||||
myEntity.Buffs.RemoveBuff("buffNPCModThreatControlMode");
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.Buffs.AddBuff("buffNPCModThreatControlMode");
|
||||
myEntity.Buffs.RemoveBuff("buffNPCModFullControlMode");
|
||||
}
|
||||
|
||||
if (flHalt == 1)
|
||||
{
|
||||
myEntity.Buffs.AddBuff("buffNPCModStopAttacking");
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.Buffs.RemoveBuff("buffNPCModStopAttacking");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip((EntityPlayerLocal)player, string.Format(Localization.Get("ttMinTakeCareCost"), numHirecost));
|
||||
ItemValue item = ItemClass.GetItem("foodRawMeat", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
player.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnCancelHireInformation_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
hireInformationPanel.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();
|
||||
}
|
||||
}
|
||||
209
Scripts/XUIC/NPCs/XUiC_HireNPCPopupRebirth.cs
Normal file
209
Scripts/XUIC/NPCs/XUiC_HireNPCPopupRebirth.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using Audio;
|
||||
|
||||
internal class XUiC_HireNPCPopupRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label hireInformationLabel;
|
||||
public XUiV_Panel hireInformationPanel;
|
||||
public EntityNPCRebirth myEntity;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
hireInformationPanel = (XUiV_Panel)GetChildById("HireInformationPopup").ViewComponent;
|
||||
((XUiC_SimpleButton)hireInformationPanel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancelHireInformation_OnPressed;
|
||||
((XUiC_SimpleButton)hireInformationPanel.Controller.GetChildById("btnConfirm")).OnPressed += BtnConfirmHireInformation_OnPressed;
|
||||
hireInformationLabel = (XUiV_Label)hireInformationPanel.Controller.GetChildById("HireInformationLabel").ViewComponent;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int entityID = RebirthVariables.talkingToNPC; // (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
|
||||
if (entityID == 0)
|
||||
return;
|
||||
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen entityID: " + entityID);
|
||||
|
||||
myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
||||
|
||||
if (myEntity == null)
|
||||
{
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen ENTITY == null");
|
||||
return;
|
||||
}
|
||||
|
||||
myEntity.Buffs.AddBuff("buffTalkingTo");
|
||||
|
||||
int numHirecost = EntityUtilities.GetHireCost(entityID);
|
||||
int flNPCLevel = (int)myEntity.Buffs.GetCustomVar("$FR_NPC_Level");
|
||||
numHirecost = numHirecost + (500 * flNPCLevel);
|
||||
|
||||
numHirecost = (int)(numHirecost * RebirthUtilities.getDiscount(player));
|
||||
//Log.Out("numHirecost: " + numHirecost);
|
||||
//Log.Out("flNPCLevel: " + flNPCLevel);
|
||||
|
||||
if (myEntity != null)
|
||||
{
|
||||
int minClass = 1;
|
||||
|
||||
if (myEntity.EntityClass.Properties.Values.ContainsKey("PlayerLevelRestriction"))
|
||||
{
|
||||
minClass = int.Parse(myEntity.EntityClass.Properties.Values["PlayerLevelRestriction"]);
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen minClass: " + minClass);
|
||||
}
|
||||
|
||||
string restrictiveHire = RebirthVariables.customRestrictHires;
|
||||
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen restrictiveHire: " + restrictiveHire);
|
||||
|
||||
bool canHire = true;
|
||||
|
||||
if (restrictiveHire == "default" || restrictiveHire == "playerLevel")
|
||||
{
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen 1");
|
||||
if (player.Progression.Level < minClass)
|
||||
{
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen 2");
|
||||
canHire = false;
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-OnOpen canHire: " + canHire);
|
||||
|
||||
if (canHire)
|
||||
{
|
||||
hireInformationLabel.Text = string.Format(Localization.Get("ttHireCost"), myEntity.EntityName, numHirecost) +
|
||||
EntityUtilities.GetHireCurrency(entityID).ItemClass.GetLocalizedItemName() + "?";
|
||||
((XUiC_SimpleButton)hireInformationPanel.Controller.GetChildById("btnConfirm")).ViewComponent.Position = new Vector2i(400, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
hireInformationLabel.Text = string.Format(Localization.Get("ttMinHireLevel"), minClass, myEntity.EntityName);
|
||||
((XUiC_SimpleButton)hireInformationPanel.Controller.GetChildById("btnConfirm")).ViewComponent.Position = new Vector2i(-10000, -10000);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirmHireInformation_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
if (myEntity != null)
|
||||
{
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer((EntityPlayerLocal)player);
|
||||
if (uiforPlayer)
|
||||
{
|
||||
|
||||
int numHirecost = EntityUtilities.GetHireCost(myEntity.entityId);
|
||||
int flNPCLevel = (int)myEntity.Buffs.GetCustomVar("$FR_NPC_Level");
|
||||
|
||||
numHirecost = numHirecost + (500 * flNPCLevel);
|
||||
|
||||
numHirecost = (int)(numHirecost * RebirthUtilities.getDiscount(player));
|
||||
|
||||
if (uiforPlayer.xui.PlayerInventory.GetItemCount(EntityUtilities.GetHireCurrency(myEntity.entityId)) >= numHirecost)
|
||||
{
|
||||
// Create the stack of currency
|
||||
var stack = new ItemStack(EntityUtilities.GetHireCurrency(myEntity.entityId), numHirecost);
|
||||
//DisplayLog(" Removing Item: " + stack);
|
||||
uiforPlayer.xui.PlayerInventory.RemoveItems(new[] { stack });
|
||||
|
||||
EntityUtilities.SetLeaderAndOwner(myEntity.entityId, player.entityId);
|
||||
myEntity.Buffs.AddBuff("buffOrderFollow");
|
||||
myEntity.Buffs.AddBuff("FuriousRamsayMaxHealth");
|
||||
|
||||
myEntity.belongsPlayerId = player.entityId;
|
||||
myEntity.LeaderUtils.Owner = player;
|
||||
RebirthUtilities.SetLeaderAndOwner(myEntity.entityId, player.entityId);
|
||||
myEntity.Buffs.AddBuff("buffNPCModFullControlMode");
|
||||
|
||||
myEntity.AddNavObject("FuriousRamsayHiredNav", "", "");
|
||||
|
||||
//Log.Out("XUiC_HireNPCPopupRebirth-BtnConfirmHireInformation_OnPressed SET TO STAY");
|
||||
myEntity.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Follow);
|
||||
|
||||
float flMode = player.Buffs.GetCustomVar("varNPCModMode");
|
||||
float flHalt = player.Buffs.GetCustomVar("varNPCModStopAttacking");
|
||||
|
||||
if (flMode == 0)
|
||||
{
|
||||
myEntity.Buffs.AddBuff("buffNPCModFullControlMode");
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.Buffs.RemoveBuff("buffNPCModFullControlMode");
|
||||
}
|
||||
|
||||
if (flHalt == 1)
|
||||
{
|
||||
myEntity.Buffs.AddBuff("buffNPCModStopAttacking");
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.Buffs.RemoveBuff("buffNPCModStopAttacking");
|
||||
}
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !SingletonMonoBehaviour<ConnectionManager>.Instance.IsSinglePlayer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageAddCompanion>().Setup(myEntity.entityId, myEntity.belongsPlayerId), false, myEntity.belongsPlayerId, -1, -1, null, 192);
|
||||
}
|
||||
else
|
||||
{
|
||||
myEntity.LeaderUtils.AddCompanion();
|
||||
}
|
||||
|
||||
RebirthManager.AddHire(player.entityId,
|
||||
myEntity.entityId,
|
||||
myEntity.EntityName,
|
||||
myEntity.EntityClass.entityClassName,
|
||||
myEntity.position,
|
||||
myEntity.rotation,
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(0, 0, 0),
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
true
|
||||
);
|
||||
|
||||
// If we're going to hire them, they need to wake up.
|
||||
if (myEntity.IsSleeping)
|
||||
myEntity.ConditionalTriggerSleeperWakeUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("ui_denied");
|
||||
GameManager.ShowTooltip((EntityPlayerLocal)player, string.Format(Localization.Get("ttMinHireCost"), numHirecost));
|
||||
ItemValue item = ItemClass.GetItem("casinoCoin", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
player.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
|
||||
myEntity.Buffs.RemoveBuff("buffTalkingTo");
|
||||
}
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnCancelHireInformation_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
myEntity.Buffs.RemoveBuff("buffTalkingTo");
|
||||
|
||||
hireInformationPanel.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();
|
||||
}
|
||||
}
|
||||
166
Scripts/XUIC/NPCs/XUiC_PickUpNPCPopupRebirth.cs
Normal file
166
Scripts/XUIC/NPCs/XUiC_PickUpNPCPopupRebirth.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using Audio;
|
||||
|
||||
internal class XUiC_PickUpNPCPopupRebirth : 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()
|
||||
{
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-OnOpen START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
{
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-OnOpen 1");
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
}
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-OnOpen entityID: " + entityID);
|
||||
|
||||
EntityNPCRebirth myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
||||
if (myEntity != null)
|
||||
{
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-OnOpen 3");
|
||||
Label.Text = string.Format(Localization.Get("ttPickUpCost"), myEntity.EntityName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-OnOpen Entity == null");
|
||||
}
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityNPCRebirth myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
||||
|
||||
if (myEntity != null)
|
||||
{
|
||||
ItemValue item = ItemClass.GetItem("casinoCoin", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
|
||||
|
||||
int itemCount = player.bag.GetItemCount(item, -1, -1, false);
|
||||
int itemCount2 = player.inventory.GetItemCount(item, false, -1, -1);
|
||||
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-BtnConfirm_OnPressed itemCount + itemCount2: " + (itemCount + itemCount2));
|
||||
|
||||
if (itemCount + itemCount2 >= 250)
|
||||
{
|
||||
int Remaining = 250;
|
||||
bool needMore = false;
|
||||
|
||||
int Withdraw = Remaining - itemCount2;
|
||||
|
||||
if (Withdraw <= 0)
|
||||
{
|
||||
player.inventory.DecItem(item, 250, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.inventory.DecItem(item, itemCount2, false);
|
||||
needMore = true;
|
||||
Remaining = Remaining - itemCount2;
|
||||
player.bag.DecItem(item, Remaining, false);
|
||||
}
|
||||
|
||||
var playerInventory = uiforPlayer.xui.PlayerInventory;
|
||||
if (playerInventory == null) return;
|
||||
|
||||
string ID = myEntity.EntityClass.Properties.Values["SpawnBlockName"];
|
||||
|
||||
var itemAdd = ItemClass.GetItem(ID);
|
||||
if (itemAdd == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var itemStack = new ItemStack(itemAdd, 1);
|
||||
if (!playerInventory.AddItem(itemStack, true))
|
||||
player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero);
|
||||
|
||||
if (myEntity.Buffs.HasBuff("FuriousRamsayNPCSilencer"))
|
||||
{
|
||||
ID = "modGunSoundSuppressorSilencer";
|
||||
|
||||
itemAdd = ItemClass.GetItem(ID);
|
||||
itemStack = new ItemStack(itemAdd, 1);
|
||||
if (!playerInventory.AddItem(itemStack, true))
|
||||
player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero);
|
||||
}
|
||||
|
||||
ItemStack[] array = myEntity.lootContainer.GetItems();
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (!array[i].IsEmpty())
|
||||
{
|
||||
if (!playerInventory.AddItem(array[i], true))
|
||||
{
|
||||
player.world.gameManager.ItemDropServer(array[i], player.GetPosition(), Vector3.zero);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
myEntity.bIsChunkObserver = false;
|
||||
|
||||
//Log.Out("XUiC_PickUpNPCPopupRebirth-BtnConfirm_OnPressed REMOVED HIRE, hire: " + myEntity.entityId);
|
||||
RebirthManager.RemoveHire(myEntity.entityId);
|
||||
|
||||
GameManager.Instance.World.RemoveEntity(myEntity.entityId, EnumRemoveEntityReason.Despawned);
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(uiforPlayer.entityPlayer, Localization.Get("ttMissingCash"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
uiforPlayer.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
193
Scripts/XUIC/NPCs/XUiC_RemoveSilencerPopupRebirth.cs
Normal file
193
Scripts/XUIC/NPCs/XUiC_RemoveSilencerPopupRebirth.cs
Normal file
@@ -0,0 +1,193 @@
|
||||
internal class XUiC_RemoveSilencerPopupRebirth : 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("ttRetrieveSilencer"), 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)
|
||||
return;
|
||||
|
||||
var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
||||
if (myEntity != null)
|
||||
{
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
|
||||
var playerInventory = uiforPlayer.xui.PlayerInventory;
|
||||
if (playerInventory == null) return;
|
||||
|
||||
string ID = "modGunSoundSuppressorSilencer";
|
||||
|
||||
var item = ItemClass.GetItem(ID);
|
||||
if (item == null)
|
||||
{
|
||||
//Log.Out("XUiC_RemoveSilencerPopupRebirth: Item Not Found: " + ID);
|
||||
return;
|
||||
}
|
||||
var itemStack = new ItemStack(item, 1);
|
||||
if (!playerInventory.AddItem(itemStack, true))
|
||||
player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero);
|
||||
|
||||
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_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "smg_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "smg_fire_end";
|
||||
}
|
||||
else if (weaponName == "gunnpcpipepistol")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_pistol_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_pistol_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcpipeshotgun")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_shotgun_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_shotgun_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcpiperifle")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_rifle_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_rifle_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcpipemg")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "pipe_smg_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pipe_smg_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcm60")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "m60_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "m60_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "m60_fire_end";
|
||||
}
|
||||
else if (weaponName == "gunnpcpistol")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "Pistol_Fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "Pistol_Fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcdpistol")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "desertvulture_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "desertvulture_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcak47")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "ak47_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "ak47_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "ak47_fire_end";
|
||||
}
|
||||
else if (weaponName == "gunnpctrifle")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "tacticalar_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "tacticalar_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpchrifle")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "sniperrifle_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "sniperrifle_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcsrifle")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "sharpshooter_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "sharpshooter_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_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "pump_shotgun_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
else if (weaponName == "gunnpcashotgun")
|
||||
{
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_start"] = "autoshotgun_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_loop"] = "autoshotgun_fire";
|
||||
myEntity.inventory.holdingItem.Actions[1].Properties.Values["Sound_end"] = "";
|
||||
}
|
||||
|
||||
myEntity.inventory.ForceHoldingItemUpdate();
|
||||
myEntity.Buffs.RemoveBuff("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");
|
||||
}
|
||||
}
|
||||
86
Scripts/XUIC/NPCs/XUiC_RepairReportRebirth.cs
Normal file
86
Scripts/XUIC/NPCs/XUiC_RepairReportRebirth.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
internal class XUiC_RepairReportRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label Label;
|
||||
public XUiV_Panel Panel;
|
||||
public float flSubLevels = 0.1f;
|
||||
public bool bDifferentBiome = false;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent;
|
||||
((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)
|
||||
{
|
||||
string strSerialize = myEntity.strSerialize;
|
||||
|
||||
Label.Text = Localization.Get("ttRepairReport");
|
||||
|
||||
if (strSerialize != null)
|
||||
{
|
||||
if (strSerialize.Length > 0)
|
||||
{
|
||||
//Log.Out("EntityNPCRebirth-OnUpdateLive strSerialize.Length: " + strSerialize.Length);
|
||||
//Log.Out("EntityNPCRebirth-OnUpdateLive strSerializeTmp LOAD: " + strSerialize);
|
||||
string[] array = strSerialize.Split(new char[]
|
||||
{
|
||||
'<'
|
||||
});
|
||||
|
||||
if (array.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
string[] array2 = array[i].Split(new char[]
|
||||
{
|
||||
'|'
|
||||
});
|
||||
for (int i2 = 0; i2 < array2.Length; i2++)
|
||||
{
|
||||
if (i2 == 0)
|
||||
{
|
||||
Label.Text = Label.Text + " • " + Localization.Get(array2[i2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Label.Text = Label.Text + " ([88d188]" + array2[i2] + "[-])";
|
||||
}
|
||||
}
|
||||
Label.Text = Label.Text + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
122
Scripts/XUIC/NPCs/XUiC_RespawnEntityRebirth.cs
Normal file
122
Scripts/XUIC/NPCs/XUiC_RespawnEntityRebirth.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
117
Scripts/XUIC/NPCs/XUiC_ShowStatsCompanionPopupRebirth.cs
Normal file
117
Scripts/XUIC/NPCs/XUiC_ShowStatsCompanionPopupRebirth.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
internal class XUiC_ShowStatsCompanionPopupRebirth : 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_ShowStatsCompanionPopupRebirth-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;
|
||||
NPCLevel = (XUiV_Label)Panel.Controller.GetChildById("NPCLevel").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;
|
||||
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-Init END");
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-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_ShowStatsCompanionPopupRebirth-OnOpen 1");
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
return;
|
||||
}
|
||||
|
||||
var myEntity = player.world.GetEntity(entityID) as EntityNPCRebirth;
|
||||
if (myEntity == null)
|
||||
{
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-OnOpen 2");
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
return;
|
||||
}
|
||||
|
||||
float flNPCLevel = myEntity.Buffs.GetCustomVar("$FR_NPC_Level");
|
||||
float flNPCKills = myEntity.Buffs.GetCustomVar("$varNumKills");
|
||||
|
||||
var entityClass = EntityClass.list[myEntity.entityClass];
|
||||
|
||||
NPCName.Text = myEntity.EntityName;
|
||||
|
||||
NPCLevel.Text = "" + flNPCLevel;
|
||||
|
||||
float perc = RebirthUtilities.getDiscount(player);
|
||||
|
||||
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;
|
||||
|
||||
base.OnOpen();
|
||||
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-OnOpen END");
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-BtnConfirm_OnPressed START");
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-BtnConfirm_OnPressed END");
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-BtnCancel_OnPressed START");
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-BtnCancel_OnPressed END");
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-OnClose START");
|
||||
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
|
||||
//Log.Out("XUiC_ShowStatsCompanionPopupRebirth-OnClose END");
|
||||
}
|
||||
}
|
||||
290
Scripts/XUIC/NPCs/XUiC_ShowStatsPopupRebirth - Copy.cs
Normal file
290
Scripts/XUIC/NPCs/XUiC_ShowStatsPopupRebirth - Copy.cs
Normal file
@@ -0,0 +1,290 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
1306
Scripts/XUIC/XUiC_ClassHUDRebirth.cs
Normal file
1306
Scripts/XUIC/XUiC_ClassHUDRebirth.cs
Normal file
@@ -0,0 +1,1306 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
internal class XUiC_ClassHUDRebirth : XUiController
|
||||
{
|
||||
private EntityPlayerLocal LocalPlayer;
|
||||
private readonly CachedStringFormatterXuiRgbaColor stealthColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatter<float> statfillFormatter = new CachedStringFormatter<float>((Func<float, string>)(_i => _i.ToCultureInvariantString()));
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatter<float, float> statmodifiedmaxFormatter = new CachedStringFormatter<float, float>((Func<float, float, string>)((_f1, _f2) => (_f1 / _f2).ToCultureInvariantString()));
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue START");
|
||||
string className = "";
|
||||
string classLvl = "";
|
||||
string classSet = "true";
|
||||
string classBackgroundColor = "";
|
||||
string classBackgroundFill = "0";
|
||||
string classPerc = "";
|
||||
string perk1Name = "";
|
||||
string perk2Name = "";
|
||||
string perk3Name = "";
|
||||
string perk1Lvl = "";
|
||||
string perk2Lvl = "";
|
||||
string perk3Lvl = "";
|
||||
string perk1Perc = "";
|
||||
string perk2Perc = "";
|
||||
string perk3Perc = "";
|
||||
|
||||
string purgeBackgroundColor = "";
|
||||
string purgeBackgroundFill = "0";
|
||||
string biomeName = "";
|
||||
|
||||
string rampageNum = "";
|
||||
//string downfallNum = "";
|
||||
string naturalSelectionNum = "";
|
||||
|
||||
float playerClass = 0;
|
||||
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
rampageNum = RebirthVariables.localConstants["$varFuriousRamsayRampageMax_Cst"].ToString();
|
||||
naturalSelectionNum = RebirthVariables.localConstants["$varFuriousRamsayTheyGrowStrongerKills_Cst"].ToString();
|
||||
|
||||
playerClass = this.LocalPlayer.Buffs.GetCustomVar("$ActiveClass_FR");
|
||||
float total = 0;
|
||||
float unit = 0;
|
||||
float perc = 0;
|
||||
int level = 0;
|
||||
|
||||
total = RebirthVariables.localConstants["$varFuriousRamsayPerk1PercUnit"];
|
||||
unit = total % 1;
|
||||
level = (int)total;
|
||||
perk1Lvl = level.ToString();
|
||||
perk1Perc = unit.ToString();
|
||||
|
||||
total = RebirthVariables.localConstants["$varFuriousRamsayPerk2PercUnit"];
|
||||
unit = total % 1;
|
||||
level = (int)total;
|
||||
perk2Lvl = level.ToString();
|
||||
perk2Perc = unit.ToString();
|
||||
|
||||
total = RebirthVariables.localConstants["$varFuriousRamsayPerk3PercUnit"];
|
||||
unit = total % 1;
|
||||
level = (int)total;
|
||||
perk3Lvl = level.ToString();
|
||||
perk3Perc = unit.ToString();
|
||||
|
||||
string biomeSuffix = RebirthUtilities.GetBiomeName(this.LocalPlayer);
|
||||
biomeName = Localization.Get("biome_" + biomeSuffix);
|
||||
|
||||
if (biomeSuffix == "pine_forest")
|
||||
{
|
||||
purgeBackgroundColor = "58, 105, 70";
|
||||
}
|
||||
else if (biomeSuffix == "desert")
|
||||
{
|
||||
purgeBackgroundColor = "184, 181, 140";
|
||||
}
|
||||
else if (biomeSuffix == "snow")
|
||||
{
|
||||
purgeBackgroundColor = "128, 128, 128";
|
||||
}
|
||||
else if (biomeSuffix == "wasteland")
|
||||
{
|
||||
purgeBackgroundColor = "152, 166, 121";
|
||||
}
|
||||
else if (biomeSuffix == "burnt_forest")
|
||||
{
|
||||
purgeBackgroundColor = "56, 56, 56";
|
||||
}
|
||||
|
||||
if (playerClass == 1)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayHunterPercUnit"];
|
||||
className = Localization.Get("ttHunter").ToUpper();
|
||||
classBackgroundColor = "53,105,101";
|
||||
perk1Name = Localization.Get("ttSpears").ToUpper();
|
||||
perk2Name = Localization.Get("ttBows").ToUpper();
|
||||
perk3Name = Localization.Get("ttLongRangeRifles").ToUpper();
|
||||
}
|
||||
else if (playerClass == 2)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayThugPercUnit"];
|
||||
className = Localization.Get("ttThug").ToUpper();
|
||||
classBackgroundColor = "104,105,53";
|
||||
perk1Name = Localization.Get("ttClubs").ToUpper();
|
||||
perk2Name = Localization.Get("ttShotguns").ToUpper();
|
||||
perk3Name = "";
|
||||
}
|
||||
else if (playerClass == 3)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayButcherPercUnit"];
|
||||
className = Localization.Get("ttButcher").ToUpper();
|
||||
classBackgroundColor = "105,53,53";
|
||||
perk1Name = Localization.Get("ttSwords").ToUpper();
|
||||
perk2Name = Localization.Get("ttAssaultRifles").ToUpper();
|
||||
perk3Name = "";
|
||||
}
|
||||
else if (playerClass == 4)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsaySoldierPercUnit"];
|
||||
className = Localization.Get("ttSoldier").ToUpper();
|
||||
classBackgroundColor = "56,105,53";
|
||||
perk1Name = Localization.Get("ttAxes").ToUpper();
|
||||
perk2Name = Localization.Get("ttMachineguns").ToUpper();
|
||||
perk3Name = "";
|
||||
}
|
||||
else if (playerClass == 5)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayTechnogeekPercUnit"];
|
||||
className = Localization.Get("ttTechnogeek").ToUpper();
|
||||
classBackgroundColor = "74,53,105";
|
||||
perk1Name = Localization.Get("ttBatons").ToUpper();
|
||||
perk2Name = Localization.Get("ttRevolvers").ToUpper();
|
||||
perk3Name = Localization.Get("ttDeployableTurrets").ToUpper();
|
||||
}
|
||||
else if (playerClass == 6)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayMadmanPercUnit"];
|
||||
className = Localization.Get("ttMadman").ToUpper();
|
||||
classBackgroundColor = "105,93,53";
|
||||
perk1Name = Localization.Get("ttKnuckles").ToUpper();
|
||||
perk2Name = Localization.Get("ttSubmachineGuns").ToUpper();
|
||||
perk3Name = ""; // "EXPLOSIVES";
|
||||
}
|
||||
else if (playerClass == 7)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayBuilderPercUnit"];
|
||||
className = Localization.Get("ttBuilder").ToUpper();
|
||||
classBackgroundColor = "105,53,105";
|
||||
perk1Name = Localization.Get("ttHammers").ToUpper();
|
||||
perk2Name = Localization.Get("ttPistols").ToUpper();
|
||||
perk3Name = Localization.Get("ttElectricTraps").ToUpper();
|
||||
}
|
||||
else if (playerClass == 8)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayChefPercUnit"];
|
||||
className = Localization.Get("ttChef").ToUpper();
|
||||
classBackgroundColor = "100,100,100";
|
||||
perk1Name = Localization.Get("ttKnives").ToUpper();
|
||||
perk2Name = Localization.Get("ttHeavyHandguns").ToUpper();
|
||||
perk3Name = "";
|
||||
}
|
||||
else if (playerClass == 9)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayWitchDoctorPercUnit"];
|
||||
className = Localization.Get("ttWitchDoctor").ToUpper();
|
||||
classBackgroundColor = "100,100,100";
|
||||
perk1Name = Localization.Get("ttScythes").ToUpper();
|
||||
perk2Name = Localization.Get("ttTacticalRifles").ToUpper();
|
||||
perk3Name = Localization.Get("ttBlackMagic").ToUpper();
|
||||
}
|
||||
else if (playerClass == 10)
|
||||
{
|
||||
RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"] = RebirthVariables.localVariables["$varFuriousRamsayBerserkerPercUnit"];
|
||||
className = Localization.Get("ttBerserker").ToUpper();
|
||||
classBackgroundColor = "53,105,101";
|
||||
perk1Name = Localization.Get("ttMelee").ToUpper();
|
||||
perk2Name = Localization.Get("ttRage").ToUpper();
|
||||
perk3Name = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
className = Localization.Get("ttClassNotActive");
|
||||
classLvl = "";
|
||||
classSet = "false";
|
||||
classBackgroundColor = "30,30,30";
|
||||
classBackgroundFill = "0";
|
||||
classPerc = "";
|
||||
perk1Name = "";
|
||||
perk2Name = "";
|
||||
perk3Name = "";
|
||||
}
|
||||
|
||||
if (playerClass > 0)
|
||||
{
|
||||
total = RebirthVariables.localConstants["$varFuriousRamsayClassPercUnit"];
|
||||
|
||||
unit = total % 1;
|
||||
level = (int)total;
|
||||
|
||||
classBackgroundFill = unit.ToString();
|
||||
classLvl = level.ToString();
|
||||
classPerc = (Math.Truncate(unit * 100 * 100) / 100).ToString() + "%";
|
||||
}
|
||||
|
||||
if (perk1Name == "")
|
||||
{
|
||||
perk1Lvl = "";
|
||||
perk1Perc = "0";
|
||||
}
|
||||
if (perk2Name == "")
|
||||
{
|
||||
perk2Lvl = "";
|
||||
perk2Perc = "0";
|
||||
}
|
||||
if (perk3Name == "")
|
||||
{
|
||||
perk3Lvl = "";
|
||||
perk3Perc = "0";
|
||||
}
|
||||
}
|
||||
|
||||
string genericClassName = "";
|
||||
bool hasQuest = false;
|
||||
float classID = 0f;
|
||||
string meleeFragmentName = "";
|
||||
string rangedFragmentName = "";
|
||||
Dictionary<string, float> classMeleePerc = new Dictionary<string, float>(); ;
|
||||
Dictionary<string, float> classRangedPerc = new Dictionary<string, float>(); ;
|
||||
|
||||
classRangedPerc["Hunter"] = 0;
|
||||
classRangedPerc["Thug"] = 0;
|
||||
classRangedPerc["Butcher"] = 0;
|
||||
classRangedPerc["Soldier"] = 0;
|
||||
classRangedPerc["Technogeek"] = 0;
|
||||
classRangedPerc["Madman"] = 0;
|
||||
classRangedPerc["Builder"] = 0;
|
||||
classRangedPerc["Chef"] = 0;
|
||||
classRangedPerc["WitchDoctor"] = 0;
|
||||
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
classID = this.LocalPlayer.Buffs.GetCustomVar("$FR_SelectedClass");
|
||||
|
||||
if (classID > 0)
|
||||
{
|
||||
genericClassName = RebirthUtilities.GetClassNameFromID(classID);
|
||||
string questName = "quest_BasicSurvival_" + genericClassName;
|
||||
|
||||
for (int i = 0; i < this.LocalPlayer.QuestJournal.quests.Count; i++)
|
||||
{
|
||||
if (this.LocalPlayer.QuestJournal.quests[i].ID.ToLower() == questName.ToLower())
|
||||
{
|
||||
hasQuest = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
List<string> tagNames = this.LocalPlayer.inventory.holdingItem.ItemTags.GetTagNames();
|
||||
classMeleePerc["Berserker"] = 0;
|
||||
meleeFragmentName = "";
|
||||
|
||||
foreach (string key in RebirthVariables.localExpertiseCrafting.Keys)
|
||||
{
|
||||
if (key.ToLower().Contains("pipe"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[0].levels;
|
||||
|
||||
if (key.ToLower().Contains("rifle"))
|
||||
{
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayPipeRiflePercUnit"] / craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
if (perc > classRangedPerc["Hunter"])
|
||||
{
|
||||
classRangedPerc["Hunter"] = (int)perc;
|
||||
}
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue PIPE RIFLE classRangedPerc[Hunter]: " + classRangedPerc["Hunter"]);
|
||||
rangedFragmentName = "FR_ClassInfoBook" + genericClassName + "1_icon";
|
||||
|
||||
}
|
||||
else if (key.ToLower().Contains("shotgun"))
|
||||
{
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayPipeShotgunPercUnit"] / craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classRangedPerc["Thug"] = (int)perc;
|
||||
rangedFragmentName = "FR_ClassInfoBook" + genericClassName + "1_icon";
|
||||
}
|
||||
else if (key.ToLower().Contains("pistol"))
|
||||
{
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayPipePistolPercUnit"] / craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classRangedPerc["Technogeek"] = (int)perc; ;
|
||||
classRangedPerc["Builder"] = (int)perc; ;
|
||||
classRangedPerc["Chef"] = (int)perc; ;
|
||||
rangedFragmentName = "FR_ClassInfoBook" + genericClassName + "1_icon";
|
||||
}
|
||||
else if (key.ToLower().Contains("machinegun"))
|
||||
{
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayPipeMachinegunPercUnit"] / craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classRangedPerc["Butcher"] = (int)perc; ;
|
||||
classRangedPerc["Soldier"] = (int)perc; ;
|
||||
classRangedPerc["Madman"] = (int)perc; ;
|
||||
classRangedPerc["WitchDoctor"] = (int)perc; ;
|
||||
rangedFragmentName = "FR_ClassInfoBook" + genericClassName + "1_icon";
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("bows"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[0].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayBowsPercUnit"] / craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue $varFuriousRamsayBowsPercUnit: " + RebirthVariables.localVariables["$varFuriousRamsayBowsPercUnit"]);
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingLevelsList.Count: " + craftingLevelsList.Count);
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel: " + craftingLevelsList[craftingLevelsList.Count - 1].categoryLevel);
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue perc: " + perc);
|
||||
if (perc > classRangedPerc["Hunter"])
|
||||
{
|
||||
classRangedPerc["Hunter"] = (int)perc;
|
||||
}
|
||||
rangedFragmentName = "FR_ClassInfoBook" + genericClassName + "1_icon";
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue BOW classRangedPerc[Hunter]: " + classRangedPerc["Hunter"]);
|
||||
}
|
||||
else if (key.ToLower().Contains("spears"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsaySpearsPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Hunter"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("spear"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookHunter2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("clubs"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayClubsPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Thug"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("club"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookThug2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("swords"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsaySwordsPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Butcher"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("sword"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookButcher2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("axes"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayAxesPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Soldier"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("axe"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookSoldier2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("batons"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayBatonsPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Technogeek"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("baton"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookTechnogeek2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("knuckles"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayKnucklesPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Madman"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("knuckle"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookMadman2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("hammers"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayHammersPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Builder"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("hammer"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookBuilder2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("knives"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayKnivesPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["Chef"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("knife"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookChef2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (key.ToLower().Contains("scythes"))
|
||||
{
|
||||
List<categoryCrafting> CategoryCraftingList = RebirthVariables.localExpertiseCrafting[key];
|
||||
|
||||
List<craftingLevels> craftingLevelsList = CategoryCraftingList[1].levels;
|
||||
|
||||
float perc = (RebirthVariables.localVariables["$varFuriousRamsayScythesPercUnit"] / craftingLevelsList[0].categoryLevel) * 100;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
classMeleePerc["WitchDoctor"] = (int)perc;
|
||||
|
||||
for (int i = 0; i < tagNames.Count; i++)
|
||||
{
|
||||
if (tagNames[i].ToLower().Contains("scythe"))
|
||||
{
|
||||
classMeleePerc["Berserker"] = (int)perc;
|
||||
meleeFragmentName = "FR_ClassInfoBookWitchDoctor2_icon";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue hasQuest: " + hasQuest);
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue classID: " + classID);
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "isPurge":
|
||||
value = (RebirthVariables.customScenario == "purge").ToString();
|
||||
return true;
|
||||
case "purgeBackgroundColor":
|
||||
value = purgeBackgroundColor;
|
||||
return true;
|
||||
case "purgeBackgroundFill":
|
||||
float perc = RebirthVariables.purgeDisplayPercentage;
|
||||
|
||||
if (perc > 100)
|
||||
{
|
||||
perc = 100;
|
||||
}
|
||||
|
||||
value = (perc / 100).ToString();
|
||||
return true;
|
||||
case "biomeName":
|
||||
value = biomeName.ToUpper();
|
||||
return true;
|
||||
case "purgePerc":
|
||||
double num = Math.Round(RebirthVariables.purgeDisplayPercentage, 1);
|
||||
|
||||
if (num > 100)
|
||||
{
|
||||
num = 100;
|
||||
}
|
||||
|
||||
value = num.ToString() + "%";
|
||||
return true;
|
||||
case "purgeLabel":
|
||||
value = RebirthVariables.purgeLabel;
|
||||
return true;
|
||||
case "craftingItem":
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem: " + RebirthVariables.holdingItemIcon);
|
||||
if (!hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 1");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 2");
|
||||
value = "ui_game_symbol_" + RebirthVariables.holdingItemIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 3");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 4");
|
||||
if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 5");
|
||||
if (RebirthVariables.holdingItemIcon != "")
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 6");
|
||||
|
||||
value = "ui_game_symbol_" + RebirthVariables.holdingItemIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 7");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem 8");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItem value: " + value);
|
||||
|
||||
return true;
|
||||
case "craftingItemQuality":
|
||||
if (!hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 1");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 2");
|
||||
value = RebirthVariables.holdingItemQuality.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 3");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 4");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 5");
|
||||
value = RebirthVariables.holdingItemQuality.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 6");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemQuality 7");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "craftingItemColor":
|
||||
if (!hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemColor 1");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = RebirthVariables.holdingItemColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,0,0,0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = RebirthVariables.holdingItemColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,0,0,0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,0,0,0";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "craftingItemColorPerc":
|
||||
if (!hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemColor 1");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = RebirthVariables.holdingItemPerc.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = RebirthVariables.holdingItemPerc.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "shouldCraft":
|
||||
if (!hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemColor 1");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = RebirthVariables.holdingItemCraftIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = RebirthVariables.holdingItemCraftIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "craftingItemColorBackground":
|
||||
if (!hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue craftingItemColorBackground 1");
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = "50,50,50,255";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,0,0,0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 1)
|
||||
{
|
||||
if (RebirthVariables.holdingItem != "")
|
||||
{
|
||||
value = "50,50,50,255";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,0,0,0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,0,0,0";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "meleeBookFragment":
|
||||
if (classID > 0)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 1");
|
||||
if (hasQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 2");
|
||||
if (RebirthVariables.cycleArea1 == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 3");
|
||||
if (classID == 10)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 4");
|
||||
value = meleeFragmentName;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 5");
|
||||
value = "FR_ClassInfoBook" + genericClassName + "2_icon";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 6");
|
||||
if (playerClass > 0)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 7");
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 8");
|
||||
if (RebirthVariables.isCraftableItem)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 9");
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 10");
|
||||
if (classID == 10)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 11");
|
||||
value = meleeFragmentName;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 12");
|
||||
value = "FR_ClassInfoBook" + genericClassName + "2_icon";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment 13");
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue meleeBookFragment ");
|
||||
value = "";
|
||||
}
|
||||
|
||||
return true;
|
||||
case "rangedBookFragment":
|
||||
if (classID > 0)
|
||||
{
|
||||
if (hasQuest)
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 0)
|
||||
{
|
||||
value = rangedFragmentName;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.isCraftableItem)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerClass > 0)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = rangedFragmentName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
return true;
|
||||
case "meleeBookFragmentPerc":
|
||||
if (classID > 0)
|
||||
{
|
||||
if (hasQuest)
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 0)
|
||||
{
|
||||
value = classMeleePerc[genericClassName].ToString() + "%";
|
||||
|
||||
if (classMeleePerc[genericClassName].ToString() == "100")
|
||||
{
|
||||
value = "[9f5ec4]" + value + "[-]";
|
||||
}
|
||||
|
||||
if (classID == 10 && meleeFragmentName == "")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.isCraftableItem)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerClass > 0)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = classMeleePerc[genericClassName].ToString() + "%";
|
||||
|
||||
if (classMeleePerc[genericClassName].ToString() == "100")
|
||||
{
|
||||
value = "[9f5ec4]" + value + "[-]";
|
||||
}
|
||||
|
||||
if (classID == 10 && meleeFragmentName == "")
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
return true;
|
||||
case "rangedBookFragmentPerc":
|
||||
if (classID > 0 && classID != 10)
|
||||
{
|
||||
if (hasQuest)
|
||||
{
|
||||
if (RebirthVariables.cycleArea1 == 0)
|
||||
{
|
||||
value = classRangedPerc[genericClassName].ToString() + "%";
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue A genericClassName: " + genericClassName);
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue A value: " + value);
|
||||
|
||||
if (classRangedPerc[genericClassName].ToString() == "100")
|
||||
{
|
||||
value = "[9f5ec4]" + value + "[-]";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.isCraftableItem)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (playerClass > 0)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = classRangedPerc[genericClassName].ToString() + "%";
|
||||
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue B genericClassName: " + genericClassName);
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue B value: " + value);
|
||||
|
||||
if (classRangedPerc[genericClassName].ToString() == "100")
|
||||
{
|
||||
value = "[9f5ec4]" + value + "[-]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
return true;
|
||||
case "lootStage":
|
||||
value = "";
|
||||
if (this.LocalPlayer != null && XUi.IsGameRunning())
|
||||
{
|
||||
value = string.Format(Localization.Get("xuiLootstageDescription_FR"), (object)this.LocalPlayer.GetHighestPartyLootStage(0f, 0f).ToString());
|
||||
}
|
||||
|
||||
return true;
|
||||
case "playerLevel":
|
||||
value = "";
|
||||
if (this.LocalPlayer != null && XUi.IsGameRunning())
|
||||
{
|
||||
value = string.Format(Localization.Get("xuiPlayerLevelDescription_FR"), (object)this.LocalPlayer.Progression.Level, RebirthVariables.displayGamestageLabel);
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue value: " + value);
|
||||
}
|
||||
|
||||
return true;
|
||||
case "scenarioIcon":
|
||||
value = "ui_game_symbol_fetch_loot";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "ui_game_symbol_purgesupplies";
|
||||
//Log.Out("XUiC_ClassHUDRebirth-GetBindingValue value: " + value);
|
||||
}
|
||||
|
||||
return true;
|
||||
case "questProgression":
|
||||
value = "";
|
||||
if (this.LocalPlayer != null && XUi.IsGameRunning())
|
||||
{
|
||||
//int currentFactionTier = this.LocalPlayer.QuestJournal.GetCurrentFactionTier((byte)1);
|
||||
//value = string.Format(Localization.Get("xuiQuestTierDescription_FR"), (object)ValueDisplayFormatters.RomanNumber(this.LocalPlayer.QuestJournal.GetCurrentFactionTier((byte)1)), (object)this.LocalPlayer.QuestJournal.GetQuestFactionPoints((byte)1), (object)this.LocalPlayer.QuestJournal.GetQuestFactionMax((byte)1, currentFactionTier));
|
||||
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
//float purgeKillsIncrement = this.LocalPlayer.Buffs.GetCustomVar("$purgeKillsIncrement");
|
||||
//float purgeRedeemKills = this.LocalPlayer.Buffs.GetCustomVar("$purgeRedeemKills");
|
||||
//float purgeRedeemableKills = this.LocalPlayer.Buffs.GetCustomVar("$purgeRedeemableKills");
|
||||
float purgeKillsTarget = RebirthVariables.purgeAirDropNumKills + (this.LocalPlayer.Buffs.GetCustomVar("$purgeKillsIncrement") * RebirthVariables.purgeAirDropNumKillsIncrement) - this.LocalPlayer.Buffs.GetCustomVar("$ModPurge") * 10;
|
||||
float purgeKills = this.LocalPlayer.Buffs.GetCustomVar("$purgeKills");
|
||||
float numRemaining = purgeKillsTarget - purgeKills;
|
||||
|
||||
if (numRemaining < 0)
|
||||
{
|
||||
numRemaining = 0;
|
||||
}
|
||||
|
||||
value = $": [8568ab]{numRemaining}[-]/[a4e37d]{purgeKillsTarget}[-] {Localization.Get("ttkills")}";
|
||||
}
|
||||
else
|
||||
{
|
||||
int numQuests = RebirthVariables.customJobsToNextTier;
|
||||
|
||||
int questPoints = this.LocalPlayer.QuestJournal.GetQuestFactionPoints((byte)1);
|
||||
int questTier = this.LocalPlayer.QuestJournal.GetCurrentFactionTier((byte)1);
|
||||
|
||||
int tierPoints = 0;
|
||||
|
||||
for (int i = 1; i <= questTier; i++)
|
||||
{
|
||||
tierPoints = tierPoints + (i * numQuests);
|
||||
}
|
||||
|
||||
int pointsLeft = tierPoints - questPoints;
|
||||
int jobsLeft = pointsLeft / questTier;
|
||||
|
||||
int numPointsLeft = tierPoints - pointsLeft;
|
||||
|
||||
if (pointsLeft > 0 && pointsLeft < questTier)
|
||||
{
|
||||
jobsLeft = 1;
|
||||
}
|
||||
|
||||
int total = numQuests - jobsLeft;
|
||||
|
||||
if (total > numQuests)
|
||||
{
|
||||
total = numQuests;
|
||||
}
|
||||
|
||||
value = string.Format(Localization.Get("xuiQuestTierDescription_FR"), (object)ValueDisplayFormatters.RomanNumber(this.LocalPlayer.QuestJournal.GetCurrentFactionTier((byte)1)), (object)total, (object)numQuests);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "className":
|
||||
value = className;
|
||||
return true;
|
||||
case "classLevel":
|
||||
value = classLvl;
|
||||
return true;
|
||||
case "classSet":
|
||||
value = classSet;
|
||||
return true;
|
||||
case "classPerc":
|
||||
value = classPerc;
|
||||
return true;
|
||||
case "classBackgroundColor":
|
||||
value = classBackgroundColor;
|
||||
return true;
|
||||
case "classBackgroundFill":
|
||||
value = classBackgroundFill;
|
||||
return true;
|
||||
case "perk1Name":
|
||||
value = perk1Name;
|
||||
return true;
|
||||
case "perk2Name":
|
||||
value = perk2Name;
|
||||
return true;
|
||||
case "perk3Name":
|
||||
value = perk3Name;
|
||||
return true;
|
||||
case "perk1Level":
|
||||
value = perk1Lvl;
|
||||
return true;
|
||||
case "perk2Level":
|
||||
value = perk2Lvl;
|
||||
return true;
|
||||
case "perk3Level":
|
||||
value = perk3Lvl;
|
||||
return true;
|
||||
case "perk1Perc":
|
||||
value = perk1Perc;
|
||||
return true;
|
||||
case "perk2Perc":
|
||||
value = perk2Perc;
|
||||
return true;
|
||||
case "perk3Perc":
|
||||
value = perk3Perc;
|
||||
return true;
|
||||
case "perk1Visible":
|
||||
value = "false";
|
||||
if (perk1Name.Trim().Length > 0)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
case "perk2Visible":
|
||||
value = "false";
|
||||
if (perk2Name.Trim().Length > 0)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
case "perk3Visible":
|
||||
value = "false";
|
||||
if (perk3Name.Trim().Length > 0)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
case "strengthLvl":
|
||||
value = ((int)RebirthVariables.localVariables["$varFuriousRamsayStrengthPercUnit"]).ToString();
|
||||
return true;
|
||||
case "dexterityLvl":
|
||||
value = ((int)RebirthVariables.localVariables["$varFuriousRamsayDexterityPercUnit"]).ToString();
|
||||
return true;
|
||||
case "constitutionLvl":
|
||||
value = ((int)RebirthVariables.localVariables["$varFuriousRamsayConstitutionPercUnit"]).ToString();
|
||||
return true;
|
||||
case "intelligenceLvl":
|
||||
value = ((int)RebirthVariables.localVariables["$varFuriousRamsayIntelligencePercUnit"]).ToString();
|
||||
return true;
|
||||
case "charismaLvl":
|
||||
value = ((int)RebirthVariables.localVariables["$varFuriousRamsayCharismaPercUnit"]).ToString();
|
||||
return true;
|
||||
case "strengthPerc":
|
||||
value = (RebirthVariables.localVariables["$varFuriousRamsayStrengthPercUnit"] % 1).ToString();
|
||||
return true;
|
||||
case "dexterityPerc":
|
||||
value = (RebirthVariables.localVariables["$varFuriousRamsayDexterityPercUnit"] % 1).ToString();
|
||||
return true;
|
||||
case "constitutionPerc":
|
||||
value = (RebirthVariables.localVariables["$varFuriousRamsayConstitutionPercUnit"] % 1).ToString();
|
||||
return true;
|
||||
case "intelligencePerc":
|
||||
value = (RebirthVariables.localVariables["$varFuriousRamsayIntelligencePercUnit"] % 1).ToString();
|
||||
return true;
|
||||
case "charismaPerc":
|
||||
value = (RebirthVariables.localVariables["$varFuriousRamsayCharismaPercUnit"] % 1).ToString();
|
||||
return true;
|
||||
case "rampageNum":
|
||||
value = rampageNum;
|
||||
return true;
|
||||
case "naturalSelectionPos":
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "95";
|
||||
return true;
|
||||
}
|
||||
|
||||
value = "108";
|
||||
return true;
|
||||
case "naturalSelectionLabel":
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = Localization.Get("PurgedLabel");
|
||||
return true;
|
||||
}
|
||||
|
||||
value = Localization.Get("NaturalSelectionLabel");
|
||||
return true;
|
||||
case "naturalSelectionNum":
|
||||
if (this.LocalPlayer != null && RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
//value = this.LocalPlayer.Buffs.GetCustomVar("$totalPurgeKills").ToString() + " ([8568ab]" + this.LocalPlayer.Buffs.GetCustomVar("$purgeKills").ToString() + "[-])";
|
||||
value = this.LocalPlayer.Buffs.GetCustomVar("$totalPurgeKills").ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
value = naturalSelectionNum;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-OnOpen START");
|
||||
base.OnOpen();
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-OnOpen 1");
|
||||
this.LocalPlayer = this.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
private float currentTime;
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-Update START");
|
||||
this.currentTime -= _dt;
|
||||
base.Update(_dt);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-Update 1");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ClassHUDRebirth-Update 2");
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
146
Scripts/XUIC/XUiC_CompassWindowRebirth.cs
Normal file
146
Scripts/XUIC/XUiC_CompassWindowRebirth.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_CompassWindowRebirth : XUiC_CompassWindow
|
||||
{
|
||||
public readonly CachedStringFormatter<int> levelFormatter = new CachedStringFormatter<int>((Func<int, string>)([PublicizedFrom(EAccessModifier.Internal)] (_i) => _i.ToString("+0;-#")));
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName == "isHordeNightLonger")
|
||||
{
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isHordeNightLonger = RebirthUtilities.isHordeNightLonger();
|
||||
|
||||
//Log.Out("XUiC_CompassWindowRebirth-GetBindingValue isHordeNightLonger: " + isHordeNightLonger);
|
||||
|
||||
if (isHordeNightLonger)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "isPurge")
|
||||
{
|
||||
if (!RebirthVariables.purgeDisplay)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "purgeVolumes")
|
||||
{
|
||||
value = RebirthVariables.currentSleeperVolumeCount.ToString();
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "purgeEntities")
|
||||
{
|
||||
value = RebirthVariables.currentSleeperEntityCount.ToString();
|
||||
|
||||
if (RebirthVariables.currentSleeperVolumeCount > 1)
|
||||
{
|
||||
value = value + "+";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.currentSleeperEntityCount == 0)
|
||||
{
|
||||
value = "1+";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = value + "-";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "isNotHordeNight")
|
||||
{
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "isPastHordeNight")
|
||||
{
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
value = "-55";
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isPastHordeNight = RebirthUtilities.isPastHordeNight();
|
||||
|
||||
//Log.Out("XUiC_CompassWindowRebirth-GetBindingValue isPastHordeNight: " + isPastHordeNight);
|
||||
|
||||
if (isPastHordeNight)
|
||||
{
|
||||
value = "-85";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "-55";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "hnHeadshots")
|
||||
{
|
||||
value = RebirthVariables.localConstants["$varFuriousRamsayHNHeadShots_Cst"].ToString();
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "hnKills")
|
||||
{
|
||||
value = RebirthVariables.localConstants["$varFuriousRamsayHNKills_Cst"].ToString();
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "lootstage")
|
||||
{
|
||||
value = ((this.localPlayer != null) ? this.localPlayer.GetHighestPartyLootStage(0f, 0f).ToString() : "");
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "mapelevation")
|
||||
{
|
||||
if (XUi.IsGameRunning() && this.xui.playerUI.entityPlayer != null)
|
||||
{
|
||||
int _v1 = Mathf.RoundToInt(this.xui.playerUI.entityPlayer.GetPosition().y - WeatherManager.SeaLevel());
|
||||
value = this.levelFormatter.Format(_v1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "playerlevel")
|
||||
{
|
||||
int playerLevel = 0;
|
||||
|
||||
if (this.localPlayer != null)
|
||||
{
|
||||
playerLevel = this.localPlayer.Progression.GetLevel();
|
||||
//Log.Out("LEVEL: " + playerLevel);
|
||||
}
|
||||
|
||||
value = playerLevel.ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.GetBindingValue(ref value, bindingName);
|
||||
}
|
||||
}
|
||||
38
Scripts/XUIC/XUiC_ConfirmRebirth.cs
Normal file
38
Scripts/XUIC/XUiC_ConfirmRebirth.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
internal class XUiC_ConfirmRebirth : 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()
|
||||
{
|
||||
base.OnOpen();
|
||||
Label.Label.text = Localization.Get("ttNotGetBack");
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
XUiC_ConfirmWindowGroupRebirth parentByType = GetParentByType<XUiC_ConfirmWindowGroupRebirth>();
|
||||
|
||||
if (parentByType != null)
|
||||
{
|
||||
NavObjectManager.Instance.UnRegisterNavObject(parentByType.currentVehicleEntity.NavObject);
|
||||
xui.playerUI.entityPlayer.world.RemoveEntity(parentByType.currentVehicleEntity.entityId, EnumRemoveEntityReason.Killed);
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
}
|
||||
7
Scripts/XUIC/XUiC_ConfirmWindowGroupRebirth.cs
Normal file
7
Scripts/XUIC/XUiC_ConfirmWindowGroupRebirth.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_ConfirmWindowGroupRebirth : XUiController
|
||||
{
|
||||
public EntityVehicle currentVehicleEntity;
|
||||
}
|
||||
597
Scripts/XUIC/XUiC_CrosshairHUDRebirth.cs
Normal file
597
Scripts/XUIC/XUiC_CrosshairHUDRebirth.cs
Normal file
@@ -0,0 +1,597 @@
|
||||
internal class XUiC_CrosshairHUDRebirth : XUiController
|
||||
{
|
||||
private float lastValueStamina = 0.0f;
|
||||
private float lastValueHealth = 0.0f;
|
||||
private float lastValueWater = 0.0f;
|
||||
private float lastValueFood = 0.0f;
|
||||
private float lastValueStealth = 0.0f;
|
||||
private float lastValueRage = 0.0f;
|
||||
private float lastValueStaminaPerc = 0.0f;
|
||||
private float lastValueHealthPerc = 0.0f;
|
||||
private float lastValueWaterPerc = 0.0f;
|
||||
private float lastValueFoodPerc = 0.0f;
|
||||
private float lastValueStealthPerc = 0.0f;
|
||||
private float lastValueRagePerc = 0.0f;
|
||||
private float deltaTime;
|
||||
private EntityPlayerLocal LocalPlayer;
|
||||
private readonly CachedStringFormatterXuiRgbaColor stealthColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatter<float> statfillFormatter = new CachedStringFormatter<float>((Func<float, string>)(_i => _i.ToCultureInvariantString()));
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatter<float, float> statmodifiedmaxFormatter = new CachedStringFormatter<float, float>((Func<float, float, string>)((_f1, _f2) => (_f1 / _f2).ToCultureInvariantString()));
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue START");
|
||||
bool bHide = flUpdateTime < 80;
|
||||
|
||||
if (flUpdateTime < 80)
|
||||
{
|
||||
flUpdateTime = flUpdateTime + .1f;
|
||||
}
|
||||
|
||||
bool optionCrosshairHUD = false;
|
||||
|
||||
float flShowCrossHairHUDRageLevel = 0;
|
||||
float flShowCrossHairHUDRageCounter = 0;
|
||||
float flShowCrossHairHUDRageCounterMax = 0;
|
||||
bool bShowCrossHairHUDDefensiveRage = false;
|
||||
bool bShowCrossHairHUDOffensiveRage = false;
|
||||
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
optionCrosshairHUD = RebirthVariables.customCrosshairHUD;
|
||||
|
||||
flShowCrossHairHUDRageLevel = RebirthUtilities.GetPerkLevel(this.LocalPlayer, "furiousramsayattberserker");
|
||||
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue flShowCrossHairHUDRageLevel: " + flShowCrossHairHUDRageLevel);
|
||||
|
||||
switch (flShowCrossHairHUDRageLevel)
|
||||
{
|
||||
case 1:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier1");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier1");
|
||||
break;
|
||||
case 2:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier2");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier2");
|
||||
break;
|
||||
case 3:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier3");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier3");
|
||||
break;
|
||||
case 4:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier4");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier4");
|
||||
break;
|
||||
case 5:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier5");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier5");
|
||||
break;
|
||||
case 6:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier6");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier6");
|
||||
break;
|
||||
case 7:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier7");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier7");
|
||||
break;
|
||||
case 8:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier8");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier8");
|
||||
break;
|
||||
case 9:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier9");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier9");
|
||||
break;
|
||||
case 10:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier10");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier10");
|
||||
break;
|
||||
case 11:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier11");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier11");
|
||||
break;
|
||||
case 12:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier12");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier12");
|
||||
break;
|
||||
case 13:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier13");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier13");
|
||||
break;
|
||||
case 14:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier14");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier14");
|
||||
break;
|
||||
case 15:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier15");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier15");
|
||||
break;
|
||||
default:
|
||||
bShowCrossHairHUDDefensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRageBuffTier1");
|
||||
bShowCrossHairHUDOffensiveRage = this.LocalPlayer.Buffs.HasBuff("FuriousRamsayOffensiveRageBuffTier1");
|
||||
break;
|
||||
}
|
||||
|
||||
/*//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue bShowCrossHairHUDDefensiveRage: " + bShowCrossHairHUDDefensiveRage);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue bShowCrossHairHUDOffensiveRage: " + bShowCrossHairHUDOffensiveRage);*/
|
||||
|
||||
if (bShowCrossHairHUDDefensiveRage)
|
||||
{
|
||||
flShowCrossHairHUDRageCounterMax = this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayRageDisplayMax"); ;
|
||||
flShowCrossHairHUDRageCounter = this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayRageDisplay") / flShowCrossHairHUDRageCounterMax;
|
||||
}
|
||||
else if (bShowCrossHairHUDOffensiveRage)
|
||||
{
|
||||
flShowCrossHairHUDRageCounterMax = this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayOffensiveRageMax");
|
||||
flShowCrossHairHUDRageCounter = this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayOffensiveRage") / flShowCrossHairHUDRageCounterMax;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue $varFuriousRamsayRageDisplay: " + this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayRageDisplay"));
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue flShowCrossHairHUDRageCounterMax: " + flShowCrossHairHUDRageCounterMax);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue flShowCrossHairHUDRageCounter: " + flShowCrossHairHUDRageCounter);
|
||||
}
|
||||
|
||||
/* //Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 0 flShowCrossHairHUDHealth: " + flShowCrossHairHUDHealth);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 0 flShowCrossHairHUDStamina: " + flShowCrossHairHUDStamina);
|
||||
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 0 bindingName: " + bindingName);*/
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "statEncumbranceVisible":
|
||||
value = "false";
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
if (this.LocalPlayer.Buffs.HasBuff("buffEncumberedInv"))
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "statEncumbrancePos":
|
||||
value = "-365";
|
||||
if (RebirthVariables.musicMode == 1 && RebirthVariables.songIndex > -1)
|
||||
{
|
||||
value = "-343";
|
||||
}
|
||||
return true;
|
||||
case "statRageFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this.lastValueRage <= 0)
|
||||
{
|
||||
value = "0";
|
||||
lastValueRagePerc = 0;
|
||||
if (flShowCrossHairHUDRageCounter > 0)
|
||||
{
|
||||
this.lastValueRage = Mathf.Lerp(this.lastValueRage, flShowCrossHairHUDRageCounter, this.deltaTime * 3f);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue A lastValueRage: " + lastValueRage);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueRage, 0.0f) * 1.01f);
|
||||
lastValueRagePerc = (float)(Math.Truncate(this.lastValueRage * 100 * 100) / 100);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue value: " + value);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue B lastValueRagePerc: " + lastValueRagePerc);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue BEFORE this.lastValueRage: " + this.lastValueRage);
|
||||
this.lastValueRage = Mathf.Lerp(this.lastValueRage, flShowCrossHairHUDRageCounter, this.deltaTime * 3f);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue AFTER this.lastValueRage: " + this.lastValueRage);
|
||||
}
|
||||
|
||||
return true;
|
||||
case "statRageVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.LocalPlayer.AimingGun)
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bShowCrossHairHUDDefensiveRage)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "statOffensiveRageVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.LocalPlayer.AimingGun)
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bShowCrossHairHUDOffensiveRage)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "statRagePerc":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
//Log.Out("lastValueRagePerc: " + lastValueRagePerc);
|
||||
int percentRage = (int)lastValueRagePerc;// this.LocalPlayer.Stats.Rage.ValuePercentUI*100;
|
||||
|
||||
value = percentRage.ToString() + "%";
|
||||
//Log.Out("lastValueRagePerc: " + lastValueRagePerc);
|
||||
return true;
|
||||
case "statStealthFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueStealth, 0.0f) * 1.01f);
|
||||
lastValueStealthPerc = this.lastValueStealth * 100;
|
||||
this.lastValueStealth = Mathf.Lerp(this.lastValueStealth, this.LocalPlayer.Stealth.ValuePercentUI, this.deltaTime * 3f);
|
||||
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 3 statStealthFill: " + value);
|
||||
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 3 statStealthFill: " + value);
|
||||
return true;
|
||||
case "statStealthVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statStealthVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a flShowCrossHairHUDStealthThreshold: " + flShowCrossHairHUDStealthThreshold);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a this.LocalPlayer.Stats.Stealth.ValuePercentUI: " + this.LocalPlayer.Stats.Stealth.ValuePercentUI);
|
||||
if (this.LocalPlayer.IsCrouching)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue IsCrouching");
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue Not Crouching");
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5b statStaminaVisible: " + value);
|
||||
return true;
|
||||
case "statStealthPerc":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
int percentStealth = (int)lastValueStealthPerc;// this.LocalPlayer.Stats.Stealth.ValuePercentUI*100;
|
||||
value = percentStealth.ToString() + "%";
|
||||
return true;
|
||||
case "playerStaminaModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Stamina.ModifiedMax / this.LocalPlayer.Stats.Stamina.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 1 playerStaminaModifiedMax: " + value);
|
||||
return true;
|
||||
case "statStamina":
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 2");
|
||||
value = (this.LocalPlayer == null) ? "0" : this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Stamina.ModifiedMax, this.LocalPlayer.Stats.Stamina.Max);
|
||||
return true;
|
||||
case "statStaminaFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueStamina, 0.0f) * 1.01f);
|
||||
lastValueStaminaPerc = this.lastValueStamina * 100;
|
||||
this.lastValueStamina = Mathf.Lerp(this.lastValueStamina, this.LocalPlayer.Stats.Stamina.ValuePercentUI, this.deltaTime * 3f);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 3 statStaminaFill: " + value);
|
||||
return true;
|
||||
case "statStaminaPerc":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
int percentStamina = (int)lastValueStaminaPerc;// this.LocalPlayer.Stats.Stamina.ValuePercentUI*100;
|
||||
value = percentStamina.ToString() + "%";
|
||||
return true;
|
||||
case "statStaminaVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statStaminaVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
if (this.LocalPlayer.AimingGun)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a this.LocalPlayer.AimingGun: " + this.LocalPlayer.AimingGun);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a this.LocalPlayer.weaponCamera.enabled: " + this.LocalPlayer.weaponCamera.enabled);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!optionCrosshairHUD)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
/*//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a flShowCrossHairHUDStaminaThreshold: " + flShowCrossHairHUDStaminaThreshold);
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a this.LocalPlayer.Stats.Stamina.ValuePercentUI: " + this.LocalPlayer.Stats.Stamina.ValuePercentUI);*/
|
||||
if (RebirthVariables.localConstants["$varFuriousRamsayCrossHairHUDStaminaThreshold_Cst"] >= lastValueStaminaPerc / 100) //this.LocalPlayer.Stats.Stamina.ValuePercentUI)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5b statStaminaVisible: " + value);
|
||||
return true;
|
||||
case "playerHealthModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Health.ModifiedMax / this.LocalPlayer.Stats.Health.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 1 playerHealthModifiedMax: " + value);
|
||||
return true;
|
||||
case "statHealth":
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 2");
|
||||
value = (this.LocalPlayer == null) ? "0" : this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Health.ModifiedMax, this.LocalPlayer.Stats.Stamina.Max);
|
||||
return true;
|
||||
case "statHealthFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueHealth, 0.0f) * 1.01f);
|
||||
this.lastValueHealth = Mathf.Lerp(this.lastValueHealth, this.LocalPlayer.Stats.Health.ValuePercentUI, this.deltaTime * 3f);
|
||||
lastValueHealthPerc = this.lastValueHealth * 100;
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 3 statHealthFill: " + value);
|
||||
return true;
|
||||
case "statHealthPerc":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
int percentHealth = (int)lastValueHealthPerc;// this.LocalPlayer.Stats.Health.ValuePercentUI * 100;
|
||||
value = percentHealth.ToString() + "%";
|
||||
return true;
|
||||
case "statHealthVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statHealthVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
if (this.LocalPlayer.AimingGun)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statWaterVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!optionCrosshairHUD)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.localConstants["$varFuriousRamsayCrossHairHUDHealthThreshold_Cst"] >= lastValueHealthPerc / 100) //this.LocalPlayer.Stats.Health.ValuePercentUI)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5b statHealthVisible: " + value);
|
||||
return true;
|
||||
case "playerWaterModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Water.ModifiedMax / this.LocalPlayer.Stats.Water.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 1 playerWaterModifiedMax: " + value);
|
||||
return true;
|
||||
case "statWater":
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 2");
|
||||
value = (this.LocalPlayer == null) ? "0" : this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Water.ModifiedMax, this.LocalPlayer.Stats.Water.Max);
|
||||
return true;
|
||||
case "statWaterFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueWater, 0.0f) * 1.01f);
|
||||
this.lastValueWater = Mathf.Lerp(this.lastValueWater, this.LocalPlayer.Stats.Water.ValuePercentUI, this.deltaTime * 3f);
|
||||
lastValueWaterPerc = this.lastValueWater * 100;
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 3 statWaterFill: " + value);
|
||||
return true;
|
||||
case "statWaterPerc":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
int percentWater = (int)lastValueWaterPerc;// this.LocalPlayer.Stats.Water.ValuePercentUI * 100;
|
||||
value = percentWater.ToString() + "%";
|
||||
return true;
|
||||
case "statWaterVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statWaterVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
if (this.LocalPlayer.AimingGun)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statWaterVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!optionCrosshairHUD)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.localConstants["$varFuriousRamsayCrossHairHUDWaterThreshold_Cst"] >= lastValueWaterPerc / 100) //this.LocalPlayer.Stats.Water.ValuePercentUI)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5b statWaterVisible: " + value);
|
||||
return true;
|
||||
case "playerFoodModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Food.ModifiedMax / this.LocalPlayer.Stats.Food.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 1 playerFoodModifiedMax: " + value);
|
||||
return true;
|
||||
case "statFood":
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 2");
|
||||
value = (this.LocalPlayer == null) ? "0" : this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Food.ModifiedMax, this.LocalPlayer.Stats.Food.Max);
|
||||
return true;
|
||||
case "statFoodFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueFood, 0.0f) * 1.01f);
|
||||
this.lastValueFood = Mathf.Lerp(this.lastValueFood, this.LocalPlayer.Stats.Food.ValuePercentUI, this.deltaTime * 3f);
|
||||
lastValueFoodPerc = this.lastValueFood * 100;
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 3 statFoodFill: " + value);
|
||||
return true;
|
||||
case "statFoodPerc":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
int percentFood = (int)lastValueFoodPerc;// this.LocalPlayer.Stats.Food.ValuePercentUI * 100;
|
||||
value = percentFood.ToString() + "%";
|
||||
return true;
|
||||
case "statFoodVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || bHide)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statFoodVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
if (this.LocalPlayer.AimingGun)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5a statWaterVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!optionCrosshairHUD)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RebirthVariables.localConstants["$varFuriousRamsayCrossHairHUDFoodThreshold_Cst"] >= lastValueFoodPerc / 100) //this.LocalPlayer.Stats.Food.ValuePercentUI)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 5b statFoodVisible: " + value);
|
||||
return true;
|
||||
default:
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-GetBindingValue 12");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-OnOpen START");
|
||||
base.OnOpen();
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-OnOpen 1");
|
||||
this.LocalPlayer = this.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-Update START");
|
||||
base.Update(_dt);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_CrosshairHUDRebirth-Update 1");
|
||||
return;
|
||||
}
|
||||
this.deltaTime = _dt;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
protected float flUpdateTime;
|
||||
}
|
||||
118
Scripts/XUIC/XUiC_CustomSubPopupList.cs
Normal file
118
Scripts/XUIC/XUiC_CustomSubPopupList.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
#nullable disable
|
||||
[Preserve]
|
||||
public class XUiC_MapSubPopupListRebirth : XUiController
|
||||
{
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
public static string[] sprites = new string[63]
|
||||
{
|
||||
"ui_game_symbol_water",
|
||||
"ui_game_symbol_tree",
|
||||
"ui_game_symbol_add",
|
||||
"ui_game_symbol_airdrop",
|
||||
"ui_game_symbol_allies",
|
||||
"ui_game_symbol_animal_tracker",
|
||||
"ui_game_symbol_archery",
|
||||
"ui_game_symbol_armor_iron",
|
||||
"ui_game_symbol_assemble",
|
||||
"ui_game_symbol_backpack",
|
||||
"ui_game_symbol_book",
|
||||
"ui_game_symbol_brick",
|
||||
"ui_game_symbol_bundle",
|
||||
"ui_game_symbol_cement",
|
||||
"ui_game_symbol_character",
|
||||
"ui_game_symbol_check",
|
||||
"ui_game_symbol_chemistry",
|
||||
"ui_game_symbol_coin",
|
||||
"ui_game_symbol_crops",
|
||||
"ui_game_symbol_diamond",
|
||||
"ui_game_symbol_door",
|
||||
"ui_game_symbol_drive",
|
||||
"ui_game_symbol_electric_power",
|
||||
"ui_game_symbol_electric_turret",
|
||||
"ui_game_symbol_fetch_loot",
|
||||
"ui_game_symbol_fire",
|
||||
"ui_game_symbol_flood_fill",
|
||||
"ui_game_symbol_foliage",
|
||||
"ui_game_symbol_fork",
|
||||
"ui_game_symbol_gas",
|
||||
"ui_game_symbol_hammer",
|
||||
"ui_game_symbol_harvest",
|
||||
"ui_game_symbol_lightbulb",
|
||||
"ui_game_symbol_lock",
|
||||
"ui_game_symbol_loot_sack",
|
||||
"ui_game_symbol_map",
|
||||
"ui_game_symbol_map_bed",
|
||||
"ui_game_symbol_map_cabin",
|
||||
"ui_game_symbol_map_campsite",
|
||||
"ui_game_symbol_map_cave",
|
||||
"ui_game_symbol_map_city",
|
||||
"ui_game_symbol_map_civil",
|
||||
"ui_game_symbol_map_fortress",
|
||||
"ui_game_symbol_map_house",
|
||||
"ui_game_symbol_map_trader",
|
||||
"ui_game_symbol_medical",
|
||||
"ui_game_symbol_mining",
|
||||
"ui_game_symbol_pills",
|
||||
"ui_game_symbol_player",
|
||||
"ui_game_symbol_quest",
|
||||
"ui_game_symbol_radiation",
|
||||
"ui_game_symbol_rifle",
|
||||
"ui_game_symbol_safe",
|
||||
"ui_game_symbol_science",
|
||||
"ui_game_symbol_scrap",
|
||||
"ui_game_symbol_shopping_cart",
|
||||
"ui_game_symbol_star",
|
||||
"ui_game_symbol_table_saw",
|
||||
"ui_game_symbol_tool",
|
||||
"ui_game_symbol_treasure",
|
||||
"ui_game_symbol_wood",
|
||||
"ui_game_symbol_workbench",
|
||||
"ui_game_symbol_x"
|
||||
};
|
||||
|
||||
public int CustomRows { get; set; } = RebirthVariables.waypointIconRows; // Default rows
|
||||
public int CustomColumns { get; set; } = RebirthVariables.waypointIconColumns; // Default columns
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
// Retrieve the grid by its ID
|
||||
var gridController = GetChildById("subPopupList");
|
||||
if (gridController?.ViewComponent is XUiV_Grid grid)
|
||||
{
|
||||
grid.Rows = CustomRows;
|
||||
grid.Columns = CustomColumns;
|
||||
}
|
||||
|
||||
for (int index = 0; index < this.children.Count; ++index)
|
||||
{
|
||||
XUiController child = this.children[index].Children[0];
|
||||
if (child is XUiC_MapSubPopupEntry)
|
||||
{
|
||||
XUiC_MapSubPopupEntry mapSubPopupEntry = (XUiC_MapSubPopupEntry)child;
|
||||
mapSubPopupEntry.SetIndex(index);
|
||||
mapSubPopupEntry.SetSpriteName(XUiC_MapSubPopupListRebirth.sprites[index % XUiC_MapSubPopupListRebirth.sprites.Length]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Internal)]
|
||||
public void ResetList()
|
||||
{
|
||||
for (int index = 0; index < this.children.Count; ++index)
|
||||
{
|
||||
XUiController child = this.children[index].Children[0];
|
||||
if (child is XUiC_MapSubPopupEntry)
|
||||
((XUiC_MapSubPopupEntry)child).Reset();
|
||||
}
|
||||
this.children[0].SelectCursorElement(true);
|
||||
}
|
||||
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
static XUiC_MapSubPopupListRebirth()
|
||||
{
|
||||
}
|
||||
}
|
||||
735
Scripts/XUIC/XUiC_HUDStatBarRebirth.cs
Normal file
735
Scripts/XUIC/XUiC_HUDStatBarRebirth.cs
Normal file
@@ -0,0 +1,735 @@
|
||||
using Quartz.Settings;
|
||||
using System.Linq.Expressions;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_HUDStatBarRebirth : XUiController
|
||||
{
|
||||
private bool miniMapOn = false;
|
||||
private float lastValue;
|
||||
private bool flipped;
|
||||
private HUDStatGroups statGroup;
|
||||
private HUDStatTypes statType;
|
||||
private string statImage = "";
|
||||
private string statIcon = "";
|
||||
private string statAtlas = "UIAtlas";
|
||||
private XUiV_Sprite barContent;
|
||||
private XUiV_Label textContent;
|
||||
private DateTime updateTime;
|
||||
private float deltaTime;
|
||||
private bool wasCrouching;
|
||||
private int currentSlotIndex = -1;
|
||||
private string lastAmmoName = "";
|
||||
private int currentAmmoCount;
|
||||
private ItemValue activeAmmoItemValue;
|
||||
private ItemActionAttack attackAction;
|
||||
private ItemClass itemClass;
|
||||
private float oldValue;
|
||||
private readonly CachedStringFormatterInt statcurrentFormatterInt = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterFloat statcurrentFormatterFloat = new CachedStringFormatterFloat();
|
||||
private readonly CachedStringFormatterInt currentPaintAmmoFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatter<int> statcurrentWMaxFormatterOf100 = new CachedStringFormatter<int>((Func<int, string>)(_i => _i.ToString() + "/100"));
|
||||
private readonly CachedStringFormatter<int> statcurrentWMaxFormatterPercent = new CachedStringFormatter<int>((Func<int, string>)(_i => _i.ToString() + "%"));
|
||||
private readonly CachedStringFormatter<float, float> statmodifiedmaxFormatter = new CachedStringFormatter<float, float>((Func<float, float, string>)((_f1, _f2) => (_f1 / _f2).ToCultureInvariantString()));
|
||||
private readonly CachedStringFormatter<float> statregenrateFormatter = new CachedStringFormatter<float>((Func<float, string>)(_f => ((double)_f >= 0.0 ? "+" : "") + _f.ToCultureInvariantString("0.00")));
|
||||
private readonly CachedStringFormatterFloat statfillFormatter = new CachedStringFormatterFloat();
|
||||
private readonly CachedStringFormatterXuiRgbaColor staticoncolorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatterXuiRgbaColor stealthColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private float lastRegenAmount;
|
||||
|
||||
public HUDStatGroups StatGroup
|
||||
{
|
||||
get => this.statGroup;
|
||||
set => this.statGroup = value;
|
||||
}
|
||||
|
||||
public HUDStatTypes StatType
|
||||
{
|
||||
get => this.statType;
|
||||
set
|
||||
{
|
||||
this.statType = value;
|
||||
this.SetStatValues();
|
||||
}
|
||||
}
|
||||
|
||||
public EntityPlayer LocalPlayer { get; internal set; }
|
||||
|
||||
public EntityVehicle Vehicle { get; internal set; }
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.IsDirty = true;
|
||||
XUiController childById1 = this.GetChildById("BarContent");
|
||||
if (childById1 != null)
|
||||
this.barContent = (XUiV_Sprite)childById1.ViewComponent;
|
||||
XUiController childById2 = this.GetChildById("TextContent");
|
||||
if (childById2 != null)
|
||||
this.textContent = (XUiV_Label)childById2.ViewComponent;
|
||||
this.activeAmmoItemValue = ItemValue.None.Clone();
|
||||
if (MinimapSettings.Enabled)
|
||||
{
|
||||
miniMapOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
this.deltaTime = _dt;
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
this.LocalPlayer = (EntityPlayer)this.xui.playerUI.entityPlayer;
|
||||
GUIWindowManager windowManager = this.xui.playerUI.windowManager;
|
||||
if (windowManager.IsFullHUDDisabled())
|
||||
this.viewComponent.IsVisible = false;
|
||||
else if (!this.xui.dragAndDrop.InMenu && windowManager.IsHUDPartialHidden())
|
||||
{
|
||||
this.viewComponent.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.statGroup == HUDStatGroups.Vehicle && this.LocalPlayer != null)
|
||||
{
|
||||
if (this.Vehicle == null && this.LocalPlayer.AttachedToEntity != null && this.LocalPlayer.AttachedToEntity is EntityVehicle)
|
||||
{
|
||||
this.Vehicle = (EntityVehicle)this.LocalPlayer.AttachedToEntity;
|
||||
this.IsDirty = true;
|
||||
this.xui.CollectedItemList.SetYOffset(100);
|
||||
}
|
||||
else if (this.Vehicle != null && this.LocalPlayer.AttachedToEntity == null)
|
||||
{
|
||||
this.Vehicle = (EntityVehicle)null;
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
if (this.statType == HUDStatTypes.Stealth && this.LocalPlayer.IsCrouching != this.wasCrouching)
|
||||
{
|
||||
this.wasCrouching = this.LocalPlayer.IsCrouching;
|
||||
this.RefreshBindings(true);
|
||||
this.IsDirty = true;
|
||||
}
|
||||
if (this.statType == HUDStatTypes.ActiveItem)
|
||||
{
|
||||
if (this.currentSlotIndex != this.xui.PlayerInventory.Toolbelt.GetFocusedItemIdx())
|
||||
{
|
||||
this.currentSlotIndex = this.xui.PlayerInventory.Toolbelt.GetFocusedItemIdx();
|
||||
this.IsDirty = true;
|
||||
}
|
||||
this.SetupActiveItemEntry();
|
||||
this.updateActiveItemAmmo();
|
||||
this.RefreshBindings(true);
|
||||
this.IsDirty = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RefreshFill();
|
||||
if (!this.HasChanged() && !this.IsDirty)
|
||||
return;
|
||||
if (this.IsDirty)
|
||||
this.IsDirty = false;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasChanged()
|
||||
{
|
||||
bool flag = false;
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
flag = true;
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
flag = true;
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
flag = (double)this.oldValue != (double)this.LocalPlayer.Stats.Water.ValuePercentUI;
|
||||
this.oldValue = this.LocalPlayer.Stats.Water.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
flag = (double)this.oldValue != (double)this.LocalPlayer.Stats.Food.ValuePercentUI;
|
||||
this.oldValue = this.LocalPlayer.Stats.Food.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Stealth:
|
||||
flag = (double)this.oldValue != (double)this.lastValue;
|
||||
this.oldValue = this.lastValue;
|
||||
break;
|
||||
case HUDStatTypes.ActiveItem:
|
||||
ItemAction action = this.LocalPlayer.inventory.holdingItemItemValue.ItemClass.Actions[0];
|
||||
if (action != null && action.IsEditingTool())
|
||||
{
|
||||
flag = action.IsStatChanged();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case HUDStatTypes.VehicleHealth:
|
||||
if (this.Vehicle == null)
|
||||
return false;
|
||||
int health = this.Vehicle.GetVehicle().GetHealth();
|
||||
flag = true;
|
||||
this.oldValue = (float)health;
|
||||
break;
|
||||
case HUDStatTypes.VehicleFuel:
|
||||
if (this.Vehicle == null)
|
||||
return false;
|
||||
flag = (double)this.oldValue != (double)this.Vehicle.GetVehicle().GetFuelLevel();
|
||||
this.oldValue = this.Vehicle.GetVehicle().GetFuelLevel();
|
||||
break;
|
||||
case HUDStatTypes.VehicleBattery:
|
||||
if (this.Vehicle == null)
|
||||
return false;
|
||||
flag = (double)this.oldValue != (double)this.Vehicle.GetVehicle().GetBatteryLevel();
|
||||
this.oldValue = this.Vehicle.GetVehicle().GetBatteryLevel();
|
||||
break;
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void RefreshFill()
|
||||
{
|
||||
if (this.barContent == null || this.LocalPlayer == null || this.statGroup == HUDStatGroups.Vehicle && this.Vehicle == null)
|
||||
return;
|
||||
float t = Time.deltaTime * 3f;
|
||||
float b = 0.0f;
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
b = Mathf.Clamp01(this.LocalPlayer.Stats.Health.ValuePercentUI);
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
b = Mathf.Clamp01(this.LocalPlayer.Stats.Stamina.ValuePercentUI);
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
b = this.LocalPlayer.Stats.Water.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
b = this.LocalPlayer.Stats.Food.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Stealth:
|
||||
b = this.LocalPlayer.Stealth.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.ActiveItem:
|
||||
b = (float)this.LocalPlayer.inventory.holdingItemItemValue.Meta / EffectManager.GetValue(PassiveEffects.MagazineSize, this.LocalPlayer.inventory.holdingItemItemValue, (float)this.attackAction.BulletsPerMagazine, (EntityAlive)this.LocalPlayer);
|
||||
break;
|
||||
case HUDStatTypes.VehicleHealth:
|
||||
b = this.Vehicle.GetVehicle().GetHealthPercent();
|
||||
break;
|
||||
case HUDStatTypes.VehicleFuel:
|
||||
b = this.Vehicle.GetVehicle().GetFuelPercent();
|
||||
break;
|
||||
case HUDStatTypes.VehicleBattery:
|
||||
b = this.Vehicle.GetVehicle().GetBatteryLevel();
|
||||
break;
|
||||
}
|
||||
float num = Math.Max(this.lastValue, 0.0f);
|
||||
this.lastValue = Mathf.Lerp(this.lastValue, b, t);
|
||||
this.barContent.Fill = num;
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
switch (bindingName)
|
||||
{
|
||||
case "statcurrent":
|
||||
if (this.LocalPlayer == null || this.statGroup == HUDStatGroups.Vehicle && this.Vehicle == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
value = this.statcurrentFormatterInt.Format(this.LocalPlayer.Health);
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
value = this.statcurrentFormatterFloat.Format(this.LocalPlayer.Stamina);
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
value = this.statcurrentFormatterInt.Format((int)((double)this.LocalPlayer.Stats.Water.ValuePercentUI * 100.0));
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
value = this.statcurrentFormatterInt.Format((int)((double)this.LocalPlayer.Stats.Food.ValuePercentUI * 100.0));
|
||||
break;
|
||||
case HUDStatTypes.Stealth:
|
||||
value = this.statcurrentFormatterFloat.Format((float)(int)((double)this.LocalPlayer.Stealth.ValuePercentUI * 100.0));
|
||||
break;
|
||||
case HUDStatTypes.ActiveItem:
|
||||
value = !(this.attackAction is ItemActionTextureBlock) ? this.statcurrentFormatterInt.Format(this.LocalPlayer.inventory.holdingItemItemValue.Meta) : this.currentPaintAmmoFormatter.Format(this.currentAmmoCount);
|
||||
break;
|
||||
case HUDStatTypes.VehicleHealth:
|
||||
value = this.statcurrentFormatterInt.Format(this.Vehicle.GetVehicle().GetHealth());
|
||||
break;
|
||||
case HUDStatTypes.VehicleFuel:
|
||||
value = this.statcurrentFormatterFloat.Format(this.Vehicle.GetVehicle().GetFuelLevel());
|
||||
break;
|
||||
case HUDStatTypes.VehicleBattery:
|
||||
value = this.statcurrentFormatterFloat.Format(this.Vehicle.GetVehicle().GetBatteryLevel());
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
case "statcurrentwithmax":
|
||||
if (this.LocalPlayer == null || this.statGroup == HUDStatGroups.Vehicle && this.Vehicle == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
value = this.statcurrentWMaxFormatterAOfB.Format((int)this.LocalPlayer.Stats.Health.Value, (int)this.LocalPlayer.Stats.Health.Max);
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
value = this.statcurrentWMaxFormatterAOfB.Format((int)XUiM_Player.GetStamina(this.LocalPlayer), (int)this.LocalPlayer.Stats.Stamina.Max);
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
value = this.statcurrentWMaxFormatterAOfB.Format((int)this.LocalPlayer.Stats.Water.Value, (int)this.LocalPlayer.Stats.Water.Max);
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
value = this.statcurrentWMaxFormatterAOfB.Format((int)this.LocalPlayer.Stats.Food.Value, (int)this.LocalPlayer.Stats.Food.Max);
|
||||
break;
|
||||
case HUDStatTypes.Stealth:
|
||||
value = this.statcurrentWMaxFormatterOf100.Format((int)((double)this.LocalPlayer.Stealth.ValuePercentUI * 100.0));
|
||||
break;
|
||||
case HUDStatTypes.ActiveItem:
|
||||
if (this.attackAction is ItemActionTextureBlock)
|
||||
{
|
||||
value = this.currentPaintAmmoFormatter.Format(this.currentAmmoCount);
|
||||
break;
|
||||
}
|
||||
if (this.attackAction != null && this.attackAction.IsEditingTool())
|
||||
{
|
||||
ItemActionData actionDataInSlot = this.LocalPlayer.inventory.GetItemActionDataInSlot(this.currentSlotIndex, 1);
|
||||
value = this.attackAction.GetStat(actionDataInSlot);
|
||||
break;
|
||||
}
|
||||
value = this.statcurrentWMaxFormatterAOfB.Format(this.LocalPlayer.inventory.GetItem(this.currentSlotIndex).itemValue.Meta, this.currentAmmoCount);
|
||||
break;
|
||||
case HUDStatTypes.VehicleHealth:
|
||||
value = this.statcurrentWMaxFormatterPercent.Format((int)((double)this.Vehicle.GetVehicle().GetHealthPercent() * 100.0));
|
||||
break;
|
||||
case HUDStatTypes.VehicleFuel:
|
||||
value = this.statcurrentWMaxFormatterPercent.Format((int)((double)this.Vehicle.GetVehicle().GetFuelPercent() * 100.0));
|
||||
break;
|
||||
case HUDStatTypes.VehicleBattery:
|
||||
value = this.statcurrentWMaxFormatterPercent.Format((int)((double)this.Vehicle.GetVehicle().GetBatteryLevel() * 100.0));
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
case "statfill":
|
||||
if (this.LocalPlayer == null || this.statGroup == HUDStatGroups.Vehicle && this.Vehicle == null)
|
||||
{
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
float t = this.deltaTime * 3f;
|
||||
float b = 0.0f;
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
b = this.LocalPlayer.Stats.Health.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
b = this.LocalPlayer.Stats.Stamina.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
b = this.LocalPlayer.Stats.Water.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
b = this.LocalPlayer.Stats.Food.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.Stealth:
|
||||
b = this.LocalPlayer.Stealth.ValuePercentUI;
|
||||
break;
|
||||
case HUDStatTypes.ActiveItem:
|
||||
b = (float)this.LocalPlayer.inventory.holdingItemItemValue.Meta / EffectManager.GetValue(PassiveEffects.MagazineSize, this.LocalPlayer.inventory.holdingItemItemValue, (float)this.attackAction.BulletsPerMagazine, (EntityAlive)this.LocalPlayer);
|
||||
break;
|
||||
case HUDStatTypes.VehicleHealth:
|
||||
b = this.Vehicle.GetVehicle().GetHealthPercent();
|
||||
break;
|
||||
case HUDStatTypes.VehicleFuel:
|
||||
b = this.Vehicle.GetVehicle().GetFuelPercent();
|
||||
break;
|
||||
case HUDStatTypes.VehicleBattery:
|
||||
b = this.Vehicle.GetVehicle().GetBatteryLevel();
|
||||
break;
|
||||
}
|
||||
float _v1_1 = Math.Max(this.lastValue, 0.0f) * 1.01f;
|
||||
value = this.statfillFormatter.Format(_v1_1);
|
||||
this.lastValue = Mathf.Lerp(this.lastValue, b, t);
|
||||
return true;
|
||||
case "staticon":
|
||||
value = this.statType != HUDStatTypes.ActiveItem ? (this.statType != HUDStatTypes.VehicleHealth ? this.statIcon : (this.Vehicle != null ? this.Vehicle.GetMapIcon() : "")) : (this.itemClass != null ? this.itemClass.GetIconName() : "");
|
||||
//Log.Out("HUDStatBarRebirth-Update value: " + value);
|
||||
return true;
|
||||
case "staticonatlas":
|
||||
value = this.statAtlas;
|
||||
return true;
|
||||
case "staticoncolor":
|
||||
Color32 _v1_2 = (Color32)Color.white;
|
||||
if (this.statType == HUDStatTypes.ActiveItem && this.itemClass != null)
|
||||
_v1_2 = (Color32)(this.itemClass != null ? this.itemClass.GetIconTint() : Color.white);
|
||||
value = this.staticoncolorFormatter.Format(_v1_2);
|
||||
return true;
|
||||
case "statimage":
|
||||
value = this.statImage;
|
||||
return true;
|
||||
case "statmodifiedmax":
|
||||
if (this.LocalPlayer == null || this.statGroup == HUDStatGroups.Vehicle && this.Vehicle == null)
|
||||
{
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
value = this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Health.ModifiedMax, this.LocalPlayer.Stats.Health.Max);
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
value = this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Stamina.ModifiedMax, this.LocalPlayer.Stats.Stamina.Max);
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
value = this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Water.ModifiedMax, this.LocalPlayer.Stats.Water.Max);
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
value = this.statmodifiedmaxFormatter.Format(this.LocalPlayer.Stats.Food.ModifiedMax, this.LocalPlayer.Stats.Food.Max);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
case "statregenrate":
|
||||
if (this.LocalPlayer == null || this.statGroup == HUDStatGroups.Vehicle && this.Vehicle == null)
|
||||
{
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
value = this.statregenrateFormatter.Format(this.LocalPlayer.Stats.Health.RegenerationAmountUI);
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
value = this.statregenrateFormatter.Format(this.LocalPlayer.Stats.Stamina.RegenerationAmountUI);
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
value = this.statregenrateFormatter.Format(this.LocalPlayer.Stats.Water.RegenerationAmountUI);
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
value = this.statregenrateFormatter.Format(this.LocalPlayer.Stats.Food.RegenerationAmountUI);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
case "statvisible":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
value = "true";
|
||||
return true;
|
||||
}
|
||||
value = "true";
|
||||
if (this.LocalPlayer.IsDead())
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
if (this.statGroup == HUDStatGroups.Vehicle)
|
||||
value = this.statType != HUDStatTypes.VehicleFuel ? (this.Vehicle != null).ToString() : (this.Vehicle != null && this.Vehicle.GetVehicle().HasEnginePart()).ToString();
|
||||
else if (this.statType == HUDStatTypes.ActiveItem)
|
||||
value = this.attackAction == null || !this.attackAction.IsEditingTool() && (int)EffectManager.GetValue(PassiveEffects.MagazineSize, this.LocalPlayer.inventory.holdingItemItemValue, _entity: ((EntityAlive)this.LocalPlayer)) <= 0 ? "false" : "true";
|
||||
else if (this.statType == HUDStatTypes.Stealth)
|
||||
{
|
||||
if (this.LocalPlayer.Crouching)
|
||||
{
|
||||
this.xui.BuffPopoutList.SetYOffset(52);
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.xui.BuffPopoutList.SetYOffset(0);
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "stealthcolor":
|
||||
Color32 _v1_3 = Color32.Lerp(new Color32((byte)72, (byte)82, (byte)0, byte.MaxValue), new Color32((byte)187, (byte)199, (byte)0, byte.MaxValue), this.lastValue);
|
||||
value = this.stealthColorFormatter.Format(_v1_3);
|
||||
return true;
|
||||
case "heatMapVisible":
|
||||
value = "false";
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
if (this.LocalPlayer.Buffs.GetCustomVar("$ModHeatMapDetection") == 1f)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "heatMap":
|
||||
value = "0%";
|
||||
|
||||
if (this.LocalPlayer != null && this.LocalPlayer.Buffs.GetCustomVar("$ModHeatMapDetection") == 1f)
|
||||
{
|
||||
float percentage = this.LocalPlayer.Buffs.GetCustomVar("$ModHeatMapDetectionValue");
|
||||
float cooldown = this.LocalPlayer.Buffs.GetCustomVar("$ModHeatMapDetectionCooldown");
|
||||
|
||||
string color = "[ffffff]";
|
||||
|
||||
if (percentage >= 25 && percentage < 50)
|
||||
{
|
||||
color = "[d6c978]";
|
||||
}
|
||||
else if (percentage >= 50 && percentage < 75)
|
||||
{
|
||||
color = "[d99b5d]";
|
||||
}
|
||||
else if (percentage >= 75 && percentage < 100)
|
||||
{
|
||||
color = "[cc6b64]";
|
||||
}
|
||||
else if (percentage >= 100)
|
||||
{
|
||||
color = "[a466d4]";
|
||||
}
|
||||
|
||||
if (percentage > 100)
|
||||
{
|
||||
percentage = 100;
|
||||
}
|
||||
|
||||
if (cooldown > 0)
|
||||
{
|
||||
value = "[85b9c7]" + Localization.Get("xuiCooldown_FR") + "[-]: " + color + RebirthUtilities.ConvertToMinutesSeconds((int)cooldown);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Localization.Get("xuiGeneratedHeat_FR") + ": " + color + percentage.ToString("F2") + "[-]%";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "musicVisible":
|
||||
//Log.Out("musicVisible, RebirthVariables.songIndex: " + RebirthVariables.songIndex);
|
||||
if (RebirthVariables.musicMode == 1 && RebirthVariables.songIndex > -1)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
return true;
|
||||
case "songName":
|
||||
value = "";
|
||||
|
||||
if (RebirthVariables.songIndex > -1)
|
||||
{
|
||||
value = Localization.Get("FuriousRamsayAchievementCassette" + RebirthVariables.songIndex + "Name");
|
||||
}
|
||||
return true;
|
||||
case "volume1Completed":
|
||||
value = "";
|
||||
|
||||
if (this.LocalPlayer != null && this.LocalPlayer.Buffs.GetCustomVar("$volume1_FR") == 1 && this.LocalPlayer.Buffs.GetCustomVar("$walkman_FR") == 1)
|
||||
{
|
||||
value = "ui_game_symbol_SynthVolume1";
|
||||
}
|
||||
return true;
|
||||
case "volume2Completed":
|
||||
value = "";
|
||||
|
||||
if (this.LocalPlayer != null && this.LocalPlayer.Buffs.GetCustomVar("$volume2_FR") == 1 && this.LocalPlayer.Buffs.GetCustomVar("$walkman_FR") == 1)
|
||||
{
|
||||
value = "ui_game_symbol_SynthVolume2";
|
||||
}
|
||||
return true;
|
||||
case "volume3Completed":
|
||||
value = "";
|
||||
|
||||
if (this.LocalPlayer != null && this.LocalPlayer.Buffs.GetCustomVar("$volume3_FR") == 1 && this.LocalPlayer.Buffs.GetCustomVar("$walkman_FR") == 1)
|
||||
{
|
||||
value = "ui_game_symbol_SynthVolume3";
|
||||
}
|
||||
return true;
|
||||
case "vehicleFuel":
|
||||
value = "0,0";
|
||||
|
||||
if (MinimapSettings.Enabled)
|
||||
{
|
||||
value = "0,250";
|
||||
}
|
||||
|
||||
//Log.Out("vehicleFuel: pos: " + value);
|
||||
return true;
|
||||
case "vehicleHealth":
|
||||
value = "0,-50";
|
||||
|
||||
if (MinimapSettings.Enabled)
|
||||
{
|
||||
value = "0,200";
|
||||
}
|
||||
|
||||
//Log.Out("vehicleHealth: pos: " + value);
|
||||
return true;
|
||||
case "activeItem":
|
||||
|
||||
value = "0,0";
|
||||
|
||||
if (MinimapSettings.Enabled)
|
||||
{
|
||||
parent.ViewComponent.Position = new Vector2i(-194, 290);
|
||||
//value = "0,350";
|
||||
}
|
||||
else
|
||||
{
|
||||
parent.ViewComponent.Position = new Vector2i(-194, 55);
|
||||
}
|
||||
|
||||
//Log.Out("activeItem: parent.ViewComponent.Position: " + parent.ViewComponent.Position);
|
||||
//Log.Out("activeItem: ViewComponent.Position: " + ViewComponent.Position);
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseAttribute(string name, string value, XUiController _parent)
|
||||
{
|
||||
bool attribute = base.ParseAttribute(name, value, _parent);
|
||||
if (attribute)
|
||||
return attribute;
|
||||
if (!(name == "stat_type"))
|
||||
return false;
|
||||
this.StatType = EnumUtils.Parse<HUDStatTypes>(value, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetStatValues()
|
||||
{
|
||||
switch (this.statType)
|
||||
{
|
||||
case HUDStatTypes.Health:
|
||||
this.statImage = "ui_game_stat_bar_health";
|
||||
this.statIcon = "ui_game_symbol_add";
|
||||
this.statGroup = HUDStatGroups.Player;
|
||||
break;
|
||||
case HUDStatTypes.Stamina:
|
||||
this.statImage = "ui_game_stat_bar_stamina";
|
||||
this.statIcon = "ui_game_symbol_run";
|
||||
this.statGroup = HUDStatGroups.Player;
|
||||
break;
|
||||
case HUDStatTypes.Water:
|
||||
this.statImage = "ui_game_stat_bar_stamina";
|
||||
this.statIcon = "ui_game_symbol_water";
|
||||
this.statGroup = HUDStatGroups.Player;
|
||||
break;
|
||||
case HUDStatTypes.Food:
|
||||
this.statImage = "ui_game_stat_bar_health";
|
||||
this.statIcon = "ui_game_symbol_hunger";
|
||||
this.statGroup = HUDStatGroups.Player;
|
||||
break;
|
||||
case HUDStatTypes.Stealth:
|
||||
this.statImage = "ui_game_stat_bar_health";
|
||||
this.statIcon = "ui_game_symbol_stealth";
|
||||
this.statGroup = HUDStatGroups.Player;
|
||||
break;
|
||||
case HUDStatTypes.ActiveItem:
|
||||
this.statImage = "ui_game_popup";
|
||||
this.statIcon = "ui_game_symbol_battery";
|
||||
this.statGroup = HUDStatGroups.Player;
|
||||
this.statAtlas = "ItemIconAtlas";
|
||||
break;
|
||||
case HUDStatTypes.VehicleHealth:
|
||||
this.statImage = "ui_game_stat_bar_health";
|
||||
this.statIcon = "ui_game_symbol_minibike";
|
||||
this.statGroup = HUDStatGroups.Vehicle;
|
||||
break;
|
||||
case HUDStatTypes.VehicleFuel:
|
||||
this.statImage = "ui_game_stat_bar_stamina";
|
||||
this.statIcon = "ui_game_symbol_gas";
|
||||
this.statGroup = HUDStatGroups.Vehicle;
|
||||
break;
|
||||
case HUDStatTypes.VehicleBattery:
|
||||
this.statImage = "ui_game_popup";
|
||||
this.statIcon = "ui_game_symbol_battery";
|
||||
this.statGroup = HUDStatGroups.Vehicle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupActiveItemEntry()
|
||||
{
|
||||
this.itemClass = null;
|
||||
this.attackAction = null;
|
||||
this.activeAmmoItemValue = ItemValue.None.Clone();
|
||||
EntityPlayer localPlayer = this.LocalPlayer;
|
||||
if (localPlayer)
|
||||
{
|
||||
Inventory inventory = localPlayer.inventory;
|
||||
ItemValue itemValue = inventory.GetItem(this.currentSlotIndex).itemValue;
|
||||
this.itemClass = itemValue.ItemClass;
|
||||
if (this.itemClass != null)
|
||||
{
|
||||
ItemActionAttack itemActionAttack = this.itemClass.Actions[0] as ItemActionAttack;
|
||||
if (itemActionAttack != null && itemActionAttack.IsEditingTool())
|
||||
{
|
||||
this.attackAction = itemActionAttack;
|
||||
base.xui.CollectedItemList.SetYOffset(46);
|
||||
return;
|
||||
}
|
||||
if (itemActionAttack == null || itemActionAttack is ItemActionMelee || !this.itemClass.IsGun() || (int)EffectManager.GetValue(PassiveEffects.MagazineSize, inventory.holdingItemItemValue, 0f, localPlayer, null, new FastTags<TagGroup.Global>(), true, true, true, true, true, 1, false) <= 0)
|
||||
{
|
||||
this.currentAmmoCount = 0;
|
||||
base.xui.CollectedItemList.SetYOffset((localPlayer.AttachedToEntity is EntityVehicle) ? 100 : 0);
|
||||
return;
|
||||
}
|
||||
this.attackAction = itemActionAttack;
|
||||
if (itemActionAttack.MagazineItemNames != null && itemActionAttack.MagazineItemNames.Length != 0)
|
||||
{
|
||||
this.lastAmmoName = itemActionAttack.MagazineItemNames[(int)itemValue.SelectedAmmoTypeIndex];
|
||||
this.activeAmmoItemValue = ItemClass.GetItem(this.lastAmmoName, false);
|
||||
this.itemClass = ItemClass.GetItemClass(this.lastAmmoName, false);
|
||||
}
|
||||
base.xui.CollectedItemList.SetYOffset(46);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentAmmoCount = 0;
|
||||
base.xui.CollectedItemList.SetYOffset((localPlayer.AttachedToEntity is EntityVehicle) ? 100 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
if (this.statType == HUDStatTypes.ActiveItem)
|
||||
{
|
||||
this.xui.PlayerInventory.OnBackpackItemsChanged += new XUiEvent_BackpackItemsChanged(this.PlayerInventory_OnBackpackItemsChanged);
|
||||
this.xui.PlayerInventory.OnToolbeltItemsChanged += new XUiEvent_ToolbeltItemsChanged(this.PlayerInventory_OnToolbeltItemsChanged);
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
this.xui.PlayerInventory.OnBackpackItemsChanged -= new XUiEvent_BackpackItemsChanged(this.PlayerInventory_OnBackpackItemsChanged);
|
||||
this.xui.PlayerInventory.OnToolbeltItemsChanged -= new XUiEvent_ToolbeltItemsChanged(this.PlayerInventory_OnToolbeltItemsChanged);
|
||||
}
|
||||
|
||||
private void PlayerInventory_OnToolbeltItemsChanged() => this.IsDirty = true;
|
||||
|
||||
private void PlayerInventory_OnBackpackItemsChanged() => this.IsDirty = true;
|
||||
|
||||
private void updateActiveItemAmmo()
|
||||
{
|
||||
if (this.activeAmmoItemValue.type == 0)
|
||||
return;
|
||||
this.currentAmmoCount = this.LocalPlayer.inventory.GetItemCount(this.activeAmmoItemValue);
|
||||
this.currentAmmoCount += this.LocalPlayer.bag.GetItemCount(this.activeAmmoItemValue);
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
426
Scripts/XUIC/XUiC_HiredNPC.cs
Normal file
426
Scripts/XUIC/XUiC_HiredNPC.cs
Normal file
@@ -0,0 +1,426 @@
|
||||
using Audio;
|
||||
using Harmony;
|
||||
using Platform;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UAI;
|
||||
using UnityEngine;
|
||||
using static SleeperVolume;
|
||||
|
||||
public class XUiC_HiredNPC : XUiController
|
||||
{
|
||||
public string name;
|
||||
public int EntityID = -1;
|
||||
private float distance;
|
||||
public Vector3 position;
|
||||
private EntityNPCRebirth hiredNPC { get; set; }
|
||||
|
||||
private readonly CachedStringFormatterXuiRgbaColor itemicontintcolorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
|
||||
private readonly CachedStringFormatter<float> distanceFormatter = new CachedStringFormatter<float>(delegate(float _f)
|
||||
{
|
||||
if (_f > 1000f)
|
||||
{
|
||||
return (_f / 1000f).ToCultureInvariantString("0.0") + " KM";
|
||||
}
|
||||
|
||||
return _f.ToCultureInvariantString("0.0") + " M";
|
||||
});
|
||||
|
||||
private XUiC_SimpleButton btnDismiss;
|
||||
private XUiC_SimpleButton btnTeleport;
|
||||
//private XUiC_SimpleButton btnTeleportTo;
|
||||
private XUiC_SimpleButton btnWaypoint;
|
||||
private XUiC_SimpleButton btnBedroll;
|
||||
|
||||
private float updateLimiter;
|
||||
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
IsDirty = true;
|
||||
|
||||
btnDismiss = (XUiC_SimpleButton)GetChildById("btnDismiss");
|
||||
if (btnDismiss != null)
|
||||
btnDismiss.OnPressed += BtnDismiss_Controller_OnPress;
|
||||
|
||||
btnTeleport = (XUiC_SimpleButton)GetChildById("btnTeleport");
|
||||
if (btnTeleport != null)
|
||||
btnTeleport.OnPressed += BtnTeleport_Controller_OnPress;
|
||||
|
||||
/*btnTeleportTo = (XUiC_SimpleButton)GetChildById("btnTeleportTo");
|
||||
if (btnTeleportTo != null)
|
||||
btnTeleportTo.OnPressed += BtnTeleportTo_Controller_OnPress;*/
|
||||
|
||||
btnWaypoint = (XUiC_SimpleButton)GetChildById("btnWaypoint");
|
||||
if (btnWaypoint != null)
|
||||
btnWaypoint.OnPressed += BtnWaypoint_Controller_OnPress;
|
||||
|
||||
btnBedroll = (XUiC_SimpleButton)GetChildById("btnBedroll");
|
||||
if (btnBedroll != null)
|
||||
btnBedroll.OnPressed += BtnBedroll_Controller_OnPress;
|
||||
}
|
||||
|
||||
private void BtnTeleport_Controller_OnPress(XUiController _sender, int _mousebutton)
|
||||
{
|
||||
if (hiredNPC != null)
|
||||
{
|
||||
hiredNPC.HideNPC(false);
|
||||
hiredNPC.guardPosition = Vector3.zero;
|
||||
hiredNPC.attackTarget = null;
|
||||
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "order", "follow");
|
||||
hiredNPC.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Follow);
|
||||
RebirthUtilities.toggleCollisions(false, hiredNPC);
|
||||
hiredNPC.SetPosition(xui.playerUI.entityPlayer.position);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnWaypoint_Controller_OnPress(XUiController _sender, int _mousebutton)
|
||||
{
|
||||
Waypoint _wp = new Waypoint();
|
||||
_wp.pos = new Vector3i(position.x, position.y, position.z);
|
||||
_wp.icon = "ui_game_symbol_npc";
|
||||
_wp.name.Update(name, PlatformManager.MultiPlatform.User.PlatformUserId);
|
||||
_wp.ownerId = (PlatformUserIdentifierAbs)null;
|
||||
//_wp.entityId = -1;
|
||||
_wp.bIsAutoWaypoint = true;
|
||||
_wp.bUsingLocalizationId = true;
|
||||
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress _wp.name: " + _wp.name);
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress _wp.pos: " + _wp.pos);
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress _wp.icon: " + _wp.icon);
|
||||
|
||||
for (int index = xui.playerUI.entityPlayer.Waypoints.Collection.list.Count - 1; index >= 0; --index)
|
||||
{
|
||||
Waypoint waypoint = xui.playerUI.entityPlayer.Waypoints.Collection.list[index];
|
||||
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress waypoint.name: " + waypoint.name);
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress waypoint.pos: " + waypoint.pos);
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress waypoint.icon: " + waypoint.icon);
|
||||
|
||||
if (xui.playerUI.entityPlayer.Waypoints.ContainsWaypoint((Waypoint)_wp))
|
||||
{
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress 1");
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip((EntityPlayerLocal)xui.playerUI.entityPlayer, Localization.Get("ttWaypointAlreadyExists"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (waypoint.pos == _wp.pos &&
|
||||
waypoint.name == _wp.name
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_HiredNPC-BtnWaypoint_Controller_OnPress 2");
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip((EntityPlayerLocal)xui.playerUI.entityPlayer, Localization.Get("ttWaypointAlreadyExists"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NavObject navObject = NavObjectManager.Instance.RegisterNavObject("waypoint", (Vector3)_wp.pos, _wp.icon, true);
|
||||
navObject.UseOverrideColor = true;
|
||||
navObject.OverrideColor = Color.white;
|
||||
navObject.IsActive = true;
|
||||
navObject.name = _wp.name.Text;
|
||||
navObject.usingLocalizationId = true;
|
||||
_wp.navObject = navObject;
|
||||
|
||||
xui.playerUI.entityPlayer.Waypoints.Collection.Add(_wp);
|
||||
}
|
||||
|
||||
/*private void BtnTeleportTo_Controller_OnPress(XUiController _sender, int _mousebutton)
|
||||
{
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
|
||||
if (isClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageTeleportTo>().Setup(xui.playerUI.entityPlayer.entityId, position), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_HiredNPC-BtnTeleportTo_Controller_OnPress position: " + position);
|
||||
//float height1 = GameManager.Instance.World.GetTerrainHeight((int)position.x, (int)position.z);
|
||||
float height1 = GameManager.Instance.World.GetHeight((int)position.x, (int)position.z);
|
||||
float height2 = GameManager.Instance.World.GetHeight((int)position.x, (int)position.z);
|
||||
|
||||
float height = ((height1 + height2) / 2f) + 1.5f;
|
||||
|
||||
//Log.Out("XUiC_HiredNPC-BtnTeleportTo_Controller_OnPress height1: " + height1);
|
||||
//Log.Out("XUiC_HiredNPC-BtnTeleportTo_Controller_OnPress height2: " + height2);
|
||||
//Log.Out("XUiC_HiredNPC-BtnTeleportTo_Controller_OnPress height: " + height);
|
||||
|
||||
if (height <= position.y)
|
||||
{
|
||||
xui.playerUI.entityPlayer.SetPosition(position);
|
||||
}
|
||||
else
|
||||
{
|
||||
xui.playerUI.entityPlayer.SetPosition(new Vector3(position.x, height, position.x));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
private void BtnDismiss_Controller_OnPress(XUiController _sender, int _mousebutton)
|
||||
{
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(xui.playerUI.entityPlayer);
|
||||
|
||||
if (uiforPlayer != null)
|
||||
{
|
||||
xui.playerUI.entityPlayer.Buffs.SetCustomVar("CurrentNPC", this.EntityID);
|
||||
uiforPlayer.windowManager.Open("DismissEntity", true, false, true);
|
||||
RebirthVariables.NPCName = this.name;
|
||||
}
|
||||
this.ViewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
private void BtnBedroll_Controller_OnPress(XUiController _sender, int _mousebutton)
|
||||
{
|
||||
SpawnPosition spawnPoint = RebirthUtilities.GetSpawnPoint(xui.playerUI.entityPlayer);
|
||||
|
||||
if (!spawnPoint.IsUndef())
|
||||
{
|
||||
bool isClient = SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient;
|
||||
|
||||
if (isClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageMoveToBedroll>().Setup(EntityID, spawnPoint.position), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hiredNPC != null)
|
||||
{
|
||||
hiredNPC.HideNPC(false);
|
||||
hiredNPC.guardPosition = Vector3.zero;
|
||||
hiredNPC.attackTarget = null;
|
||||
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "order", "stay", spawnPoint.position.ToString(), new Vector3(0, hiredNPC.rotation.y, 0).ToString());
|
||||
hiredNPC.Buffs.SetCustomVar("CurrentOrder", (int)EntityUtilities.Orders.Stay);
|
||||
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "reSpawnPosition", "", Vector3.zero.ToString(), new Vector3(0, hiredNPC.rotation.y, 0).ToString());
|
||||
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "spawnPosition", "", spawnPoint.position.ToString(), new Vector3(0, hiredNPC.rotation.y, 0).ToString());
|
||||
RebirthManager.UpdateHireInfo(hiredNPC.entityId, "order", "guard", Vector3.zero.ToString(), Vector3.zero.ToString());
|
||||
hiredNPC.SetPosition(new Vector3(spawnPoint.position.x, spawnPoint.position.y + 1f, spawnPoint.position.z));
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.pauseSleep(hiredNPC, 1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip((EntityPlayerLocal)xui.playerUI.entityPlayer, Localization.Get("ttMissingBedroll"));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
updateLimiter -= _dt;
|
||||
if (!(updateLimiter < 0f)) return;
|
||||
updateLimiter = 1f;
|
||||
UpdateStatus();
|
||||
RefreshBindings(true);
|
||||
}
|
||||
|
||||
public void SetCompanion(EntityNPCRebirth entity)
|
||||
{
|
||||
hiredNPC = entity;
|
||||
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
RefreshBindings(true);
|
||||
return;
|
||||
}
|
||||
|
||||
UpdateStatus();
|
||||
RefreshBindings(true);
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
private void UpdateStatus()
|
||||
{
|
||||
if (hiredNPC == null) return;
|
||||
|
||||
var entityPlayer = xui.playerUI.entityPlayer;
|
||||
var magnitude = (hiredNPC.GetPosition() - entityPlayer.GetPosition()).magnitude;
|
||||
distance = magnitude;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
IsDirty = true;
|
||||
RefreshBindings(true);
|
||||
}
|
||||
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
if (!XUi.IsGameRunning() || xui.playerUI.entityPlayer == null || !LocalPlayerUI.GetUIForPlayer(xui.playerUI.entityPlayer).windowManager.IsWindowOpen("ManageNPCs"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "name" when hiredNPC == null:
|
||||
value = this.name;
|
||||
btnTeleport.IsVisible = false;
|
||||
return true;
|
||||
case "name":
|
||||
value = hiredNPC.EntityName;
|
||||
|
||||
if (hiredNPC.Buffs.GetCustomVar("$FR_NPC_Respawn") == 0f && !(hiredNPC.bMine || hiredNPC.bRepair))
|
||||
{
|
||||
btnTeleport.IsVisible = true;
|
||||
}
|
||||
return true;
|
||||
case "currentorder":
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
//Log.Out("XUiC_HiredNPC-GetBindingValue value: " + value);
|
||||
return true;
|
||||
}
|
||||
|
||||
string currentOrder = "tt" + (EntityUtilities.Orders)hiredNPC.Buffs.GetCustomVar("CurrentOrder");
|
||||
//Log.Out("XUiC_HiredNPC-GetBindingValue currentOrder: " + currentOrder);
|
||||
|
||||
//Log.Out("XUiC_HiredNPC-GetBindingValue hiredNPC.bMine: " + hiredNPC.bMine);
|
||||
|
||||
if (hiredNPC.Buffs.GetCustomVar("$FR_NPC_Respawn") == 1f)
|
||||
{
|
||||
value = "[cf8888]" + Localization.Get("ttInactive") + "[-]";
|
||||
}
|
||||
else if (hiredNPC.bMine)
|
||||
{
|
||||
value = "[cf8888]" + Localization.Get("ttMining") + "[-]";
|
||||
}
|
||||
else if (hiredNPC.bRepair)
|
||||
{
|
||||
value = "[cf8888]" + Localization.Get("ttRepairing") + "[-]";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Localization.Get(currentOrder);
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_HiredNPC-GetBindingValue value: " + value);
|
||||
return true;
|
||||
|
||||
case "distancecolor":
|
||||
{
|
||||
var color2 = Color.white;
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
var leader = EntityUtilities.GetLeaderOrOwner(hiredNPC.entityId);
|
||||
if (leader == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (distance > 50f)
|
||||
{
|
||||
color2 = new Color(207f / 255f, 136f / 255f, 136f / 255f);
|
||||
}
|
||||
|
||||
value = itemicontintcolorFormatter.Format(color2);
|
||||
return true;
|
||||
}
|
||||
case "distance":
|
||||
{
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
value = distanceFormatter.Format(this.distance);
|
||||
return true;
|
||||
}
|
||||
case "position":
|
||||
{
|
||||
value = "";
|
||||
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "[cf8888]" + Localization.Get("ttCannotBeFound") + "[-]\n" + position.ToString();
|
||||
btnWaypoint.IsVisible = true;
|
||||
btnBedroll.IsVisible = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hiredNPC.bMine || hiredNPC.bRepair)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
btnWaypoint.IsVisible = false;
|
||||
btnBedroll.IsVisible = true;
|
||||
value = hiredNPC.position.ToString();
|
||||
return true;
|
||||
}
|
||||
case "type":
|
||||
{
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hiredNPC.HasAnyTags(FastTags<TagGroup.Global>.Parse("survivor")))
|
||||
{
|
||||
value = Localization.Get("ttSurvivor");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Localization.Get(hiredNPC.EntityClass.entityClassName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "level":
|
||||
{
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
value = hiredNPC.Buffs.GetCustomVar("$FR_NPC_Level").ToString();
|
||||
return true;
|
||||
}
|
||||
case "kills":
|
||||
{
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
value = hiredNPC.Buffs.GetCustomVar("$varNumKills").ToString();
|
||||
return true;
|
||||
}
|
||||
case "weapon":
|
||||
{
|
||||
if (hiredNPC == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hiredNPC.EntityClass.Properties.Values.ContainsKey("BagItems"))
|
||||
{
|
||||
value = Localization.Get(hiredNPC.EntityClass.Properties.Values["BagItems"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
263
Scripts/XUIC/XUiC_ImmunityModsRebirth.cs
Normal file
263
Scripts/XUIC/XUiC_ImmunityModsRebirth.cs
Normal file
@@ -0,0 +1,263 @@
|
||||
|
||||
internal class XUiC_ImmunityModsRebirth : XUiController
|
||||
{
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
public float barterPerc = 0f;
|
||||
|
||||
private XUiC_ComboBoxList<string> cbxTargetAuraType;
|
||||
|
||||
public XUiC_ComboBoxInt combo9mm;
|
||||
public XUiC_ComboBoxInt combo762;
|
||||
public XUiC_ComboBoxInt combo44;
|
||||
public XUiC_ComboBoxInt comboShell;
|
||||
public XUiV_Label Resource;
|
||||
public XUiV_Label ResourceMultiplier;
|
||||
public XUiV_Label GatherType;
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Label LabelTotalCash;
|
||||
public XUiV_Label LabelTotalRemains;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
public XUiV_Sprite spriteAuraImage;
|
||||
public XUiV_Sprite spriteRemainsImage;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-Init START");
|
||||
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;
|
||||
|
||||
spriteAuraImage = (XUiV_Sprite)GetChildById("AuraImage").ViewComponent;
|
||||
spriteRemainsImage = (XUiV_Sprite)GetChildById("RemainsImage").ViewComponent;
|
||||
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
LabelTotalCash = (XUiV_Label)Panel.Controller.GetChildById("lblTotalCash").ViewComponent;
|
||||
LabelTotalRemains = (XUiV_Label)Panel.Controller.GetChildById("lblTotalRemains").ViewComponent;
|
||||
|
||||
this.cbxTargetAuraType = (base.GetChildById("cbxAuraType") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxTargetAuraType != null)
|
||||
{
|
||||
this.cbxTargetAuraType.Elements.Add(Localization.Get("ttFire"));
|
||||
this.cbxTargetAuraType.Elements.Add(Localization.Get("ttShock"));
|
||||
this.cbxTargetAuraType.Elements.Add(Localization.Get("ttExplosion"));
|
||||
this.cbxTargetAuraType.Elements.Add(Localization.Get("ttFireShock"));
|
||||
this.cbxTargetAuraType.Elements.Add(Localization.Get("ttFireShockExplosion"));
|
||||
this.cbxTargetAuraType.OnValueChanged += this.cbxTargetAuraType_OnValueChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void changeValue(EntityPlayer player, int index)
|
||||
{
|
||||
string iconAuraName = "";
|
||||
string iconRemainsName = "";
|
||||
string remainsName = "";
|
||||
string costCash = "0";
|
||||
string costRemains = "0";
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
iconAuraName = "FireResistAura";
|
||||
iconRemainsName = "ZombieRemainsFire";
|
||||
remainsName = "FuriousRamsayZombieRemainsFire";
|
||||
costCash = "10000";
|
||||
costRemains = "150";
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
iconAuraName = "ShockResistAura";
|
||||
iconRemainsName = "ZombieRemainsShock";
|
||||
remainsName = "FuriousRamsayZombieRemainsShock";
|
||||
costCash = "12500";
|
||||
costRemains = "200";
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
iconAuraName = "SmokeResistAura";
|
||||
iconRemainsName = "ZombieRemainsSmoke";
|
||||
remainsName = "FuriousRamsayZombieRemainsSmoke";
|
||||
costCash = "15000";
|
||||
costRemains = "250";
|
||||
}
|
||||
else if (index == 3)
|
||||
{
|
||||
iconAuraName = "FireShockResistAura";
|
||||
iconRemainsName = "ZombieRemainsFireShock";
|
||||
remainsName = "FuriousRamsayZombieRemainsFireShock";
|
||||
costCash = "20000";
|
||||
costRemains = "150";
|
||||
}
|
||||
else if (index == 4)
|
||||
{
|
||||
iconAuraName = "FireShockSmokeResistAura";
|
||||
iconRemainsName = "ZombieRemainsFireShockSmoke";
|
||||
remainsName = "FuriousRamsayZombieRemainsFireShockSmoke";
|
||||
costCash = "30000";
|
||||
costRemains = "200";
|
||||
}
|
||||
|
||||
int totalCash = RebirthUtilities.numItems(ItemClass.GetItem("casinoCoin"), player);
|
||||
int totalRemains = RebirthUtilities.numItems(ItemClass.GetItem(remainsName), player);
|
||||
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue costCash: " + costCash);
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue totalCash: " + totalCash);
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue costRemains: " + costRemains);
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue totalRemains: " + totalRemains);
|
||||
|
||||
string cashColor = "ffffff";
|
||||
|
||||
bool cannotTrade = false;
|
||||
|
||||
if (totalCash < int.Parse(costCash))
|
||||
{
|
||||
cashColor = "c79595";
|
||||
cannotTrade = true;
|
||||
}
|
||||
|
||||
string remainsColor = "ffffff";
|
||||
|
||||
if (totalRemains < int.Parse(costRemains))
|
||||
{
|
||||
remainsColor = "c79595";
|
||||
cannotTrade |= true;
|
||||
}
|
||||
|
||||
spriteAuraImage.SpriteName = "ui_game_symbol_" + iconAuraName;
|
||||
spriteRemainsImage.SpriteName = "ui_game_symbol_" + iconRemainsName;
|
||||
|
||||
string cashText = "[" + cashColor + "]" + costCash + "[-]";
|
||||
string remainsText = "[" + remainsColor + "]" + costRemains + "[-]";
|
||||
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue cashText: " + cashText);
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue remainsText: " + remainsText);
|
||||
|
||||
LabelTotalCash.Text = cashText;
|
||||
LabelTotalRemains.Text = remainsText;
|
||||
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue cbxTargetAuraType.Value: " + cbxTargetAuraType.Value);
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-changeValue cbxTargetAuraType.currentIndex: " + cbxTargetAuraType.currentIndex);
|
||||
|
||||
if (cannotTrade)
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnConfirm")).Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnConfirm")).Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void cbxTargetAuraType_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int index = cbxTargetAuraType.currentIndex;
|
||||
|
||||
changeValue(player, index);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-Update 1");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-OnOpen START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
{
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-OnOpen 1, entityID: " + entityID);
|
||||
}
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
cbxTargetAuraType.SelectedIndex = 0;
|
||||
changeValue(player, 0);
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-BtnConfirm_OnPressed START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
int index = cbxTargetAuraType.currentIndex;
|
||||
|
||||
string auraName = "";
|
||||
string remainsName = "";
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
auraName = "FuriousRamsayModFireResist";
|
||||
remainsName = "FuriousRamsayZombieRemainsFire";
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
auraName = "FuriousRamsayModShockResist";
|
||||
remainsName = "FuriousRamsayZombieRemainsShock";
|
||||
}
|
||||
else if (index == 2)
|
||||
{
|
||||
auraName = "FuriousRamsayModSmokeResist";
|
||||
remainsName = "FuriousRamsayZombieRemainsSmoke";
|
||||
}
|
||||
else if (index == 3)
|
||||
{
|
||||
auraName = "FuriousRamsayModFireShockResist";
|
||||
remainsName = "FuriousRamsayZombieRemainsFireShock";
|
||||
}
|
||||
else if (index == 4)
|
||||
{
|
||||
auraName = "FuriousRamsayModFireShockSmokeResist";
|
||||
remainsName = "FuriousRamsayZombieRemainsFireShockSmoke";
|
||||
}
|
||||
|
||||
string cashText = LabelTotalCash.Text.Replace("[-]", "").Replace("[ffffff]", "").Replace("[]", "c79595"); ;
|
||||
string remainsText = LabelTotalRemains.Text.Replace("[-]", "").Replace("[ffffff]", "").Replace("[]", "c79595"); ;
|
||||
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-BtnConfirm_OnPressed AuraType: " + AuraType);
|
||||
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-BtnConfirm_OnPressed cashText: " + cashText);
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-BtnConfirm_OnPressed remainsText: " + remainsText);
|
||||
|
||||
RebirthUtilities.useInventoryBagItem(player, "casinoCoin", int.Parse(cashText));
|
||||
RebirthUtilities.useInventoryBagItem(player, remainsName, int.Parse(remainsText));
|
||||
|
||||
ItemValue itemReceived = ItemClass.GetItem(auraName, false);
|
||||
|
||||
RebirthUtilities.addToPlayerBag(itemReceived, player, 1);
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-BtnCancel_OnPressed START");
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_ImmunityModsRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
491
Scripts/XUIC/XUiC_ItemInfoWindowRebirth.cs
Normal file
491
Scripts/XUIC/XUiC_ItemInfoWindowRebirth.cs
Normal file
@@ -0,0 +1,491 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_ItemInfoWindowRebirth : XUiC_InfoWindow
|
||||
{
|
||||
private ItemStack itemStack = ItemStack.Empty.Clone();
|
||||
private ItemClass itemClass;
|
||||
private XUiC_RepairableVehicleStack selectedItemStack;
|
||||
private XUiController itemPreview;
|
||||
private XUiC_ItemActionList mainActionItemList;
|
||||
private XUiC_ItemActionList traderActionItemList;
|
||||
private XUiC_PartList partList;
|
||||
public XUiC_Counter BuySellCounter;
|
||||
private XUiController statButton;
|
||||
private XUiController descriptionButton;
|
||||
private XUiC_InfoWindow emptyInfoWindow;
|
||||
private bool isBuying;
|
||||
private bool useCustomMarkup;
|
||||
public bool SetMaxCountOnDirty;
|
||||
private ItemDisplayEntry itemDisplayEntry;
|
||||
private XUiC_SelectableEntry hoverEntry;
|
||||
private ItemStack compareStack = ItemStack.Empty;
|
||||
private bool showStats = true;
|
||||
private readonly CachedStringFormatterInt itemcostFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatter<int> markupFormatter = new CachedStringFormatter<int>((Func<int, string>)(_i =>
|
||||
{
|
||||
if (_i > 0)
|
||||
return string.Format(" (+{0}%)", (object)_i);
|
||||
return _i >= 0 ? "" : string.Format(" ({0}%)", (object)_i);
|
||||
}));
|
||||
private readonly CachedStringFormatterXuiRgbaColor itemicontintcolorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatterXuiRgbaColor durabilitycolorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatterFloat durabilityfillFormatter = new CachedStringFormatterFloat();
|
||||
private readonly CachedStringFormatterInt durabilitytextFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterXuiRgbaColor altitemtypeiconcolorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private static readonly Dictionary<string, string> itemGroupToIcon;
|
||||
private static readonly string defaultItemGroupIcon;
|
||||
|
||||
private bool isOpenAsTrader => this.xui.Trader != null && this.xui.Trader.Trader != null;
|
||||
|
||||
public XUiC_SelectableEntry HoverEntry
|
||||
{
|
||||
get => this.hoverEntry;
|
||||
set
|
||||
{
|
||||
if (this.hoverEntry == value)
|
||||
return;
|
||||
this.hoverEntry = value;
|
||||
if (this.hoverEntry != null && !this.hoverEntry.Selected && !this.itemStack.IsEmpty())
|
||||
{
|
||||
ItemStack controllerItemStack = this.GetHoverControllerItemStack();
|
||||
if (!controllerItemStack.IsEmpty() && XUiM_ItemStack.CanCompare(controllerItemStack.itemValue.ItemClass, this.itemClass))
|
||||
this.CompareStack = controllerItemStack;
|
||||
else
|
||||
this.CompareStack = ItemStack.Empty;
|
||||
}
|
||||
else
|
||||
this.CompareStack = ItemStack.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack CompareStack
|
||||
{
|
||||
get => this.compareStack;
|
||||
set
|
||||
{
|
||||
if (this.compareStack == value)
|
||||
return;
|
||||
this.compareStack = value;
|
||||
this.RefreshBindings();
|
||||
}
|
||||
}
|
||||
|
||||
private ItemStack GetHoverControllerItemStack()
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-GetHoverControllerItemStack START");
|
||||
if (this.hoverEntry is XUiC_RepairableVehicleStack hoverEntry1)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-GetHoverControllerItemStack 1");
|
||||
return hoverEntry1.ItemStack;
|
||||
}
|
||||
return this.hoverEntry is XUiC_QuestTurnInEntry hoverEntry5 ? hoverEntry5.Item : (ItemStack)null;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-Init START");
|
||||
base.Init();
|
||||
this.itemPreview = this.GetChildById("itemPreview");
|
||||
this.mainActionItemList = (XUiC_ItemActionList)this.GetChildById("itemActions");
|
||||
this.traderActionItemList = (XUiC_ItemActionList)this.GetChildById("vendorItemActions");
|
||||
this.partList = (XUiC_PartList)this.GetChildById("parts");
|
||||
this.BuySellCounter = this.GetChildByType<XUiC_Counter>();
|
||||
if (this.BuySellCounter != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-Init 1");
|
||||
this.BuySellCounter.OnCountChanged += new XUiEvent_OnCountChanged(this.Counter_OnCountChanged);
|
||||
this.BuySellCounter.Count = 1;
|
||||
}
|
||||
this.statButton = this.GetChildById("statButton");
|
||||
this.statButton.OnPress += new XUiEvent_OnPressEventHandler(this.StatButton_OnPress);
|
||||
this.descriptionButton = this.GetChildById("descriptionButton");
|
||||
this.descriptionButton.OnPress += new XUiEvent_OnPressEventHandler(this.DescriptionButton_OnPress);
|
||||
}
|
||||
|
||||
private void DescriptionButton_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-DescriptionButton_OnPress START");
|
||||
((XUiV_Button)this.statButton.ViewComponent).Selected = false;
|
||||
((XUiV_Button)this.descriptionButton.ViewComponent).Selected = true;
|
||||
this.showStats = false;
|
||||
this.IsDirty = true;
|
||||
}
|
||||
|
||||
private void StatButton_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-StatButton_OnPress START");
|
||||
((XUiV_Button)this.statButton.ViewComponent).Selected = true;
|
||||
((XUiV_Button)this.descriptionButton.ViewComponent).Selected = false;
|
||||
this.showStats = true;
|
||||
this.IsDirty = true;
|
||||
}
|
||||
|
||||
private void Counter_OnCountChanged(XUiController _sender, OnCountChangedEventArgs _e)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-Counter_OnCountChanged START");
|
||||
this.RefreshBindings();
|
||||
this.traderActionItemList.RefreshActionList();
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
if (!this.IsDirty || !this.ViewComponent.IsVisible)
|
||||
return;
|
||||
if (this.emptyInfoWindow == null)
|
||||
this.emptyInfoWindow = (XUiC_InfoWindow)this.xui.FindWindowGroupByName("backpack").GetChildById("emptyInfoPanel");
|
||||
if (this.selectedItemStack != null)
|
||||
this.SetItemStack(this.selectedItemStack);
|
||||
this.IsDirty = false;
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
switch (bindingName)
|
||||
{
|
||||
case "durabilitycolor":
|
||||
Color32 _v1_1 = (Color32)Color.white;
|
||||
if (!this.itemStack.IsEmpty())
|
||||
_v1_1 = (Color32)QualityInfo.GetTierColor(this.itemStack.itemValue.Quality);
|
||||
value = this.durabilitycolorFormatter.Format(_v1_1);
|
||||
return true;
|
||||
case "durabilityfill":
|
||||
value = !this.itemStack.IsEmpty() ? (this.itemStack.itemValue.MaxUseTimes == 0 ? "1" : this.durabilityfillFormatter.Format(((float)this.itemStack.itemValue.MaxUseTimes - this.itemStack.itemValue.UseTimes) / (float)this.itemStack.itemValue.MaxUseTimes)) : "";
|
||||
return true;
|
||||
case "durabilityjustify":
|
||||
value = "center";
|
||||
if (!this.itemStack.IsEmpty() && !this.itemClass.ShowQualityBar)
|
||||
value = "right";
|
||||
return true;
|
||||
case "durabilitytext":
|
||||
value = "";
|
||||
if (!this.itemStack.IsEmpty())
|
||||
value = !this.itemClass.ShowQualityBar ? (this.itemClass.Stacknumber == 1 ? "" : this.durabilitytextFormatter.Format(this.itemStack.count)) : (this.itemStack.itemValue.Quality > 0 ? this.durabilitytextFormatter.Format(this.itemStack.itemValue.Quality) : "-");
|
||||
return true;
|
||||
case "hasdurability":
|
||||
value = (!this.itemStack.IsEmpty() && this.itemClass.ShowQualityBar).ToString();
|
||||
return true;
|
||||
case "hasitemtypeicon":
|
||||
value = !this.itemStack.IsEmpty() ? (!this.itemStack.itemValue.ItemClass.IsBlock() ? (this.itemStack.itemValue.ItemClass.ItemTypeIcon != "").ToString() : (Block.list[this.itemStack.itemValue.type].ItemTypeIcon != "").ToString()) : "false";
|
||||
return true;
|
||||
case "iscomparing":
|
||||
value = (!this.CompareStack.IsEmpty()).ToString();
|
||||
return true;
|
||||
case "isnotcomparing":
|
||||
value = this.CompareStack.IsEmpty().ToString();
|
||||
return true;
|
||||
case "itemammoname":
|
||||
value = "";
|
||||
if (this.itemClass != null)
|
||||
{
|
||||
if (this.itemClass.Actions[0] is ItemActionRanged action2)
|
||||
{
|
||||
if (action2.MagazineItemNames.Length > 1)
|
||||
{
|
||||
ItemClass itemClass = ItemClass.GetItemClass(action2.MagazineItemNames[(int)this.itemStack.itemValue.SelectedAmmoTypeIndex]);
|
||||
value = itemClass.GetLocalizedItemName();
|
||||
}
|
||||
}
|
||||
else if (this.itemClass.Actions[0] is ItemActionLauncher action1 && action1.MagazineItemNames.Length > 1)
|
||||
{
|
||||
ItemClass itemClass = ItemClass.GetItemClass(action1.MagazineItemNames[(int)this.itemStack.itemValue.SelectedAmmoTypeIndex]);
|
||||
value = itemClass.GetLocalizedItemName();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "itemdescription":
|
||||
value = "";
|
||||
if (this.itemClass != null)
|
||||
{
|
||||
if (this.itemClass.IsBlock())
|
||||
{
|
||||
string descriptionKey = Block.list[this.itemClass.Id].DescriptionKey;
|
||||
if (Localization.Exists(descriptionKey))
|
||||
value = Localization.Get(descriptionKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
string descriptionKey = this.itemClass.DescriptionKey;
|
||||
if (Localization.Exists(descriptionKey))
|
||||
value = Localization.Get(descriptionKey);
|
||||
if (this.itemClass.Unlocks != "")
|
||||
{
|
||||
ItemClass itemClass = ItemClass.GetItemClass(this.itemClass.Unlocks);
|
||||
if (itemClass != null)
|
||||
value = value + "\n\n" + Localization.Get(itemClass.DescriptionKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case "itemgroupicon":
|
||||
value = "";
|
||||
if (this.itemClass != null && this.itemClass.Groups.Length != 0)
|
||||
{
|
||||
string group = this.itemClass.Groups[0];
|
||||
if (!XUiC_ItemInfoWindowRebirth.itemGroupToIcon.TryGetValue(group, out value))
|
||||
value = XUiC_ItemInfoWindowRebirth.defaultItemGroupIcon;
|
||||
}
|
||||
return true;
|
||||
case "itemicon":
|
||||
value = this.itemStack == null ? "" : this.itemStack.itemValue.GetPropertyOverride("CustomIcon", this.itemStack.itemValue.ItemClass != null ? this.itemStack.itemValue.ItemClass.GetIconName() : "");
|
||||
return true;
|
||||
case "itemicontint":
|
||||
Color32 _v1_2 = (Color32)Color.white;
|
||||
if (this.itemClass != null)
|
||||
_v1_2 = (Color32)this.itemStack.itemValue.ItemClass.GetIconTint(this.itemStack.itemValue);
|
||||
value = this.itemicontintcolorFormatter.Format(_v1_2);
|
||||
return true;
|
||||
case "itemname":
|
||||
value = this.itemClass != null ? this.itemClass.GetLocalizedItemName() : "";
|
||||
return true;
|
||||
case "itemstattitle1":
|
||||
value = this.itemClass != null ? this.GetStatTitle(0) : "";
|
||||
return true;
|
||||
case "itemstattitle2":
|
||||
value = this.itemClass != null ? this.GetStatTitle(1) : "";
|
||||
return true;
|
||||
case "itemstattitle3":
|
||||
value = this.itemClass != null ? this.GetStatTitle(2) : "";
|
||||
return true;
|
||||
case "itemstattitle4":
|
||||
value = this.itemClass != null ? this.GetStatTitle(3) : "";
|
||||
return true;
|
||||
case "itemstattitle5":
|
||||
value = this.itemClass != null ? this.GetStatTitle(4) : "";
|
||||
return true;
|
||||
case "itemstattitle6":
|
||||
value = this.itemClass != null ? this.GetStatTitle(5) : "";
|
||||
return true;
|
||||
case "itemstattitle7":
|
||||
value = this.itemClass != null ? this.GetStatTitle(6) : "";
|
||||
return true;
|
||||
case "itemtypeicon":
|
||||
if (this.itemStack.IsEmpty())
|
||||
value = "";
|
||||
else if (this.itemStack.itemValue.ItemClass.IsBlock())
|
||||
{
|
||||
value = Block.list[this.itemStack.itemValue.type].ItemTypeIcon;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.itemStack.itemValue.ItemClass.AltItemTypeIcon != null && this.itemStack.itemValue.ItemClass.Unlocks != "" && XUiM_ItemStack.CheckKnown(this.xui.playerUI.entityPlayer, this.itemStack.itemValue.ItemClass, this.itemStack.itemValue))
|
||||
{
|
||||
value = this.itemStack.itemValue.ItemClass.AltItemTypeIcon;
|
||||
return true;
|
||||
}
|
||||
value = this.itemStack.itemValue.ItemClass.ItemTypeIcon;
|
||||
}
|
||||
return true;
|
||||
case "itemtypeicontint":
|
||||
value = "255,255,255,255";
|
||||
if (!this.itemStack.IsEmpty() && this.itemStack.itemValue.ItemClass.Unlocks != "" && XUiM_ItemStack.CheckKnown(this.xui.playerUI.entityPlayer, this.itemStack.itemValue.ItemClass, this.itemStack.itemValue))
|
||||
value = this.altitemtypeiconcolorFormatter.Format((Color32)this.itemStack.itemValue.ItemClass.AltItemTypeIconColor);
|
||||
return true;
|
||||
case "pricelabel":
|
||||
value = "";
|
||||
if (this.itemClass != null && (!this.itemClass.IsBlock() ? this.itemClass.SellableToTrader : Block.list[this.itemStack.itemValue.type].SellableToTrader))
|
||||
{
|
||||
int count = this.itemStack.count;
|
||||
if (this.isOpenAsTrader)
|
||||
count = this.BuySellCounter.Count;
|
||||
value = !this.isBuying ? (XUiM_Trader.GetSellPrice(this.xui, this.itemStack.itemValue, count, this.itemClass) > 0 ? Localization.Get("xuiSellPrice") : "") : (XUiM_Trader.GetBuyPrice(this.xui, this.itemStack.itemValue, count, this.itemClass) > 0 ? Localization.Get("xuiBuyPrice") : "");
|
||||
}
|
||||
return true;
|
||||
case "showdescription":
|
||||
value = (!this.showStats).ToString();
|
||||
return true;
|
||||
case "shownormaloptions":
|
||||
value = (!this.isOpenAsTrader).ToString();
|
||||
return true;
|
||||
case "showonlydescription":
|
||||
value = (!XUiM_ItemStack.HasItemStats(this.itemStack)).ToString();
|
||||
return true;
|
||||
case "showstatanddescription":
|
||||
value = XUiM_ItemStack.HasItemStats(this.itemStack).ToString();
|
||||
return true;
|
||||
case "showstatoptions":
|
||||
value = "false";
|
||||
return true;
|
||||
case "showstats":
|
||||
value = this.showStats.ToString();
|
||||
return true;
|
||||
case "showtraderoptions":
|
||||
value = this.isOpenAsTrader.ToString();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetStatTitle(int index)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-GetStatTitle START");
|
||||
if (this.itemDisplayEntry == null || this.itemDisplayEntry.DisplayStats.Count <= index)
|
||||
return "";
|
||||
return this.itemDisplayEntry.DisplayStats[index].TitleOverride != null ? this.itemDisplayEntry.DisplayStats[index].TitleOverride : UIDisplayInfoManager.Current.GetLocalizedName(this.itemDisplayEntry.DisplayStats[index].StatType);
|
||||
}
|
||||
|
||||
private void makeVisible(bool _makeVisible)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-makeVisible START");
|
||||
if (!_makeVisible || !this.windowGroup.isShowing)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-makeVisible 1");
|
||||
return;
|
||||
}
|
||||
this.ViewComponent.IsVisible = true;
|
||||
((XUiV_Window)this.viewComponent).ForceVisible(1f);
|
||||
}
|
||||
|
||||
public void SetItemStack(XUiC_RepairableVehicleStack stack, bool _makeVisible = false)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetItemStack START");
|
||||
if (stack == null || stack.ItemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetItemStack 1");
|
||||
this.ShowEmptyInfo();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetItemStack 2");
|
||||
this.makeVisible(_makeVisible);
|
||||
this.selectedItemStack = stack;
|
||||
this.SetInfo(stack.ItemStack, (XUiController)stack, XUiC_ItemActionList.ItemActionListTypes.Item);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowEmptyInfo()
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-ShowEmptyInfo START");
|
||||
if (this.emptyInfoWindow == null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-ShowEmptyInfo 1");
|
||||
this.emptyInfoWindow = (XUiC_InfoWindow)this.xui.FindWindowGroupByName("backpack").GetChildById("emptyInfoPanel");
|
||||
}
|
||||
this.emptyInfoWindow.ViewComponent.IsVisible = true;
|
||||
}
|
||||
|
||||
private void SetInfo(
|
||||
ItemStack stack,
|
||||
XUiController controller,
|
||||
XUiC_ItemActionList.ItemActionListTypes actionListType)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo START");
|
||||
bool flag1 = stack.itemValue.type == this.itemStack.itemValue.type && stack.count == this.itemStack.count;
|
||||
this.itemStack = stack.Clone();
|
||||
bool flag2 = this.itemStack != null && !this.itemStack.IsEmpty();
|
||||
if (this.itemPreview == null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 1");
|
||||
return;
|
||||
}
|
||||
if (!flag1 || !stack.itemValue.Equals(this.itemStack.itemValue))
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 2");
|
||||
this.compareStack = ItemStack.Empty.Clone();
|
||||
}
|
||||
this.itemClass = (ItemClass)null;
|
||||
int num = 1;
|
||||
if (flag2)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 3");
|
||||
this.itemClass = this.itemStack.itemValue.ItemClass;
|
||||
if (this.itemClass is ItemClassQuest)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 4");
|
||||
this.itemClass = (ItemClass)ItemClassQuest.GetItemQuestById(this.itemStack.itemValue.Seed);
|
||||
}
|
||||
num = this.itemClass.IsBlock() ? Block.list[this.itemStack.itemValue.type].EconomicBundleSize : this.itemClass.EconomicBundleSize;
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 5");
|
||||
this.itemDisplayEntry = UIDisplayInfoManager.Current.GetDisplayStatsForTag(this.itemClass.IsBlock() ? Block.list[this.itemStack.itemValue.type].DisplayType : this.itemClass.DisplayType);
|
||||
}
|
||||
if (this.isOpenAsTrader)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 6");
|
||||
this.isBuying = actionListType == XUiC_ItemActionList.ItemActionListTypes.Trader;
|
||||
this.traderActionItemList.SetCraftingActionList(actionListType, controller);
|
||||
int count = this.BuySellCounter.Count;
|
||||
if (!flag1)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 7");
|
||||
this.BuySellCounter.Count = this.itemStack.count < num ? 0 : num;
|
||||
}
|
||||
else if (count > this.itemStack.count)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 8");
|
||||
this.BuySellCounter.Count = this.itemStack.count < num ? 0 : this.itemStack.count;
|
||||
}
|
||||
this.BuySellCounter.MaxCount = this.itemStack.count < num ? 0 : this.itemStack.count / num * num;
|
||||
this.BuySellCounter.Step = num;
|
||||
if (this.BuySellCounter.Count == 0 && this.itemStack.count >= num)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 9");
|
||||
this.BuySellCounter.Count = num;
|
||||
}
|
||||
if (this.SetMaxCountOnDirty)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 10");
|
||||
this.BuySellCounter.Count = this.BuySellCounter.MaxCount;
|
||||
this.SetMaxCountOnDirty = false;
|
||||
}
|
||||
this.BuySellCounter.ForceTextRefresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 11");
|
||||
this.mainActionItemList.SetCraftingActionList(actionListType, controller);
|
||||
this.isBuying = false;
|
||||
this.useCustomMarkup = false;
|
||||
}
|
||||
if (flag2 && this.itemStack.itemValue.Modifications != null)
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 12");
|
||||
if (this.itemStack.itemValue.CosmeticMods != null && this.itemStack.itemValue.CosmeticMods.Length != 0 && this.itemStack.itemValue.CosmeticMods[0] != null && !this.itemStack.itemValue.CosmeticMods[0].IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 13");
|
||||
this.partList.SetSlot(this.itemStack.itemValue.CosmeticMods[0], 0);
|
||||
this.partList.SetSlots(this.itemStack.itemValue.Modifications, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 14");
|
||||
this.partList.SetSlots(this.itemStack.itemValue.Modifications);
|
||||
}
|
||||
this.partList.ViewComponent.IsVisible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ItemInfoWindowRebirth-SetInfo 15");
|
||||
this.partList.ViewComponent.IsVisible = false;
|
||||
}
|
||||
this.RefreshBindings();
|
||||
}
|
||||
|
||||
static XUiC_ItemInfoWindowRebirth()
|
||||
{
|
||||
CaseInsensitiveStringDictionary<string> stringDictionary = new CaseInsensitiveStringDictionary<string>();
|
||||
stringDictionary.Add("basics", "ui_game_symbol_campfire");
|
||||
stringDictionary.Add("building", "ui_game_symbol_map_house");
|
||||
stringDictionary.Add("resources", "ui_game_symbol_resource");
|
||||
stringDictionary.Add("ammo/weapons", "ui_game_symbol_knife");
|
||||
stringDictionary.Add("tools/traps", "ui_game_symbol_tool");
|
||||
stringDictionary.Add("food/cooking", "ui_game_symbol_fork");
|
||||
stringDictionary.Add("medicine", "ui_game_symbol_medical");
|
||||
stringDictionary.Add("clothing", "ui_game_symbol_shirt");
|
||||
stringDictionary.Add("decor/miscellaneous", "ui_game_symbol_chair");
|
||||
stringDictionary.Add("books", "ui_game_symbol_book");
|
||||
stringDictionary.Add("chemicals", "ui_game_symbol_water");
|
||||
stringDictionary.Add("mods", "ui_game_symbol_assemble");
|
||||
XUiC_ItemInfoWindowRebirth.itemGroupToIcon = (Dictionary<string, string>)stringDictionary;
|
||||
XUiC_ItemInfoWindowRebirth.defaultItemGroupIcon = "ui_game_symbol_campfire";
|
||||
}
|
||||
}
|
||||
94
Scripts/XUIC/XUiC_MainMenuBackgroundRebirth.cs
Normal file
94
Scripts/XUIC/XUiC_MainMenuBackgroundRebirth.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class XUiC_MainMenuBackgroundRebirth : XUiController
|
||||
{
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.mainMenuTexture = (base.GetChildById("menuBG").ViewComponent as XUiV_Texture);
|
||||
}
|
||||
|
||||
private XUiV_Texture mainMenuTexture;
|
||||
|
||||
public override bool ParseAttribute(string _name, string _value, XUiController _parent)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void GetImage()
|
||||
{
|
||||
string ModsBasePath = GameIO.GetUserGameDataDir() + "/Mods";
|
||||
string ModsBasePathLegacy = Application.platform != UnityEngine.RuntimePlatform.OSXPlayer ? (Application.dataPath + "/../Mods") : (Application.dataPath + "/../../Mods");
|
||||
string imagePath = "";
|
||||
|
||||
if (Directory.Exists(ModsBasePathLegacy + "/zzz_REBIRTH__Utils"))
|
||||
{
|
||||
imagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/Resources/Backgrounds/";
|
||||
}
|
||||
else
|
||||
{
|
||||
imagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/Resources/Backgrounds/";
|
||||
}
|
||||
|
||||
string[] backgroundsPNG = Directory.GetFiles(imagePath, "Menu*.jpg");
|
||||
int randomIndex = 0;
|
||||
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen backgroundsPNG.Length: " + backgroundsPNG.Length);
|
||||
|
||||
|
||||
if (backgroundLeft.Count == 0)
|
||||
{
|
||||
for (int i = 0; i < 81; i++)
|
||||
{
|
||||
backgroundLeft.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen backgroundLeft.Count: " + backgroundLeft.Count);
|
||||
|
||||
int num = UnityEngine.Random.Range(0, backgroundLeft.Count - 1);
|
||||
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen num: " + num);
|
||||
|
||||
randomIndex = backgroundLeft[num];
|
||||
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen randomIndex: " + randomIndex);
|
||||
|
||||
backgroundLeft.Remove(randomIndex);
|
||||
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen prefabImagePath: " + imagePath);
|
||||
if (File.Exists(backgroundsPNG[randomIndex]))
|
||||
{
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen EXISTS");
|
||||
|
||||
Texture2D texture = new Texture2D(0, 0, TextureFormat.RGB24, false);
|
||||
texture.LoadImage(File.ReadAllBytes(backgroundsPNG[randomIndex]));
|
||||
|
||||
mainMenuTexture.Texture = texture;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
float menuBackgroundTick = 20f;
|
||||
if ((Time.time - RebirthVariables.menuBackgroundCheck) > menuBackgroundTick)
|
||||
{
|
||||
RebirthVariables.menuBackgroundCheck = Time.time;
|
||||
GetImage();
|
||||
}
|
||||
|
||||
base.Update(_dt);
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen START");
|
||||
//Log.Out("XUiC_MainMenuBackgroundRebirth-OnOpen Size: " + mainMenuTexture.Size);
|
||||
|
||||
GetImage();
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private static List<int> backgroundLeft = new List<int>();
|
||||
}
|
||||
233
Scripts/XUIC/XUiC_MainMenuRebirth.cs
Normal file
233
Scripts/XUIC/XUiC_MainMenuRebirth.cs
Normal file
@@ -0,0 +1,233 @@
|
||||
public class XUiC_MainMenuRebirth : XUiC_MainMenu
|
||||
{
|
||||
public XUiC_SimpleButton btnRebirthDiscord;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
if (!GameManager.IsDedicatedServer)
|
||||
{
|
||||
this.btnRebirthDiscord = base.GetChildById("btnRebirthDiscord") as XUiC_SimpleButton;
|
||||
this.btnRebirthDiscord.OnPressed += this.btnRebirthDiscord_OnPressed;
|
||||
|
||||
UILabel component = this.xui.playerUI.nguiWindowManager.GetWindow(EnumNGUIWindow.Version).GetComponent<UILabel>();
|
||||
Mod mod = ModManager.GetMod("zzz_REBIRTH__Utils", true);
|
||||
|
||||
component.text = "[bf9ad9]REBIRTH[-] " + mod.Version + " / " + Constants.cVersionInformation.LongString;
|
||||
Log.Out("Rebirth Version: " + mod.Version);
|
||||
}
|
||||
}
|
||||
private void btnRebirthDiscord_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
Application.OpenURL("https://discord.gg/gfBxVYy4mu");
|
||||
}
|
||||
|
||||
/*public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
XUiC_MainMenu.ID = base.WindowGroup.ID;
|
||||
this.btnNewGame = base.GetChildById("btnNewGame") as XUiC_SimpleButton;
|
||||
this.btnContinueGame = base.GetChildById("btnContinueGame") as XUiC_SimpleButton;
|
||||
this.btnConnectToServer = base.GetChildById("btnConnectToServer") as XUiC_SimpleButton;
|
||||
this.btnRebirthDiscord = base.GetChildById("btnRebirthDiscord") as XUiC_SimpleButton;
|
||||
this.btnEditingTools = base.GetChildById("btnEditingTools") as XUiC_SimpleButton;
|
||||
this.btnOptions = base.GetChildById("btnOptions") as XUiC_SimpleButton;
|
||||
this.btnCredits = base.GetChildById("btnCredits") as XUiC_SimpleButton;
|
||||
this.btnQuit = base.GetChildById("btnQuit") as XUiC_SimpleButton;
|
||||
this.btnNewGame.OnPressed += this.btnNewGame_OnPressed;
|
||||
this.btnContinueGame.OnPressed += this.btnContinueGame_OnPressed;
|
||||
this.btnConnectToServer.OnPressed += this.btnConnectToServer_OnPressed;
|
||||
this.btnRebirthDiscord.OnPressed += this.btnRebirthDiscord_OnPressed;
|
||||
this.btnEditingTools.OnPressed += this.btnEditingTools_OnPressed;
|
||||
this.btnOptions.OnPressed += this.btnOptions_OnPressed;
|
||||
this.btnCredits.OnPressed += this.btnCredits_OnPressed;
|
||||
this.btnQuit.OnPressed += this.btnQuit_OnPressed;
|
||||
|
||||
if(!GameManager.IsDedicatedServer)
|
||||
{
|
||||
UILabel component = this.xui.playerUI.nguiWindowManager.GetWindow(EnumNGUIWindow.Version).GetComponent<UILabel>();
|
||||
Mod mod = ModManager.GetMod("zzz_REBIRTH__Utils", true);
|
||||
|
||||
component.text = "[bf9ad9]REBIRTH[-] " + mod.Version + " / " + Constants.cVersionInformation.LongString;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnRebirthDiscord_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
Application.OpenURL("https://discord.gg/gfBxVYy4mu");
|
||||
}
|
||||
|
||||
private void btnNewGame_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
XUiC_NewContinueGame.SetIsContinueGame(base.xui, false);
|
||||
this.CheckProfile(XUiC_NewContinueGame.ID);
|
||||
}
|
||||
|
||||
private void btnContinueGame_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
XUiC_NewContinueGame.SetIsContinueGame(base.xui, true);
|
||||
this.CheckProfile(XUiC_NewContinueGame.ID);
|
||||
}
|
||||
|
||||
private void btnConnectToServer_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
this.CheckProfile(XUiC_ServerBrowser.ID);
|
||||
}
|
||||
|
||||
private void btnEditingTools_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
base.xui.playerUI.windowManager.Close(this.windowGroup.ID);
|
||||
base.xui.playerUI.windowManager.Open(XUiC_EditingTools.ID, true, false, true);
|
||||
}
|
||||
|
||||
private void btnOptions_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
base.xui.playerUI.windowManager.Close(this.windowGroup.ID);
|
||||
base.xui.playerUI.windowManager.Open(XUiC_OptionsMenu.ID, true, false, true);
|
||||
}
|
||||
|
||||
private void btnCredits_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
base.xui.playerUI.windowManager.Close(this.windowGroup.ID);
|
||||
base.xui.playerUI.windowManager.Open(XUiC_Credits.ID, true, false, true);
|
||||
}
|
||||
|
||||
private void btnQuit_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
private void CheckProfile(string _windowToOpen)
|
||||
{
|
||||
base.xui.playerUI.windowManager.Close(this.windowGroup.ID);
|
||||
if(ProfileSDF.CurrentProfileName().Length == 0)
|
||||
{
|
||||
XUiC_OptionsProfiles.Open(base.xui, delegate
|
||||
{
|
||||
this.xui.playerUI.windowManager.Open(_windowToOpen, true, false, true);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
base.xui.playerUI.windowManager.Open(_windowToOpen, true, false, true);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
this.windowGroup.isEscClosable = false;
|
||||
this.RefreshBindings();
|
||||
bool _checkRestartAtMainMenu = true;
|
||||
int num = PlatformManager.MultiPlatform.JoinSessionGameInviteListener == null ? 0 : (PlatformManager.MultiPlatform.JoinSessionGameInviteListener.IsProcessingIntent(out _checkRestartAtMainMenu) ? 1 : 0);
|
||||
if (_checkRestartAtMainMenu)
|
||||
ThreadManager.StartCoroutine(PlatformApplicationManager.CheckRestartCoroutine());
|
||||
if (num != 0)
|
||||
XUiC_ProgressWindow.Open(LocalPlayerUI.primaryUI, Localization.Get("lblReceivedGameInvite"), (System.Action)([PublicizedFrom(EAccessModifier.Internal)] () =>
|
||||
{
|
||||
PlatformManager.MultiPlatform.JoinSessionGameInviteListener?.Cancel();
|
||||
LocalPlayerUI.primaryUI.windowManager.Open(XUiC_MainMenu.ID, true);
|
||||
}));
|
||||
this.DoLoadSaveGameAutomation();
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string _value, string _bindingName)
|
||||
{
|
||||
if(_bindingName != null)
|
||||
{
|
||||
if(_bindingName == "systemtime_hr")
|
||||
{
|
||||
_value = DateTime.Now.Hour.ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(_bindingName == "systemtime_min")
|
||||
{
|
||||
_value = DateTime.Now.Minute.ToString();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(_bindingName == "systemtime_sec")
|
||||
{
|
||||
_value = DateTime.Now.Second.ToString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return base.GetBindingValue(ref _value, _bindingName);
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
PlatformManager.MultiPlatform.RichPresence.UpdateRichPresence(IRichPresence.PresenceStates.Menu);
|
||||
TitleStorageOverridesManager.Instance.FetchFromSource((Action<TitleStorageOverridesManager.TSOverrides>)null);
|
||||
|
||||
XUiC_MainMenu.openedOnce = true;
|
||||
SaveDataUtils.SaveDataManager.CommitAsync();
|
||||
this.anySaveFilesExist = GameIO.GetPlayerSaves() > 0;
|
||||
this.xui.playerUI.windowManager.Close("eacWarning");
|
||||
this.xui.playerUI.windowManager.Close("crossplayWarning");
|
||||
XUiC_MainMenuPlayerName.OpenIfNotOpen(this.xui);
|
||||
|
||||
if (base.xui.playerUI.ActionSetManager != null)
|
||||
{
|
||||
base.xui.playerUI.ActionSetManager.Reset();
|
||||
base.xui.playerUI.ActionSetManager.Push(base.xui.playerUI.playerInput);
|
||||
if(base.xui.playerUI.windowManager.IsWindowOpen(GUIWindowConsole.ID))
|
||||
{
|
||||
base.xui.playerUI.ActionSetManager.Push(base.xui.playerUI.playerInput.GUIActions);
|
||||
}
|
||||
}
|
||||
|
||||
this.btnConnectToServer.Enabled = PlatformManager.MultiPlatform.User.UserStatus != EUserStatus.OfflineMode;
|
||||
base.xui.playerUI.nguiWindowManager.Show(EnumNGUIWindow.MainMenuBackground, false);
|
||||
base.xui.playerUI.windowManager.Open("menuBackground", false, false, true);
|
||||
base.xui.playerUI.windowManager.Open("mainMenuLogo", false, false, true);
|
||||
GameManager.Instance.SetCursorEnabledOverride(false, false);
|
||||
this.xui.playerUI.CursorController.SetCursorHidden(false);
|
||||
this.GetChildById("btnNewGame").SelectCursorElement(true);
|
||||
this.xui.playerUI.windowManager.OpenIfNotOpen("CalloutGroup", false);
|
||||
this.xui.calloutWindow.ClearCallouts(XUiC_GamepadCalloutWindow.CalloutType.Menu);
|
||||
this.xui.calloutWindow.AddCallout(UIUtils.ButtonIcon.FaceButtonSouth, "igcoSelect", XUiC_GamepadCalloutWindow.CalloutType.Menu);
|
||||
this.xui.calloutWindow.RemoveCallout(UIUtils.ButtonIcon.FaceButtonEast, "igcoBack", XUiC_GamepadCalloutWindow.CalloutType.Menu);
|
||||
this.xui.calloutWindow.SetCalloutsEnabled(XUiC_GamepadCalloutWindow.CalloutType.Menu, true);
|
||||
TriggerEffectManager.SetMainMenuLightbarColor();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
base.xui.playerUI.windowManager.Close("mainMenuLogo");
|
||||
this.xui.calloutWindow.AddCallout(UIUtils.ButtonIcon.FaceButtonEast, "igcoBack", XUiC_GamepadCalloutWindow.CalloutType.Menu);
|
||||
XUiC_MainMenuPlayerName.Close(this.xui);
|
||||
}
|
||||
|
||||
public static void Open(XUi _xuiInstance)
|
||||
{
|
||||
XUiC_MainMenu.shownNewsScreenOnce = true;
|
||||
IJoinSessionGameInviteListener gameInviteListener = PlatformManager.NativePlatform.JoinSessionGameInviteListener;
|
||||
if ((gameInviteListener != null ? (gameInviteListener.HasPendingIntent() ? 1 : 0) : 0) != 0)
|
||||
XUiC_MainMenu.shownNewsScreenOnce = true;
|
||||
if (!XUiC_MainMenu.shownNewsScreenOnce)
|
||||
{
|
||||
XUiC_NewsScreen.Open(_xuiInstance);
|
||||
XUiC_MainMenu.shownNewsScreenOnce = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_xuiInstance.playerUI.windowManager.Open(XUiC_MainMenu.ID, true);
|
||||
}
|
||||
}
|
||||
|
||||
public static string ID = "";
|
||||
public static bool openedOnce;
|
||||
private XUiC_SimpleButton btnNewGame;
|
||||
private XUiC_SimpleButton btnContinueGame;
|
||||
private XUiC_SimpleButton btnConnectToServer;
|
||||
private XUiC_SimpleButton btnRebirthDiscord;
|
||||
private XUiC_SimpleButton btnEditingTools;
|
||||
private XUiC_SimpleButton btnOptions;
|
||||
private XUiC_SimpleButton btnCredits;
|
||||
private XUiC_SimpleButton btnQuit;
|
||||
public bool anySaveFilesExist;*/
|
||||
}
|
||||
123
Scripts/XUIC/XUiC_ManageNPCs.cs
Normal file
123
Scripts/XUIC/XUiC_ManageNPCs.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static RebirthManager;
|
||||
|
||||
internal class XUiC_ManageNPCs : XUiController
|
||||
{
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
private EntityPlayerLocal _player;
|
||||
|
||||
private List<XUiC_HiredNPC> entryList = new List<XUiC_HiredNPC>();
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_ManageNPCs-Init START");
|
||||
base.Init();
|
||||
Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent;
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancel_OnPressed;
|
||||
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
//Log.Out("XUiC_ManageNPCs-Update 1");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ManageNPCs-OnOpen START");
|
||||
base.OnOpen();
|
||||
_player = xui.playerUI.entityPlayer;
|
||||
if (_player == null)
|
||||
{
|
||||
OnClose();
|
||||
return;
|
||||
}
|
||||
RefreshHires();
|
||||
}
|
||||
|
||||
private void RefreshHires()
|
||||
{
|
||||
//Log.Out("XUiC_ManageNPCs-RefreshCompanions START");
|
||||
|
||||
var childrenByType = GetChildrenByType<XUiC_HiredNPC>(null);
|
||||
foreach (var t in childrenByType)
|
||||
{
|
||||
t.ViewComponent.IsVisible = false;
|
||||
entryList.Add(t);
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_ManageNPCs-RefreshCompanions entryList.Count: " + entryList.Count);
|
||||
|
||||
foreach (var t in entryList)
|
||||
{
|
||||
t.SetCompanion(null);
|
||||
t.ViewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
var j = 0;
|
||||
|
||||
foreach (hireInfo hire in playerHires)
|
||||
{
|
||||
if (hire.playerID == _player.entityId)
|
||||
{
|
||||
EntityNPCRebirth hiredNPC = GameManager.Instance.World.GetEntity(hire.hireID) as EntityNPCRebirth;
|
||||
|
||||
if (hiredNPC != null
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_ManageNPCs-RefreshCompanions hiredNPC: " + hiredNPC.EntityClass.entityClassName);
|
||||
if (!hiredNPC.EntityClass.Tags.Test_AnySet(FastTags<TagGroup.Global>.Parse("temp")) && j <= entryList.Count - 1)
|
||||
{
|
||||
entryList[j].name = hire.name;
|
||||
entryList[j].EntityID = hire.hireID;
|
||||
entryList[j].position = hire.spawnPosition;
|
||||
entryList[j].SetCompanion(hiredNPC);
|
||||
entryList[j].ViewComponent.IsVisible = true;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entryList[j].name = hire.name;
|
||||
entryList[j].EntityID = hire.hireID;
|
||||
entryList[j].position = hire.spawnPosition;
|
||||
entryList[j].ViewComponent.IsVisible = true;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_ManageNPCs-RefreshCompanions num hires: " + j);
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ManageNPCs-BtnCancel_OnPressed START");
|
||||
/*Panel.IsVisible = false;
|
||||
entryList.Clear();
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);*/
|
||||
OnClose();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_ManageNPCs-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
entryList.Clear();
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
145
Scripts/XUIC/XUiC_MapAreaRebirth.cs
Normal file
145
Scripts/XUIC/XUiC_MapAreaRebirth.cs
Normal file
@@ -0,0 +1,145 @@
|
||||
public class XUiC_MapAreaRebirth : XUiC_MapArea
|
||||
{
|
||||
public static bool purgeIconToggle = false;
|
||||
public static bool tier0IconToggle = false;
|
||||
public static bool tier1IconToggle = false;
|
||||
public static bool tier2IconToggle = false;
|
||||
public static bool tier3IconToggle = false;
|
||||
public static bool tier4IconToggle = false;
|
||||
public static bool tier5IconToggle = false;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.GetChildById("purgedIcon").OnPress += new XUiEvent_OnPressEventHandler(this.onPurgedIconPressed);
|
||||
this.GetChildById("tier0Icon").OnPress += new XUiEvent_OnPressEventHandler(this.ontier0IconPressed);
|
||||
this.GetChildById("tier1Icon").OnPress += new XUiEvent_OnPressEventHandler(this.ontier1IconPressed);
|
||||
this.GetChildById("tier2Icon").OnPress += new XUiEvent_OnPressEventHandler(this.ontier2IconPressed);
|
||||
this.GetChildById("tier3Icon").OnPress += new XUiEvent_OnPressEventHandler(this.ontier3IconPressed);
|
||||
this.GetChildById("tier4Icon").OnPress += new XUiEvent_OnPressEventHandler(this.ontier4IconPressed);
|
||||
this.GetChildById("tier5Icon").OnPress += new XUiEvent_OnPressEventHandler(this.ontier5IconPressed);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
this.RefreshBindings();
|
||||
}
|
||||
|
||||
public void onIconPressed(ref bool iconToggle, string navObjectClassName)
|
||||
{
|
||||
iconToggle = !iconToggle;
|
||||
|
||||
foreach (NavObject navObject in NavObjectManager.Instance.NavObjectList)
|
||||
{
|
||||
if (navObject != null && navObject.NavObjectClass != null)
|
||||
{
|
||||
if (navObject.NavObjectClass.NavObjectClassName == navObjectClassName)
|
||||
{
|
||||
navObject.hiddenOnCompass = iconToggle;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onPurgedIconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = purgeIconToggle;
|
||||
onIconPressed(ref localIconToggle, "purge_waypoint");
|
||||
purgeIconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public void ontier0IconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = tier0IconToggle;
|
||||
onIconPressed(ref localIconToggle, "discovered_waypoint_0");
|
||||
tier0IconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public void ontier1IconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = tier1IconToggle;
|
||||
onIconPressed(ref localIconToggle, "discovered_waypoint_1");
|
||||
tier1IconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public void ontier2IconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = tier2IconToggle;
|
||||
onIconPressed(ref localIconToggle, "discovered_waypoint_2");
|
||||
tier2IconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public void ontier3IconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = tier3IconToggle;
|
||||
onIconPressed(ref localIconToggle, "discovered_waypoint_3");
|
||||
tier3IconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public void ontier4IconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = tier4IconToggle;
|
||||
onIconPressed(ref localIconToggle, "discovered_waypoint_4");
|
||||
tier4IconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public void ontier5IconPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
bool localIconToggle = tier5IconToggle;
|
||||
onIconPressed(ref localIconToggle, "discovered_waypoint_5");
|
||||
tier5IconToggle = localIconToggle;
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
switch (bindingName)
|
||||
{
|
||||
case "height":
|
||||
value = "712";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "670";
|
||||
}
|
||||
return true;
|
||||
case "heightY":
|
||||
value = "712";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
//value = "670";
|
||||
value = "712";
|
||||
}
|
||||
return true;
|
||||
case "heightY2":
|
||||
value = "761";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "780";
|
||||
}
|
||||
return true;
|
||||
case "posY":
|
||||
value = "-49";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "-91";
|
||||
}
|
||||
return true;
|
||||
case "clipY":
|
||||
value = "-356";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "-335";
|
||||
}
|
||||
return true;
|
||||
case "purge":
|
||||
value = "false";
|
||||
if (RebirthVariables.customScenario == "purge")
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return base.GetBindingValue(ref value, bindingName);
|
||||
}
|
||||
}
|
||||
}
|
||||
142
Scripts/XUIC/XUiC_OfferQuestPopupRebirth.cs
Normal file
142
Scripts/XUIC/XUiC_OfferQuestPopupRebirth.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
internal class XUiC_OfferQuestPopupRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label LabelQuestName;
|
||||
public XUiV_Label LabelQuestOffer;
|
||||
public XUiV_Panel Panel;
|
||||
string strQuestID = "";
|
||||
|
||||
private Quest quest;
|
||||
|
||||
public Quest Quest
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.quest;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.quest = value;
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public int QuestGiverID { get; private set; }
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-Init START");
|
||||
|
||||
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;
|
||||
LabelQuestName = (XUiV_Label)Panel.Controller.GetChildById("questName").ViewComponent;
|
||||
LabelQuestOffer = (XUiV_Label)Panel.Controller.GetChildById("questOffer").ViewComponent;
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-Init END");
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-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_OfferQuestPopupRebirth-OnOpen 1");
|
||||
return;
|
||||
}
|
||||
|
||||
var myEntity = player.world.GetEntity(entityID) as EntityAlive;
|
||||
if (myEntity == null)
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
float questNumber = 0;
|
||||
if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestNumber"))
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen 3");
|
||||
questNumber = (float)player.Buffs.GetCustomVar("$varFuriousRamsayQuestNumber");
|
||||
}
|
||||
player.Buffs.SetCustomVar("$varFuriousRamsayQuestNumber", 0f);
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen questNumber: " + questNumber);
|
||||
|
||||
if (questNumber == 1)
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen 4");
|
||||
strQuestID = "quest_FuriousRamsayEventNanos";
|
||||
this.Quest = QuestClass.CreateQuest(strQuestID);
|
||||
LabelQuestName.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Name);
|
||||
LabelQuestOffer.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Offer);
|
||||
}
|
||||
if (questNumber == 2)
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen 4");
|
||||
strQuestID = "quest_FuriousRamsayMissionBrownPaste";
|
||||
this.Quest = QuestClass.CreateQuest(strQuestID);
|
||||
LabelQuestName.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Name);
|
||||
LabelQuestOffer.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Offer);
|
||||
}
|
||||
if (questNumber == 3)
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen 4");
|
||||
strQuestID = "quest_FuriousRamsayMissionChickenCoop";
|
||||
this.Quest = QuestClass.CreateQuest(strQuestID);
|
||||
LabelQuestName.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Name);
|
||||
LabelQuestOffer.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Offer);
|
||||
}
|
||||
if (questNumber == 4)
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen 4");
|
||||
strQuestID = "quest_FuriousRamsayMissionAmmoMachine";
|
||||
this.Quest = QuestClass.CreateQuest(strQuestID);
|
||||
LabelQuestName.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Name);
|
||||
LabelQuestOffer.Text = this.Quest.GetParsedText(this.Quest.QuestClass.Offer);
|
||||
}
|
||||
base.OnOpen();
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnOpen END");
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-BtnConfirm_OnPressed START");
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
player.QuestJournal.AddQuest(this.Quest);
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-BtnConfirm_OnPressed END");
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-BtnCancel_OnPressed START");
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-BtnCancel_OnPressed END");
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnClose START");
|
||||
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
|
||||
//Log.Out("XUiC_OfferQuestPopupRebirth-OnClose END");
|
||||
}
|
||||
}
|
||||
111
Scripts/XUIC/XUiC_PermadeathRebirth.cs
Normal file
111
Scripts/XUIC/XUiC_PermadeathRebirth.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using System.Collections;
|
||||
|
||||
public class XUiC_PermadeathRebirth : XUiController
|
||||
{
|
||||
public string TipText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.tipText;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.tipText = value;
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string TipTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.tipTitle;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.tipTitle = value;
|
||||
this.IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ToolTipEvent CloseEvent { get; set; }
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName != null)
|
||||
{
|
||||
if (bindingName == "tiptext")
|
||||
{
|
||||
value = this.TipText;
|
||||
return true;
|
||||
}
|
||||
if (bindingName == "tiptitle")
|
||||
{
|
||||
value = this.TipTitle;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public XUiV_Rect Panel;
|
||||
public XUiV_Label Description;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
((XUiV_Button)base.GetChildById("clickable").ViewComponent).Controller.OnPress += this.closeButton_OnPress;
|
||||
Panel = (XUiV_Rect)GetChildById("content").ViewComponent;
|
||||
Description = (XUiV_Label)Panel.Controller.GetChildById("descriptionText").ViewComponent;
|
||||
}
|
||||
|
||||
private void closeButton_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
base.xui.playerUI.windowManager.Close(base.WindowGroup.ID);
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
int num = UnityEngine.Random.Range(1, 3);
|
||||
|
||||
Description.Text = Localization.Get("infoFuriousRamsayPermadeath" + num);
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
if (this.IsDirty)
|
||||
{
|
||||
base.RefreshBindings(true);
|
||||
this.IsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
if (this.CloseEvent != null)
|
||||
{
|
||||
this.CloseEvent.HandleEvent();
|
||||
this.CloseEvent = null;
|
||||
}
|
||||
if (this.nextTip != "")
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(this.openTipLater(this.nextTip, base.xui.playerUI.entityPlayer));
|
||||
this.nextTip = "";
|
||||
}
|
||||
}
|
||||
|
||||
protected IEnumerator openTipLater(string tip, EntityPlayerLocal player)
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
//XUiC_PermadeathRebirth.ShowTip(tip, player, null);
|
||||
yield break;
|
||||
}
|
||||
|
||||
private string tipText = "";
|
||||
private string tipTitle = "";
|
||||
private string nextTip = "";
|
||||
}
|
||||
238
Scripts/XUIC/XUiC_PreviewInformationWindowRebirth.cs
Normal file
238
Scripts/XUIC/XUiC_PreviewInformationWindowRebirth.cs
Normal file
@@ -0,0 +1,238 @@
|
||||
public class XUiC_PreviewInformationWindowRebirth : XUiController
|
||||
{
|
||||
public XUiV_Sprite imagePreview;
|
||||
public XUiV_Label description;
|
||||
public XUiV_Label title;
|
||||
public XUiV_Panel content;
|
||||
public XUiC_SimpleButton btnOk;
|
||||
public XUiC_SimpleButton btnTrader;
|
||||
public int windowX = -1;
|
||||
public int windowY = -1;
|
||||
public int imageWidth = 0;
|
||||
public int imageHeight = 0;
|
||||
public int previewIndex = -1;
|
||||
public string quest = "";
|
||||
public string gameevent = "";
|
||||
public string items = "";
|
||||
public string trader = "";
|
||||
public static string ID = "";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-Init START");
|
||||
base.Init();
|
||||
XUiC_PreviewInformationWindowRebirth.ID = base.WindowGroup.ID;
|
||||
this.imagePreview = (XUiV_Sprite)GetChildById("imagePreview").ViewComponent;
|
||||
this.btnOk = base.GetChildById("btnOk") as XUiC_SimpleButton;
|
||||
this.btnTrader = base.GetChildById("btnTrader") as XUiC_SimpleButton;
|
||||
this.btnOk.OnPressed += BtnOk_OnPressed;
|
||||
this.btnTrader.OnPressed += BtnTrader_OnPressed;
|
||||
this.description = (XUiV_Label)GetChildById("descriptionText").ViewComponent;
|
||||
|
||||
this.title = (XUiV_Label)GetChildById("title").ViewComponent;
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-Update START");
|
||||
base.Update(_dt);
|
||||
if (this.IsDirty)
|
||||
{
|
||||
base.RefreshBindings(true);
|
||||
this.IsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnOk_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
if (this.items != "")
|
||||
{
|
||||
string[] itemList = this.items.Split('~');
|
||||
|
||||
for (int i = 0; i < itemList.Length; i++)
|
||||
{
|
||||
string[] itemProperties = itemList[i].Split(',');
|
||||
|
||||
ItemValue itemValue = null;
|
||||
int quantity = 1;
|
||||
int quality = 1;
|
||||
|
||||
for (int j = 0; j < itemList.Length; j++)
|
||||
{
|
||||
if (j == 0)
|
||||
{
|
||||
itemValue = ItemClass.GetItem(itemProperties[j]);
|
||||
}
|
||||
else if (j == 1)
|
||||
{
|
||||
quantity = int.Parse(itemProperties[j]);
|
||||
}
|
||||
else if (j == 2)
|
||||
{
|
||||
if (itemValue.HasQuality)
|
||||
{
|
||||
quality = int.Parse(itemProperties[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RebirthUtilities.addToPlayerInventory(itemValue, base.xui.playerUI.entityPlayer, quantity, "", quality);
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-BtnOk_OnPressed previewIndex: " + this.previewIndex);
|
||||
|
||||
if (this.previewIndex == 2)
|
||||
{
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolRepairT0StoneAxe"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolRepairT0StoneAxe"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 1);
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolShovelT0StoneShovel"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolShovelT0StoneShovel"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 1);
|
||||
}
|
||||
else if (this.previewIndex == 3)
|
||||
{
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("FuriousRamsayClassBookGeneric"), base.xui.playerUI.entityPlayer, 1, "", 1);
|
||||
|
||||
string optionJumpstart = RebirthVariables.customJumpstart;
|
||||
|
||||
if (optionJumpstart == "classbookessentials")
|
||||
{
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolAxeT1IronFireaxe"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolAxeT1IronFireaxe"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 2);
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolPickT1IronPickaxe"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolPickT1IronPickaxe"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 2);
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolShovelT1IronShovel"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolShovelT1IronShovel"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 2);
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolSalvageT1Wrench"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolSalvageT1Wrench"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 1);
|
||||
|
||||
ProgressionValue progressionValue = base.xui.playerUI.entityPlayer.Progression.GetProgressionValue("FuriousRamsayMiningTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 50)
|
||||
{
|
||||
progressionValue.Level = 50;
|
||||
RebirthVariables.localVariables["$varFuriousRamsayMinePercUnit"] = 0.5f;
|
||||
RebirthUtilities.ProcessAttribute(base.xui.playerUI.entityPlayer, "$varFuriousRamsayMinePercUnit");
|
||||
}
|
||||
}
|
||||
|
||||
progressionValue = base.xui.playerUI.entityPlayer.Progression.GetProgressionValue("FuriousRamsayDiggingTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 50)
|
||||
{
|
||||
progressionValue.Level = 50;
|
||||
RebirthVariables.localVariables["$varFuriousRamsayDigPercUnit"] = 0.75f;
|
||||
RebirthUtilities.ProcessAttribute(base.xui.playerUI.entityPlayer, "$varFuriousRamsayDigPercUnit");
|
||||
}
|
||||
}
|
||||
|
||||
progressionValue = base.xui.playerUI.entityPlayer.Progression.GetProgressionValue("craftingChoppingTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 50)
|
||||
{
|
||||
progressionValue.Level = 50;
|
||||
RebirthVariables.localVariables["$varFuriousRamsayChopPercUnit"] = 0.5f;
|
||||
RebirthUtilities.ProcessAttribute(base.xui.playerUI.entityPlayer, "$varFuriousRamsayChopPercUnit");
|
||||
}
|
||||
}
|
||||
|
||||
progressionValue = base.xui.playerUI.entityPlayer.Progression.GetProgressionValue("craftingSalvageTools");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
if (progressionValue.Level < 10)
|
||||
{
|
||||
progressionValue.Level = 10;
|
||||
RebirthVariables.localVariables["$varFuriousRamsaySalvageToolsPercUnit"] = 0.1f;
|
||||
RebirthUtilities.ProcessAttribute(base.xui.playerUI.entityPlayer, "$varFuriousRamsaySalvageToolsPercUnit");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolRepairT0StoneAxe"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolRepairT0StoneAxe"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 1);
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("meleeToolShovelT0StoneShovel"), base.xui.playerUI.entityPlayer))
|
||||
RebirthUtilities.addToPlayerInventory(ItemClass.GetItem("meleeToolShovelT0StoneShovel"), base.xui.playerUI.entityPlayer, 1, "", 1, true, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.quest != "")
|
||||
{
|
||||
Quest quest = QuestClass.CreateQuest(this.quest);
|
||||
base.xui.playerUI.entityPlayer.QuestJournal.AddQuest(quest);
|
||||
}
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnTrader_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
if (this.gameevent != "")
|
||||
{
|
||||
GameEventManager.Current.HandleAction(this.gameevent, base.xui.playerUI.entityPlayer as EntityPlayer, base.xui.playerUI.entityPlayer, false, "", "", false, true, "", null);
|
||||
}
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue START");
|
||||
if (bindingName != null)
|
||||
{
|
||||
if (bindingName == "windowX")
|
||||
{
|
||||
value = this.windowX.ToString();
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue windowX value: " + value);
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "windowY")
|
||||
{
|
||||
value = this.windowY.ToString();
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue windowY value: " + value);
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "imageWidth")
|
||||
{
|
||||
value = this.imageWidth.ToString();
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue imageWidth value: " + value);
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "imageHeight")
|
||||
{
|
||||
value = this.imageHeight.ToString();
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue imageHeight value: " + value);
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "descriptionHeight")
|
||||
{
|
||||
value = (693 - this.imageHeight).ToString();
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue imageHeight value: " + value);
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "traderinfovisible")
|
||||
{
|
||||
value = (this.previewIndex == 4).ToString();
|
||||
|
||||
if (RebirthUtilities.ScenarioSkip())
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-GetBindingValue traderinfovisible value: " + value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_PreviewInformationWindowRebirth-OnOpen START");
|
||||
this.btnTrader.ViewComponent.IsVisible = false;
|
||||
this.previewIndex = -1;
|
||||
base.OnOpen();
|
||||
}
|
||||
}
|
||||
349
Scripts/XUIC/XUiC_QuestOfferWindowRebirth.cs
Normal file
349
Scripts/XUIC/XUiC_QuestOfferWindowRebirth.cs
Normal file
@@ -0,0 +1,349 @@
|
||||
public class XUiC_QuestOfferWindowRebirth : XUiC_QuestOfferWindow
|
||||
{
|
||||
public Quest quest;
|
||||
public XUiV_Sprite prefabPreview;
|
||||
public XUiV_Label Label;
|
||||
public XUiV_Label LabelNumToGo;
|
||||
public XUiV_Panel Panel;
|
||||
public XUiV_Panel PanelHeader;
|
||||
public XUiV_Label LabelBiome;
|
||||
public int windowX = 0;
|
||||
public int windowY = 0;
|
||||
private XUiController btnAccept;
|
||||
private XUiController btnDecline;
|
||||
private XUiV_Button btnAccept_Background;
|
||||
private XUiV_Button btnDecline_Background;
|
||||
private bool btnAcceptHovered;
|
||||
private bool btnDeclineHovered;
|
||||
private bool questAccepted;
|
||||
private Action<EntityNPC> OnCancel;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
if (this.viewComponent != null)
|
||||
{
|
||||
this.viewComponent.InitView();
|
||||
}
|
||||
for (int i = 0; i < this.children.Count; i++)
|
||||
{
|
||||
this.children[i].Init();
|
||||
}
|
||||
|
||||
this.btnAccept = base.GetChildById("btnAccept");
|
||||
this.btnAccept_Background = (XUiV_Button)this.btnAccept.GetChildById("clickable").ViewComponent;
|
||||
this.btnAccept_Background.Controller.OnPress += this.btnAccept_OnPress;
|
||||
this.btnAccept_Background.Controller.OnHover += this.btnAccept_OnHover;
|
||||
this.btnDecline = base.GetChildById("btnDecline");
|
||||
this.btnDecline_Background = (XUiV_Button)this.btnDecline.GetChildById("clickable").ViewComponent;
|
||||
this.btnDecline_Background.Controller.OnPress += this.btnDecline_OnPress;
|
||||
this.btnDecline_Background.Controller.OnHover += this.btnDecline_OnHover;
|
||||
|
||||
//prefabPreview = base.GetChildById("poiPreview").ViewComponent as XUiV_Texture;
|
||||
this.prefabPreview = (XUiV_Sprite)GetChildById("previewImage").ViewComponent;
|
||||
Panel = (XUiV_Panel)GetChildById("content").ViewComponent;
|
||||
Label = (XUiV_Label)Panel.Controller.GetChildById("descriptionText").ViewComponent;
|
||||
PanelHeader = (XUiV_Panel)GetChildById("header").ViewComponent;
|
||||
LabelNumToGo = (XUiV_Label)PanelHeader.Controller.GetChildById("numToGo").ViewComponent;
|
||||
}
|
||||
|
||||
private void btnAccept_OnHover(XUiController _sender, bool _isOver)
|
||||
{
|
||||
this.btnAcceptHovered = _isOver;
|
||||
base.RefreshBindings(false);
|
||||
}
|
||||
|
||||
private void btnDecline_OnHover(XUiController _sender, bool _isOver)
|
||||
{
|
||||
this.btnDeclineHovered = _isOver;
|
||||
base.RefreshBindings(false);
|
||||
}
|
||||
|
||||
private void btnAccept_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
Quest quest = this.Quest;
|
||||
quest.QuestGiverID = this.QuestGiverID;
|
||||
if (this.OfferType == XUiC_QuestOfferWindow.OfferTypes.Item)
|
||||
{
|
||||
ItemStack itemStack = this.ItemStackController.ItemStack;
|
||||
if (itemStack.count > 1)
|
||||
{
|
||||
itemStack.count--;
|
||||
this.ItemStackController.ForceSetItemStack(itemStack.Clone());
|
||||
this.ItemStackController.WindowGroup.Controller.SetAllChildrenDirty(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ItemStackController.ItemStack = ItemStack.Empty.Clone();
|
||||
this.ItemStackController.WindowGroup.Controller.SetAllChildrenDirty(false);
|
||||
}
|
||||
}
|
||||
if (this.QuestGiverID != -1)
|
||||
{
|
||||
base.xui.Dialog.Respondent.PlayVoiceSetEntry("questaccepted", base.xui.playerUI.entityPlayer, true, true);
|
||||
}
|
||||
this.questAccepted = true;
|
||||
base.xui.playerUI.windowManager.Close(base.WindowGroup.ID);
|
||||
base.xui.playerUI.entityPlayer.QuestJournal.AddQuest(quest);
|
||||
}
|
||||
|
||||
private void btnDecline_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
EntityNPC respondent = base.xui.Dialog.Respondent;
|
||||
if (this.QuestGiverID != -1)
|
||||
{
|
||||
base.xui.Dialog.Respondent.PlayVoiceSetEntry("questdeclined", base.xui.playerUI.entityPlayer, true, true);
|
||||
}
|
||||
base.xui.playerUI.windowManager.Close(base.WindowGroup.ID);
|
||||
if (this.OnCancel != null)
|
||||
{
|
||||
this.OnCancel(respondent);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName != null)
|
||||
{
|
||||
if (bindingName == "questname")
|
||||
{
|
||||
string biome = "";
|
||||
|
||||
if (this.Quest != null && !GameUtils.IsPlaytesting())
|
||||
{
|
||||
Vector3 QuestLocation = this.Quest.GetLocation();
|
||||
string biomeName = RebirthUtilities.GetBiomeName(QuestLocation);
|
||||
|
||||
if (biomeName == "wasteland")
|
||||
{
|
||||
biome = "[bd5959]" + Localization.Get("xuiWasteland") + "[-]";
|
||||
}
|
||||
else if (biomeName == "desert")
|
||||
{
|
||||
biome = "[bfbc5a]" + Localization.Get("xuiDesert") + "[-]";
|
||||
}
|
||||
else if (biomeName == "forest" || biomeName == "pine_forest")
|
||||
{
|
||||
biome = "[5fb056]" + Localization.Get("xuiPineForest") + "[-]";
|
||||
}
|
||||
else if (biomeName == "burnt_forest")
|
||||
{
|
||||
biome = "[bf9b5c]" + Localization.Get("xuiBurntForest") + "[-]";
|
||||
}
|
||||
else if (biomeName == "snow")
|
||||
{
|
||||
biome = "[bf9b5c]" + Localization.Get("xuiSnow") + "[-]";
|
||||
}
|
||||
}
|
||||
|
||||
value = ((this.Quest != null) ? this.Quest.GetParsedText(this.Quest.QuestClass.Name) : "");
|
||||
|
||||
if (biome.Trim().Length > 0)
|
||||
{
|
||||
value = value + " (" + biome.Trim() + ")";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "questicon")
|
||||
{
|
||||
value = ((this.Quest != null) ? this.Quest.QuestClass.Icon : "");
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "questoffer")
|
||||
{
|
||||
value = ((this.Quest != null) ? this.Quest.GetParsedText(this.Quest.QuestClass.Offer) : "");
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "questdifficulty")
|
||||
{
|
||||
value = ((this.Quest != null) ? this.Quest.QuestClass.Difficulty : "");
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "windowX")
|
||||
{
|
||||
value = this.windowX.ToString();
|
||||
return true;
|
||||
}
|
||||
else if (bindingName == "windowY")
|
||||
{
|
||||
value = this.windowY.ToString();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
string strPrefabName = "";
|
||||
|
||||
if (this.Quest.QuestPrefab != null)
|
||||
{
|
||||
strPrefabName = base.Quest.QuestPrefab.name;
|
||||
}
|
||||
|
||||
//strPrefabName = base.Quest.QuestPrefab.name; // base.Quest.GetPOIName();
|
||||
|
||||
string[] parts = strPrefabName.Split('.');
|
||||
|
||||
strPrefabName = parts[0];
|
||||
|
||||
string strQuestTags = base.Quest.QuestTags.ToString();
|
||||
|
||||
int questType = 0;
|
||||
|
||||
Entity entity = GameManager.Instance.World.GetEntity(Quest.QuestGiverID);
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (entity is EntityTrader)
|
||||
{
|
||||
EntityTrader entityTrader = (EntityTrader)entity;
|
||||
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen entityTrader.EntityName: " + entityTrader.EntityName);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen entityTrader.EntityClass.entityClassName: " + entityTrader.EntityClass.entityClassName);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen entityTrader.NPCInfo.QuestFaction: " + entityTrader.NPCInfo.QuestFaction);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestsPerTier: " + Quest.QuestsPerTier);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestFactionPoints: " + GameManager.Instance.World.GetPrimaryPlayer().QuestJournal.QuestFactionPoints);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.GetCurrentFactionTier: " + GameManager.Instance.World.GetPrimaryPlayer().QuestJournal.GetCurrentFactionTier(entityTrader.NPCInfo.QuestFaction));
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen GetQuestFactionPoints: " + GameManager.Instance.World.GetPrimaryPlayer().QuestJournal.GetQuestFactionPoints(entityTrader.NPCInfo.QuestFaction));
|
||||
|
||||
int jobsToNextTier = RebirthVariables.customJobsToNextTier;
|
||||
|
||||
int numQuests = jobsToNextTier; // Quest.QuestsPerTier;
|
||||
int questPoints = 0;
|
||||
int questTier = 0;
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
questPoints = primaryPlayer.QuestJournal.GetQuestFactionPoints(entityTrader.NPCInfo.QuestFaction);
|
||||
questTier = primaryPlayer.QuestJournal.GetCurrentFactionTier(entityTrader.NPCInfo.QuestFaction);
|
||||
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen questPoints: " + questPoints);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen questTier: " + questTier);
|
||||
|
||||
int tierPoints = 0;
|
||||
|
||||
for (int i = 1; i <= questTier; i++)
|
||||
{
|
||||
tierPoints = tierPoints + (i * numQuests);
|
||||
}
|
||||
|
||||
int pointsLeft = tierPoints - questPoints;
|
||||
int jobsLeft = pointsLeft / questTier;
|
||||
|
||||
int numPointsLeft = tierPoints - pointsLeft;
|
||||
|
||||
if (pointsLeft > 0 && pointsLeft < questTier)
|
||||
{
|
||||
jobsLeft = 1;
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen pointsLeft: " + pointsLeft);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen tierPoints: " + tierPoints);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen jobsLeft: " + jobsLeft);
|
||||
|
||||
if (questTier < 6)
|
||||
{
|
||||
LabelNumToGo.Text = "[cf8080]" + (int)jobsLeft + "[-] " + Localization.Get("ttTier") + " [d4d483]" + questTier + "[-] " + Localization.Get("ttJobsLeft") + " [8dc987]" + (questTier + 1) + "[-]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.ID: " + base.Quest.ID);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestClass.Name: " + base.Quest.QuestClass.Name);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestClass.ID: " + base.Quest.QuestClass.ID);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Quest.QuestClass.QuestType: " + base.Quest.QuestClass.QuestType);
|
||||
|
||||
for (int i = 0; i < base.Quest.Objectives.Count; i++)
|
||||
{
|
||||
/*//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen ToString(): " + base.Quest.Objectives[i].ToString());
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen ObjectiveValueType: " + base.Quest.Objectives[i].ObjectiveValueType);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen Value: " + base.Quest.Objectives[i].Value);
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen ID: " + base.Quest.Objectives[i].ID);*/
|
||||
if (base.Quest.Objectives[i].ToString() == "ObjectiveTreasureChest")
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 1");
|
||||
questType = 1;
|
||||
strPrefabName = "buried_supplies";
|
||||
}
|
||||
}
|
||||
|
||||
if (base.Quest.ID.ToLower().Contains("challenge_furiousramsaystarter"))
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 1a");
|
||||
questType = 2;
|
||||
strPrefabName = base.Quest.ID.ToLower();
|
||||
}
|
||||
else if (base.Quest.ID.ToLower().Contains("contraband_collection"))
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 1a2");
|
||||
questType = 3;
|
||||
strPrefabName = "ContrabandCollection";
|
||||
}
|
||||
|
||||
Vector2i labelSize = new Vector2i(990, 710);
|
||||
Label.Size = labelSize;
|
||||
|
||||
string ModsBasePath = GameIO.GetUserGameDataDir() + "/Mods";
|
||||
string ModsBasePathLegacy = Application.platform != UnityEngine.RuntimePlatform.OSXPlayer ? (Application.dataPath + "/../Mods") : (Application.dataPath + "/../../Mods");
|
||||
string prefabImagePath = "";
|
||||
|
||||
if (Directory.Exists(ModsBasePathLegacy + "/zzz_REBIRTH__Utils"))
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 3");
|
||||
if (questType == 1)
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 4");
|
||||
prefabImagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/buried_supplies.jpg";
|
||||
}
|
||||
else if (questType == 3)
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 4a");
|
||||
prefabImagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/ContrabandCollection.jpg";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 6");
|
||||
prefabImagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/" + strPrefabName + ".jpg";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 7");
|
||||
if (questType == 1)
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 8");
|
||||
prefabImagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/buried_supplies.jpg";
|
||||
}
|
||||
else if (questType == 3)
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 8a");
|
||||
prefabImagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/ContrabandCollection.jpg";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_QuestOfferWindowRebirth-OnOpen 9");
|
||||
prefabImagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/UIAtlases/UIAtlas/" + strPrefabName + ".jpg";
|
||||
}
|
||||
}
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
this.windowX = 6;
|
||||
this.windowY = -350;
|
||||
}
|
||||
|
||||
prefabPreview.SpriteName = strPrefabName;
|
||||
|
||||
if (!File.Exists(prefabImagePath))
|
||||
{
|
||||
this.windowX = 6;
|
||||
this.windowY = -10;
|
||||
}
|
||||
else
|
||||
{
|
||||
labelSize = new Vector2i(998, 440);
|
||||
Label.Size = labelSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
522
Scripts/XUIC/XUiC_RandomItemRebirth.cs
Normal file
522
Scripts/XUIC/XUiC_RandomItemRebirth.cs
Normal file
@@ -0,0 +1,522 @@
|
||||
using Audio;
|
||||
using static RebirthVariables;
|
||||
using static vp_Timer;
|
||||
|
||||
internal class XUiC_RandomItemRebirth : XUiController
|
||||
{
|
||||
private static float uiCheck = 1f;
|
||||
public float uiTick = 0.5f;
|
||||
public float barterPerc = 0f;
|
||||
public float durabilityThreshold = 0.5f;
|
||||
public float multiplierCash = 3f;
|
||||
public float multiplierBlueprint = 1.5f;
|
||||
public float tierMultiplier = 0.35f;
|
||||
public float barterPercUnit = 0.04f;
|
||||
public bool cannotTrade = false;
|
||||
public ItemValue currentItem = null;
|
||||
|
||||
public XUiV_Label LabelTotal;
|
||||
private XUiC_ComboBoxList<string> cbxRandomWeapon;
|
||||
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
public XUiV_Label lblNameLabel;
|
||||
public XUiV_Label lblName;
|
||||
|
||||
public XUiV_Label lblEntityDamageLabel;
|
||||
public XUiV_Label lblEntityDamage;
|
||||
|
||||
public XUiV_Label lblBlockDamageLabel;
|
||||
public XUiV_Label lblBlockDamage;
|
||||
|
||||
public XUiV_Label lblRoundsPerMinuteLabel;
|
||||
public XUiV_Label lblRoundsPerMinute;
|
||||
|
||||
public XUiV_Label lblAttacksPerMinuteLabel;
|
||||
public XUiV_Label lblAttacksPerMinute;
|
||||
|
||||
public XUiV_Label lblDamageFalloffRangeLabel;
|
||||
public XUiV_Label lblDamageFalloffRange;
|
||||
|
||||
public XUiV_Label lblStaminaLossLabel;
|
||||
public XUiV_Label lblStaminaLoss;
|
||||
|
||||
public XUiV_Label lblMagazineSizeLabel;
|
||||
public XUiV_Label lblMagazineSize;
|
||||
|
||||
public XUiV_Label lblDegradationMaxLabel;
|
||||
public XUiV_Label lblDegradationMax;
|
||||
|
||||
public XUiV_Label lblModSlotsLabel;
|
||||
public XUiV_Label lblModSlots;
|
||||
|
||||
public XUiV_Label lblBonusLabel;
|
||||
public XUiV_Label lblBonus;
|
||||
|
||||
public XUiV_Label lblTotalCash;
|
||||
public XUiV_Label lblTotalBlueprints;
|
||||
|
||||
public XUiV_Label lblPurchaseCost;
|
||||
public XUiV_Label lblRefreshCost;
|
||||
|
||||
public XUiV_Label lblRefreshTime;
|
||||
|
||||
public XUiV_Sprite spriteItemImage;
|
||||
public XUiV_Sprite spriteBonusTypeIcon;
|
||||
public XUiV_Sprite cashImage;
|
||||
public XUiV_Sprite blueprintImage;
|
||||
public XUiV_Sprite refreshImage;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent;
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnPurchase")).OnPressed += BtnPurchase_OnPressed;
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRefresh")).OnPressed += BtnRefresh_OnPressed;
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancel_OnPressed;
|
||||
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
|
||||
lblNameLabel = (XUiV_Label)Panel.Controller.GetChildById("lblNameLabel").ViewComponent;
|
||||
lblName = (XUiV_Label)Panel.Controller.GetChildById("lblName").ViewComponent;
|
||||
|
||||
lblEntityDamageLabel = (XUiV_Label)Panel.Controller.GetChildById("lblEntityDamageLabel").ViewComponent;
|
||||
lblEntityDamage = (XUiV_Label)Panel.Controller.GetChildById("lblEntityDamage").ViewComponent;
|
||||
|
||||
lblBlockDamageLabel = (XUiV_Label)Panel.Controller.GetChildById("lblBlockDamageLabel").ViewComponent;
|
||||
lblBlockDamage = (XUiV_Label)Panel.Controller.GetChildById("lblBlockDamage").ViewComponent;
|
||||
|
||||
lblRoundsPerMinuteLabel = (XUiV_Label)Panel.Controller.GetChildById("lblRoundsPerMinuteLabel").ViewComponent;
|
||||
lblRoundsPerMinute = (XUiV_Label)Panel.Controller.GetChildById("lblRoundsPerMinute").ViewComponent;
|
||||
|
||||
lblAttacksPerMinuteLabel = (XUiV_Label)Panel.Controller.GetChildById("lblAttacksPerMinuteLabel").ViewComponent;
|
||||
lblAttacksPerMinute = (XUiV_Label)Panel.Controller.GetChildById("lblAttacksPerMinute").ViewComponent;
|
||||
|
||||
lblDamageFalloffRangeLabel = (XUiV_Label)Panel.Controller.GetChildById("lblDamageFalloffRangeLabel").ViewComponent;
|
||||
lblDamageFalloffRange = (XUiV_Label)Panel.Controller.GetChildById("lblDamageFalloffRange").ViewComponent;
|
||||
|
||||
lblStaminaLossLabel = (XUiV_Label)Panel.Controller.GetChildById("lblStaminaLossLabel").ViewComponent;
|
||||
lblStaminaLoss = (XUiV_Label)Panel.Controller.GetChildById("lblStaminaLoss").ViewComponent;
|
||||
|
||||
lblMagazineSizeLabel = (XUiV_Label)Panel.Controller.GetChildById("lblMagazineSizeLabel").ViewComponent;
|
||||
lblMagazineSize = (XUiV_Label)Panel.Controller.GetChildById("lblMagazineSize").ViewComponent;
|
||||
|
||||
lblDegradationMaxLabel = (XUiV_Label)Panel.Controller.GetChildById("lblDegradationMaxLabel").ViewComponent;
|
||||
lblDegradationMax = (XUiV_Label)Panel.Controller.GetChildById("lblDegradationMax").ViewComponent;
|
||||
|
||||
lblModSlotsLabel = (XUiV_Label)Panel.Controller.GetChildById("lblModSlotsLabel").ViewComponent;
|
||||
lblModSlots = (XUiV_Label)Panel.Controller.GetChildById("lblModSlots").ViewComponent;
|
||||
|
||||
lblBonusLabel = (XUiV_Label)Panel.Controller.GetChildById("lblBonusLabel").ViewComponent;
|
||||
lblBonus = (XUiV_Label)Panel.Controller.GetChildById("lblBonus").ViewComponent;
|
||||
|
||||
lblTotalCash = (XUiV_Label)Panel.Controller.GetChildById("lblTotalCash").ViewComponent;
|
||||
lblTotalBlueprints = (XUiV_Label)Panel.Controller.GetChildById("lblTotalBlueprints").ViewComponent;
|
||||
|
||||
lblPurchaseCost = (XUiV_Label)Panel.Controller.GetChildById("lblPurchaseCost").ViewComponent;
|
||||
lblRefreshCost = (XUiV_Label)Panel.Controller.GetChildById("lblRefreshCost").ViewComponent;
|
||||
|
||||
lblRefreshTime = (XUiV_Label)Panel.Controller.GetChildById("lblRefreshTime").ViewComponent;
|
||||
|
||||
spriteItemImage = (XUiV_Sprite)GetChildById("itemImage").ViewComponent;
|
||||
spriteBonusTypeIcon = (XUiV_Sprite)GetChildById("bonusTypeIcon").ViewComponent;
|
||||
cashImage = (XUiV_Sprite)GetChildById("CashImage").ViewComponent;
|
||||
blueprintImage = (XUiV_Sprite)GetChildById("BlueprintImage").ViewComponent;
|
||||
refreshImage = (XUiV_Sprite)GetChildById("RefreshImage").ViewComponent;
|
||||
|
||||
this.cbxRandomWeapon = (base.GetChildById("cbxItem") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxRandomWeapon != null)
|
||||
{
|
||||
this.cbxRandomWeapon.OnValueChanged += this.cbxRandomWeapon_OnValueChanged;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
|
||||
lblRefreshTime.Text = Localization.Get("xuiExpiresIn") + ": [c98181]" + RebirthUtilities.GetTimeRemainingMS(RebirthVariables.randomWeaponUpdateTick, RebirthVariables.randomWeaponUpdateCheck) + "[-]";
|
||||
lblRefreshTime.isDirty = true;
|
||||
|
||||
if (RebirthVariables.refreshRandomWeapons)
|
||||
{
|
||||
RebirthVariables.refreshRandomWeapons = false;
|
||||
Reset();
|
||||
updateItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cbxRandomWeapon_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
updateItem();
|
||||
}
|
||||
|
||||
private void updateItem()
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
int questTier = player.QuestJournal.GetCurrentFactionTier((byte)1);
|
||||
|
||||
string purchaseCost = Localization.Get("xuiPurchaseItemExchange");
|
||||
|
||||
currentItem = null;
|
||||
|
||||
if (RebirthVariables.randomWeapons.Count > 0)
|
||||
{
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen cbxRandomWeapon.SelectedIndex:" + cbxRandomWeapon.SelectedIndex);
|
||||
|
||||
RandomWeapon randomWeapon = RebirthVariables.randomWeapons[cbxRandomWeapon.SelectedIndex];
|
||||
|
||||
if (randomWeapon.Weapon != null)
|
||||
{
|
||||
ItemValue itemValue = randomWeapon.Weapon;
|
||||
currentItem = itemValue;
|
||||
|
||||
int entityDamage = (int)EffectManager.GetValue(PassiveEffects.EntityDamage, itemValue);
|
||||
int blockDamage = (int)EffectManager.GetValue(PassiveEffects.BlockDamage, itemValue);
|
||||
int staminaLoss = (int)EffectManager.GetValue(PassiveEffects.StaminaLoss, itemValue);
|
||||
|
||||
if (randomWeapon.Type == WeaponType.Melee)
|
||||
{
|
||||
// MELEE
|
||||
lblRoundsPerMinuteLabel.IsVisible = false;
|
||||
lblRoundsPerMinute.IsVisible = false;
|
||||
lblDamageFalloffRangeLabel.IsVisible = false;
|
||||
lblDamageFalloffRange.IsVisible = false;
|
||||
lblMagazineSizeLabel.IsVisible = false;
|
||||
lblMagazineSize.IsVisible = false;
|
||||
|
||||
lblBlockDamageLabel.IsVisible = true;
|
||||
lblBlockDamage.IsVisible = true;
|
||||
lblAttacksPerMinuteLabel.IsVisible = true;
|
||||
lblAttacksPerMinute.IsVisible = true;
|
||||
lblStaminaLossLabel.IsVisible = true;
|
||||
lblStaminaLoss.IsVisible = true;
|
||||
|
||||
int entityDamagePrimary = (int)EffectManager.GetValue(PassiveEffects.EntityDamage, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("primary"));
|
||||
int entityDamageSecondary = (int)EffectManager.GetValue(PassiveEffects.EntityDamage, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("secondary"));
|
||||
|
||||
if (entityDamagePrimary == 0)
|
||||
{
|
||||
lblEntityDamage.Text = $"{entityDamage}";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entityDamagePrimary == entityDamageSecondary)
|
||||
{
|
||||
lblEntityDamage.Text = $"{entityDamagePrimary}";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblEntityDamage.Text = $"{entityDamagePrimary} ({entityDamageSecondary})";
|
||||
}
|
||||
}
|
||||
|
||||
lblEntityDamage.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen EntityDamage (Primary):" + (int)EffectManager.GetValue(PassiveEffects.EntityDamage, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("primary")));
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen EntityDamage (Secondary):" + (int)EffectManager.GetValue(PassiveEffects.EntityDamage, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("secondary")));
|
||||
|
||||
lblBlockDamageLabel.IsVisible = true;
|
||||
|
||||
int blockDamagePrimary = (int)EffectManager.GetValue(PassiveEffects.BlockDamage, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("primary"));
|
||||
int blockDamageSecondary = (int)EffectManager.GetValue(PassiveEffects.BlockDamage, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("secondary"));
|
||||
|
||||
if (blockDamagePrimary == 0)
|
||||
{
|
||||
lblBlockDamage.Text = $"{blockDamage}";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (blockDamagePrimary == blockDamageSecondary)
|
||||
{
|
||||
lblBlockDamage.Text = $"{blockDamagePrimary}";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblBlockDamage.Text = $"{blockDamagePrimary} ({blockDamageSecondary})";
|
||||
}
|
||||
}
|
||||
lblBlockDamage.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen BlockDamage (Primary):" + blockDamagePrimary);
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen BlockDamage (Secondary):" + blockDamageSecondary);
|
||||
|
||||
lblAttacksPerMinuteLabel.IsVisible = true;
|
||||
lblAttacksPerMinute.Text = $"{(int)EffectManager.GetValue(PassiveEffects.AttacksPerMinute, itemValue)}";
|
||||
lblAttacksPerMinute.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen AttacksPerMinute:" + (int)EffectManager.GetValue(PassiveEffects.AttacksPerMinute, itemValue));
|
||||
|
||||
lblStaminaLossLabel.IsVisible = true;
|
||||
|
||||
int staminaLossPrimary = (int)EffectManager.GetValue(PassiveEffects.StaminaLoss, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("primary"));
|
||||
int staminaLossSecondary = (int)EffectManager.GetValue(PassiveEffects.StaminaLoss, itemValue, 0, player, null, FastTags<TagGroup.Global>.Parse("secondary"));
|
||||
if (staminaLossPrimary == 0)
|
||||
{
|
||||
lblStaminaLoss.Text = $"{staminaLoss}";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (staminaLossPrimary == staminaLossSecondary)
|
||||
{
|
||||
lblStaminaLoss.Text = $"{staminaLossPrimary}";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblStaminaLoss.Text = $"{staminaLossPrimary} ({staminaLossSecondary})";
|
||||
}
|
||||
}
|
||||
lblStaminaLoss.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen StaminaLoss (Primary):" + staminaLossPrimary);
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen StaminaLoss (Secondary):" + staminaLossSecondary);
|
||||
}
|
||||
else if (randomWeapon.Type == WeaponType.Ranged)
|
||||
{
|
||||
// RANGED
|
||||
lblBlockDamageLabel.IsVisible = false;
|
||||
lblBlockDamage.IsVisible = false;
|
||||
lblAttacksPerMinuteLabel.IsVisible = false;
|
||||
lblAttacksPerMinute.IsVisible = false;
|
||||
lblStaminaLossLabel.IsVisible = false;
|
||||
lblStaminaLoss.IsVisible = false;
|
||||
|
||||
lblRoundsPerMinuteLabel.IsVisible = true;
|
||||
lblRoundsPerMinute.IsVisible = true;
|
||||
lblDamageFalloffRangeLabel.IsVisible = true;
|
||||
lblDamageFalloffRange.IsVisible = true;
|
||||
lblMagazineSizeLabel.IsVisible = true;
|
||||
lblMagazineSize.IsVisible = true;
|
||||
|
||||
lblEntityDamage.Text = $"{entityDamage}";
|
||||
lblEntityDamage.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen EntityDamage (Primary):" + entityDamage);
|
||||
|
||||
lblRoundsPerMinuteLabel.IsVisible = true;
|
||||
lblRoundsPerMinute.Text = $"{(int)EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemValue)}";
|
||||
lblRoundsPerMinute.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen RoundsPerMinute:" + (int)EffectManager.GetValue(PassiveEffects.RoundsPerMinute, itemValue));
|
||||
|
||||
lblDamageFalloffRangeLabel.IsVisible = true;
|
||||
lblDamageFalloffRange.Text = $"{(int)EffectManager.GetValue(PassiveEffects.DamageFalloffRange, itemValue)}";
|
||||
lblDamageFalloffRange.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen DamageFalloffRange:" + (int)EffectManager.GetValue(PassiveEffects.DamageFalloffRange, itemValue));
|
||||
|
||||
lblMagazineSizeLabel.IsVisible = true;
|
||||
lblMagazineSize.Text = $"{(int)EffectManager.GetValue(PassiveEffects.MagazineSize, itemValue)}";
|
||||
lblMagazineSize.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen MagazineSize:" + (int)EffectManager.GetValue(PassiveEffects.MagazineSize, itemValue));
|
||||
}
|
||||
|
||||
// COMMON
|
||||
lblName.Text = Localization.Get(itemValue.ItemClass.Name);
|
||||
lblName.IsDirty = true;
|
||||
|
||||
lblDegradationMax.Text = $"{(int)EffectManager.GetValue(PassiveEffects.DegradationMax, itemValue)}";
|
||||
lblDegradationMax.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen DegradationMax:" + (int)EffectManager.GetValue(PassiveEffects.DegradationMax, itemValue));
|
||||
|
||||
lblModSlots.Text = $"{(int)EffectManager.GetValue(PassiveEffects.ModSlots, itemValue)}";
|
||||
lblModSlots.IsDirty = true;
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen ModSlots:" + (int)EffectManager.GetValue(PassiveEffects.ModSlots, itemValue));
|
||||
|
||||
lblBonus.Text = $"{Localization.Get("xui" + (string)itemValue.GetMetadata("bonus"))} [c9c7c7]([-]{Localization.Get("ttLevelFull")} [e0dcab]{(int)itemValue.GetMetadata("level")}[-][c9c7c7])[-]";
|
||||
lblBonus.IsDirty = true;
|
||||
|
||||
spriteItemImage.SpriteName = "ui_game_symbol_" + itemValue.ItemClass.GetIconName();
|
||||
spriteItemImage.IsDirty = true;
|
||||
|
||||
spriteBonusTypeIcon.SpriteName = "ui_game_symbol_" + (string)itemValue.GetMetadata("bonus");
|
||||
spriteBonusTypeIcon.IsDirty = true;
|
||||
|
||||
cannotTrade = false;
|
||||
|
||||
float durability = 1 - itemValue.UseTimes;
|
||||
float multiplier = 1 + ((float)(RebirthUtilities.GetTier(itemValue.ItemClass) * tierMultiplier));
|
||||
|
||||
int numBlueprints = (int)(0.16 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierBlueprint);
|
||||
int cash = (int)(9 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierCash);
|
||||
|
||||
string cashColor = "[ffffff]";
|
||||
string blueprintColor = "[ffffff]";
|
||||
|
||||
string blueprint = RebirthUtilities.GetBlueprint(itemValue.ItemClass);
|
||||
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnOpen blueprint:" + blueprint);
|
||||
|
||||
int totalCash = RebirthUtilities.numItems(ItemClass.GetItem("casinoCoin"), player);
|
||||
int totalBlueprints = RebirthUtilities.numItems(ItemClass.GetItem("geneticBlueprint" + blueprint), player);
|
||||
|
||||
if (totalCash < cash)
|
||||
{
|
||||
cashColor = "[c79595]";
|
||||
cannotTrade = true;
|
||||
}
|
||||
if (totalBlueprints < numBlueprints)
|
||||
{
|
||||
blueprintColor = "[c79595]";
|
||||
cannotTrade = true;
|
||||
}
|
||||
|
||||
lblTotalCash.Text = cashColor + cash.ToString() + "[-]";
|
||||
lblTotalBlueprints.Text = blueprintColor + numBlueprints.ToString() + "[-]";
|
||||
|
||||
if (cannotTrade)
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnPurchase")).Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnPurchase")).Enabled = true;
|
||||
}
|
||||
|
||||
cashImage.spriteName = "ui_game_symbol_oldCash";
|
||||
blueprintImage.spriteName = "ui_game_symbol_FR_Blueprint" + blueprint;
|
||||
blueprintImage.isDirty = true;
|
||||
|
||||
lblPurchaseCost.Text = Localization.Get("xuiPurchaseItemExchange");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lblName.Text = "-";
|
||||
lblEntityDamage.Text = "-";
|
||||
lblBlockDamage.Text = "-";
|
||||
lblAttacksPerMinute.Text = "-";
|
||||
lblStaminaLoss.Text = "-";
|
||||
lblRoundsPerMinute.Text = "-";
|
||||
lblDamageFalloffRange.Text = "-";
|
||||
lblMagazineSize.Text = "-";
|
||||
lblDegradationMax.Text = "-";
|
||||
lblModSlots.Text = "-";
|
||||
lblBonus.Text = "-";
|
||||
|
||||
spriteItemImage.spriteName = "";
|
||||
spriteBonusTypeIcon.spriteName = "";
|
||||
cashImage.spriteName = "";
|
||||
blueprintImage.spriteName = "";
|
||||
|
||||
spriteItemImage.isDirty = true;
|
||||
spriteBonusTypeIcon.isDirty = true;
|
||||
cashImage.isDirty = true;
|
||||
blueprintImage.isDirty = true;
|
||||
|
||||
lblTotalCash.Text = "";
|
||||
lblTotalBlueprints.Text = "";
|
||||
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnPurchase")).Enabled = false;
|
||||
|
||||
lblPurchaseCost.Text = Localization.Get("xuiPurchaseItemNothingExchange");
|
||||
}
|
||||
|
||||
int charismaBlueprints = RebirthUtilities.numItems(ItemClass.GetItem("geneticBlueprintCharisma"), player);
|
||||
|
||||
int multiplierRefresh = (int)(1 + ((questTier - 1) * 0.75));
|
||||
int numCharismaBlueprints = (int)(15 * (1 - barterPerc) * multiplierRefresh);
|
||||
|
||||
if (charismaBlueprints >= numCharismaBlueprints)
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRefresh")).Enabled = true;
|
||||
lblRefreshCost.Text = numCharismaBlueprints.ToString();
|
||||
refreshImage.spriteName = "ui_game_symbol_FR_BlueprintCharisma";
|
||||
refreshImage.isDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRefresh")).Enabled = false;
|
||||
lblRefreshCost.Text = "[c79595]" + numCharismaBlueprints.ToString() + "[-]";
|
||||
refreshImage.spriteName = "ui_game_symbol_FR_BlueprintCharisma";
|
||||
refreshImage.isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
cbxRandomWeapon.Elements.Clear();
|
||||
|
||||
if (RebirthVariables.randomWeapons.Count > 0)
|
||||
{
|
||||
for (int i = 1; i < RebirthVariables.randomWeapons.Count + 1; i++)
|
||||
{
|
||||
this.cbxRandomWeapon.Elements.Add(i.ToString());
|
||||
}
|
||||
|
||||
cbxRandomWeapon.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
float progressionLevel = 0;
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkBetterBarter");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
}
|
||||
|
||||
barterPerc = progressionLevel * barterPercUnit;
|
||||
|
||||
LabelDescription.Text = Localization.Get("xuiItemsToPurchaseDescription").Replace("{0}", ((int)(barterPerc * 100)).ToString() + "%");
|
||||
|
||||
Reset();
|
||||
updateItem();
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_RandomItemRebirth-BtnCancel_OnPressed START");
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnRefresh_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_RandomItemRebirth-BtnRefresh_OnPressed currentTrackedItem.Slot: " + currentTrackedItem.Slot);
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
RebirthUtilities.useInventoryBagItem(player, "geneticBlueprintCharisma", 15);
|
||||
RebirthUtilities.RefreshRandomWeapons((EntityPlayerLocal)player);
|
||||
RebirthVariables.randomWeaponUpdateCheck = Time.time;
|
||||
|
||||
Reset();
|
||||
updateItem();
|
||||
}
|
||||
|
||||
private void BtnPurchase_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_RandomItemRebirth-BtnPurchase_OnPressed currentTrackedItem.Slot: " + currentTrackedItem.Slot);
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
currentItem.SetMetadata("active", 1, TypedMetadataValue.TypeTag.Integer);
|
||||
|
||||
RebirthUtilities.addToPlayerBag(currentItem, player, 1);
|
||||
|
||||
float durability = 1 - currentItem.UseTimes;
|
||||
float multiplier = 1 + ((float)(RebirthUtilities.GetTier(currentItem.ItemClass) * tierMultiplier));
|
||||
|
||||
int numBlueprints = (int)(0.16 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierBlueprint);
|
||||
int cash = (int)(9 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierCash);
|
||||
|
||||
string blueprint = RebirthUtilities.GetBlueprint(currentItem.ItemClass);
|
||||
|
||||
RebirthUtilities.useInventoryBagItem(player, "casinoCoin", cash);
|
||||
RebirthUtilities.useInventoryBagItem(player, "geneticBlueprint" + blueprint, numBlueprints);
|
||||
|
||||
RebirthVariables.randomWeapons.RemoveAt(cbxRandomWeapon.SelectedIndex);
|
||||
Reset();
|
||||
updateItem();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_RandomItemRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
554
Scripts/XUIC/XUiC_RepairItemRebirth.cs
Normal file
554
Scripts/XUIC/XUiC_RepairItemRebirth.cs
Normal file
@@ -0,0 +1,554 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static XUiC_RepairItemRebirth;
|
||||
|
||||
internal class XUiC_RepairItemRebirth : XUiController
|
||||
{
|
||||
public class TrackedItem
|
||||
{
|
||||
public int Index { get; set; }
|
||||
public int Location { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Type { get; set; }
|
||||
public string Icon { get; set; }
|
||||
public string Blueprint { get; set; }
|
||||
public int Slot { get; set; }
|
||||
public float Durability { get; set; }
|
||||
public int DurabilityMax { get; set; }
|
||||
public int Tier { get; set; }
|
||||
public string Bonus { get; set; }
|
||||
public int BonusLevel { get; set; }
|
||||
|
||||
public TrackedItem(int index, int location, string name, int type, string icon, string blueprint, int slot, float durability, int durabilityMax, int tier, string bonus, int bonusLevel)
|
||||
{
|
||||
Location = location;
|
||||
Name = name;
|
||||
Type = type;
|
||||
Icon = icon;
|
||||
Blueprint = blueprint;
|
||||
Index = index;
|
||||
Slot = slot;
|
||||
Durability = durability;
|
||||
DurabilityMax = durabilityMax;
|
||||
Tier = tier;
|
||||
Bonus = bonus;
|
||||
BonusLevel = bonusLevel;
|
||||
}
|
||||
}
|
||||
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
public float barterPerc = 0f;
|
||||
public float durabilityThreshold = 0.5f;
|
||||
public float multiplierCash = 2f;
|
||||
public float multiplierBlueprint = 1f;
|
||||
public float tierMultiplier = 0.35f;
|
||||
public float barterPercUnit = 0.04f;
|
||||
public bool cannotTrade = false;
|
||||
|
||||
public XUiV_Label LabelTotal;
|
||||
private XUiC_ComboBoxList<string> cbxTargetItem;
|
||||
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
public XUiV_Label lblNameLabel;
|
||||
public XUiV_Label lblName;
|
||||
|
||||
public XUiV_Label lblLocationLabel;
|
||||
public XUiV_Label lblLocation;
|
||||
|
||||
public XUiV_Label lblSlotLabel;
|
||||
public XUiV_Label lblSlot;
|
||||
|
||||
public XUiV_Label lblDurabilityLabel;
|
||||
public XUiV_Label lblDurability;
|
||||
|
||||
public XUiV_Label lblDurabilityPercLabel;
|
||||
public XUiV_Label lblDurabilityPerc;
|
||||
|
||||
public XUiV_Label lblTotalCash;
|
||||
public XUiV_Label lblTotalBlueprints;
|
||||
|
||||
public XUiV_Label lblBonusLabel;
|
||||
public XUiV_Label lblBonus;
|
||||
|
||||
public XUiV_Label lblRepairCost;
|
||||
|
||||
public XUiV_Sprite spriteItemImage;
|
||||
public XUiV_Sprite spriteBonusTypeIcon;
|
||||
public XUiV_Sprite cashImage;
|
||||
public XUiV_Sprite blueprintImage;
|
||||
|
||||
private List<TrackedItem> trackedItems = new List<TrackedItem>();
|
||||
private TrackedItem currentTrackedItem;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
Panel = (XUiV_Panel)GetChildById("Popup").ViewComponent;
|
||||
//((XUiC_SimpleButton)Panel.Controller.GetChildById("btnDamage")).OnPressed += BtnDamage_OnPressed;
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRepair")).OnPressed += BtnRepair_OnPressed;
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnCancel")).OnPressed += BtnCancel_OnPressed;
|
||||
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
|
||||
lblNameLabel = (XUiV_Label)Panel.Controller.GetChildById("lblNameLabel").ViewComponent;
|
||||
lblName = (XUiV_Label)Panel.Controller.GetChildById("lblName").ViewComponent;
|
||||
|
||||
lblLocationLabel = (XUiV_Label)Panel.Controller.GetChildById("lblLocationLabel").ViewComponent;
|
||||
lblLocation = (XUiV_Label)Panel.Controller.GetChildById("lblLocation").ViewComponent;
|
||||
|
||||
lblSlotLabel = (XUiV_Label)Panel.Controller.GetChildById("lblSlotLabel").ViewComponent;
|
||||
lblSlot = (XUiV_Label)Panel.Controller.GetChildById("lblSlot").ViewComponent;
|
||||
|
||||
lblDurabilityLabel = (XUiV_Label)Panel.Controller.GetChildById("lblDurabilityLabel").ViewComponent;
|
||||
lblDurability = (XUiV_Label)Panel.Controller.GetChildById("lblDurability").ViewComponent;
|
||||
|
||||
lblDurabilityPercLabel = (XUiV_Label)Panel.Controller.GetChildById("lblDurabilityPercLabel").ViewComponent;
|
||||
lblDurabilityPerc = (XUiV_Label)Panel.Controller.GetChildById("lblDurabilityPerc").ViewComponent;
|
||||
|
||||
lblTotalCash = (XUiV_Label)Panel.Controller.GetChildById("lblTotalCash").ViewComponent;
|
||||
lblTotalBlueprints = (XUiV_Label)Panel.Controller.GetChildById("lblTotalBlueprints").ViewComponent;
|
||||
|
||||
lblBonusLabel = (XUiV_Label)Panel.Controller.GetChildById("lblBonusLabel").ViewComponent;
|
||||
lblBonus = (XUiV_Label)Panel.Controller.GetChildById("lblBonus").ViewComponent;
|
||||
|
||||
lblRepairCost = (XUiV_Label)Panel.Controller.GetChildById("lblRepairCost").ViewComponent;
|
||||
|
||||
spriteItemImage = (XUiV_Sprite)GetChildById("itemImage").ViewComponent;
|
||||
spriteBonusTypeIcon = (XUiV_Sprite)GetChildById("bonusTypeIcon").ViewComponent;
|
||||
cashImage = (XUiV_Sprite)GetChildById("CashImage").ViewComponent;
|
||||
blueprintImage = (XUiV_Sprite)GetChildById("BlueprintImage").ViewComponent;
|
||||
|
||||
this.cbxTargetItem = (base.GetChildById("cbxItem") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxTargetItem != null)
|
||||
{
|
||||
this.cbxTargetItem.OnValueChanged += this.cbxTargetAmmoType_OnValueChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateItem()
|
||||
{
|
||||
bool bEmpty = true;
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
currentTrackedItem = null;
|
||||
|
||||
if (this.cbxTargetItem.Elements.Count > 0)
|
||||
{
|
||||
TrackedItem trackedItem = trackedItems.FirstOrDefault(item => item.Index == int.Parse(cbxTargetItem.Value));
|
||||
if (trackedItem != null)
|
||||
{
|
||||
currentTrackedItem = trackedItem;
|
||||
spriteItemImage.SpriteName = "ui_game_symbol_" + trackedItem.Icon;
|
||||
lblName.Text = Localization.Get(trackedItem.Name);
|
||||
|
||||
string location = "-";
|
||||
|
||||
if (trackedItem.Location == 0)
|
||||
{
|
||||
location = "ttInventory";
|
||||
}
|
||||
else if (trackedItem.Location == 1)
|
||||
{
|
||||
location = "ttBackpack";
|
||||
}
|
||||
else if (trackedItem.Location == 2)
|
||||
{
|
||||
location = "ttCharacter";
|
||||
}
|
||||
|
||||
lblLocation.Text = Localization.Get(location);
|
||||
|
||||
lblSlot.Text = (trackedItem.Slot + 1).ToString();
|
||||
lblDurability.Text = trackedItem.DurabilityMax.ToString();
|
||||
lblDurabilityPerc.Text = RebirthUtilities.FormatPercentage(trackedItem.Durability, 0);
|
||||
|
||||
cashImage.spriteName = "ui_game_symbol_oldCash";
|
||||
blueprintImage.spriteName = "ui_game_symbol_FR_Blueprint" + trackedItem.Blueprint;
|
||||
|
||||
lblTotalCash.text = "";
|
||||
lblTotalBlueprints.Text = "";
|
||||
|
||||
bEmpty = false;
|
||||
}
|
||||
}
|
||||
|
||||
string repairCost = Localization.Get("xuiRepairItemExchange");
|
||||
|
||||
if (bEmpty)
|
||||
{
|
||||
lblName.Text = "-";
|
||||
lblLocation.Text = "-";
|
||||
lblSlot.Text = "-";
|
||||
lblDurability.Text = "-";
|
||||
lblDurabilityPerc.Text = "-";
|
||||
lblBonus.Text = "-";
|
||||
|
||||
spriteItemImage.spriteName = "";
|
||||
spriteBonusTypeIcon.spriteName = "";
|
||||
cashImage.spriteName = "";
|
||||
blueprintImage.spriteName = "";
|
||||
|
||||
cashImage.isDirty = true;
|
||||
blueprintImage.isDirty = true;
|
||||
|
||||
lblTotalCash.Text = "";
|
||||
lblTotalBlueprints.Text = "";
|
||||
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRepair")).Enabled = false;
|
||||
|
||||
repairCost = Localization.Get("xuiRepairItemNothingExchange");
|
||||
}
|
||||
else
|
||||
{
|
||||
cannotTrade = false;
|
||||
|
||||
float durability = 1 - currentTrackedItem.Durability;
|
||||
float multiplier = 1 + ((float)(currentTrackedItem.Tier * tierMultiplier));
|
||||
|
||||
int numBlueprints = (int)(0.16 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierBlueprint);
|
||||
int cash = (int)(9 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierCash);
|
||||
|
||||
string cashColor = "[ffffff]";
|
||||
string blueprintColor = "[ffffff]";
|
||||
|
||||
int totalCash = RebirthUtilities.numItems(ItemClass.GetItem("casinoCoin"), player);
|
||||
int totalBlueprints = RebirthUtilities.numItems(ItemClass.GetItem("geneticBlueprint" + currentTrackedItem.Blueprint), player);
|
||||
|
||||
if (totalCash < cash)
|
||||
{
|
||||
cashColor = "[c79595]";
|
||||
cannotTrade = true;
|
||||
}
|
||||
if (totalBlueprints < numBlueprints)
|
||||
{
|
||||
blueprintColor = "[c79595]";
|
||||
cannotTrade = true;
|
||||
}
|
||||
|
||||
lblTotalCash.Text = cashColor + cash.ToString() + "[-]";
|
||||
lblTotalBlueprints.Text = blueprintColor + numBlueprints.ToString() + "[-]";
|
||||
|
||||
if (cannotTrade)
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRepair")).Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
((XUiC_SimpleButton)Panel.Controller.GetChildById("btnRepair")).Enabled = true;
|
||||
}
|
||||
|
||||
spriteBonusTypeIcon.spriteName = "ui_game_symbol_" + currentTrackedItem.Bonus;
|
||||
|
||||
if (currentTrackedItem.Bonus.Trim().Length > 0)
|
||||
{
|
||||
lblBonus.Text = $"{Localization.Get("xui" + currentTrackedItem.Bonus)} [c9c7c7]([-]{Localization.Get("ttLevelFull")} [e0dcab]{currentTrackedItem.BonusLevel}[-][c9c7c7])[-]";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblBonus.Text = "-";
|
||||
}
|
||||
lblBonus.IsDirty = true;
|
||||
}
|
||||
|
||||
lblRepairCost.Text = repairCost;
|
||||
|
||||
spriteItemImage.isDirty = true;
|
||||
spriteBonusTypeIcon.isDirty = true;
|
||||
cashImage.isDirty = true;
|
||||
blueprintImage.isDirty = true;
|
||||
}
|
||||
|
||||
|
||||
private void cbxTargetAmmoType_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
updateItem();
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
//Log.Out("XUiC_RepairItemRebirth-Update 1");
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
// Reset the tracking list
|
||||
trackedItems.Clear();
|
||||
cbxTargetItem.Elements.Clear();
|
||||
|
||||
int index = 0;
|
||||
|
||||
for (int _idx = 0; _idx < player.inventory.slots.Length - 1; ++_idx)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset A _idx: " + _idx);
|
||||
ItemClass itemClass = ItemClass.GetForId(player.inventory.slots[_idx].itemStack.itemValue.type);
|
||||
ItemStack itemStack = player.inventory.slots[_idx].itemStack;
|
||||
ItemValue itemValue = player.inventory.slots[_idx].itemStack.itemValue;
|
||||
|
||||
if (!itemStack.IsEmpty() &&
|
||||
!itemClass.CanStack()
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset A Name: " + itemClass.Name);
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset A ItemTags: " + itemClass.ItemTags);
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset A itemClass.RepairTools == null: " + (itemClass.RepairTools == null));
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset A itemValue.PercentUsesLeft: " + itemValue.PercentUsesLeft);
|
||||
|
||||
if (itemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("weapon,melee,armor")) &&
|
||||
itemClass.RepairTools == null &&
|
||||
itemValue.PercentUsesLeft < durabilityThreshold)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset A Added: " + itemClass.Name);
|
||||
index++;
|
||||
|
||||
this.cbxTargetItem.Elements.Add(index.ToString());
|
||||
|
||||
int type = RebirthUtilities.GetType(itemClass);
|
||||
int tier = RebirthUtilities.GetTier(itemClass);
|
||||
string blueprint = RebirthUtilities.GetBlueprint(itemClass);
|
||||
string bonus = "";
|
||||
int bonusLevel = 0;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
bonus = (string)itemValue.GetMetadata("bonus");
|
||||
bonusLevel = (int)itemValue.GetMetadata("level");
|
||||
}
|
||||
|
||||
trackedItems.Add(new TrackedItem(index, 0, itemClass.Name, type, itemClass.GetIconName(), blueprint, _idx, itemValue.PercentUsesLeft, itemValue.MaxUseTimes, tier, bonus, bonusLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ItemStack[] itemStackArray = player.bag.GetSlots();
|
||||
for (int _idx = 0; _idx < itemStackArray.Length; ++_idx)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset B _idx: " + _idx);
|
||||
ItemClass itemClass = ItemClass.GetForId(itemStackArray[_idx].itemValue.type);
|
||||
ItemStack itemStack = itemStackArray[_idx];
|
||||
ItemValue itemValue = itemStackArray[_idx].itemValue;
|
||||
|
||||
if (!itemStack.IsEmpty() &&
|
||||
!itemClass.CanStack()
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset B Name: " + itemClass.Name);
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset B ItemTags: " + itemClass.ItemTags);
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset B itemClass.RepairTools == null: " + (itemClass.RepairTools == null));
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset B itemValue.PercentUsesLeft: " + itemValue.PercentUsesLeft);
|
||||
|
||||
if (itemClass.HasAnyTags(FastTags<TagGroup.Global>.Parse("weapon,melee,armor")) &&
|
||||
itemClass.RepairTools == null &&
|
||||
itemValue.PercentUsesLeft < durabilityThreshold
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset B Added: " + itemClass.Name);
|
||||
|
||||
index++;
|
||||
|
||||
this.cbxTargetItem.Elements.Add(index.ToString());
|
||||
|
||||
int type = RebirthUtilities.GetType(itemClass);
|
||||
int tier = RebirthUtilities.GetTier(itemClass);
|
||||
string blueprint = RebirthUtilities.GetBlueprint(itemClass);
|
||||
string bonus = "";
|
||||
int bonusLevel = 0;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
bonus = (string)itemValue.GetMetadata("bonus");
|
||||
bonusLevel = (int)itemValue.GetMetadata("level");
|
||||
}
|
||||
|
||||
trackedItems.Add(new TrackedItem(index, 1, itemClass.Name, type, itemClass.GetIconName(), blueprint, _idx, itemValue.PercentUsesLeft, itemValue.MaxUseTimes, tier, bonus, bonusLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int _idx = 0; _idx < player.equipment.GetSlotCount(); ++_idx)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset C _idx: " + _idx);
|
||||
ItemValue slotItem = player.equipment.GetSlotItem(_idx);
|
||||
if (slotItem != null && slotItem.ItemClass != null && slotItem.ItemClass.SDCSData != null)
|
||||
{
|
||||
ItemClass itemClass = slotItem.ItemClass;
|
||||
ItemValue itemValue = slotItem;
|
||||
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset C Name: " + itemClass.Name);
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset C ItemTags: " + itemClass.ItemTags);
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset C itemClass.RepairTools == null: " + (itemClass.RepairTools == null));
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset C itemValue.PercentUsesLeft: " + itemValue.PercentUsesLeft);
|
||||
|
||||
if (itemValue.PercentUsesLeft < durabilityThreshold)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-Reset C ADDED: " + itemClass.Name);
|
||||
|
||||
index++;
|
||||
|
||||
this.cbxTargetItem.Elements.Add(index.ToString());
|
||||
|
||||
int type = 3;
|
||||
int tier = RebirthUtilities.GetTier(itemClass);
|
||||
string blueprint = RebirthUtilities.GetBlueprint(itemClass);
|
||||
string bonus = "";
|
||||
int bonusLevel = 0;
|
||||
|
||||
if (itemValue != null &&
|
||||
itemValue.HasMetadata("bonus") &&
|
||||
itemValue.HasMetadata("level") &&
|
||||
itemValue.HasMetadata("type") &&
|
||||
itemValue.HasMetadata("active"))
|
||||
{
|
||||
bonus = (string)itemValue.GetMetadata("bonus");
|
||||
bonusLevel = (int)itemValue.GetMetadata("level");
|
||||
}
|
||||
|
||||
// Track the item
|
||||
trackedItems.Add(new TrackedItem(index, 2, itemClass.Name, type, itemClass.GetIconName(), blueprint, _idx, itemValue.PercentUsesLeft, itemValue.MaxUseTimes, tier, bonus, bonusLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*foreach (var item in trackedItems)
|
||||
{
|
||||
Log.Out("XUiC_RepairItemRebirth-Reset item.Name: " + item.Name);
|
||||
Log.Out("XUiC_RepairItemRebirth-Reset item.Index: " + item.Index);
|
||||
Log.Out("XUiC_RepairItemRebirth-Reset item.Location: " + item.Location);
|
||||
Log.Out("XUiC_RepairItemRebirth-Reset item.Icon: " + item.Icon);
|
||||
Log.Out("XUiC_RepairItemRebirth-Reset item.Slot: " + item.Slot);
|
||||
Log.Out("XUiC_RepairItemRebirth-Reset item.Durability: " + item.Durability);
|
||||
}*/
|
||||
|
||||
if (this.cbxTargetItem.Elements.Count > 0)
|
||||
{
|
||||
cbxTargetItem.SelectedIndex = 0;
|
||||
}
|
||||
updateItem();
|
||||
|
||||
float progressionLevel = 0;
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkBetterBarter");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
}
|
||||
|
||||
barterPerc = progressionLevel * barterPercUnit;
|
||||
|
||||
LabelDescription.Text = Localization.Get("xuiItemsToRepairDescription").Replace("{0}", ((int)(barterPerc * 100)).ToString() + "%");
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
Reset();
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-BtnCancel_OnPressed START");
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnRepair_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-BtnRepair_OnPressed currentTrackedItem.Slot: " + currentTrackedItem.Slot);
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
ItemValue itemValue = null;
|
||||
|
||||
if (currentTrackedItem.Location == 0)
|
||||
{
|
||||
itemValue = player.inventory.slots[currentTrackedItem.Slot].itemStack.itemValue;
|
||||
}
|
||||
else if (currentTrackedItem.Location == 1)
|
||||
{
|
||||
ItemStack[] itemStackArray = player.bag.GetSlots();
|
||||
itemValue = itemStackArray[currentTrackedItem.Slot].itemValue;
|
||||
}
|
||||
else if (currentTrackedItem.Location == 2)
|
||||
{
|
||||
itemValue = player.equipment.GetSlotItem(currentTrackedItem.Slot);
|
||||
}
|
||||
|
||||
if (itemValue != null)
|
||||
{
|
||||
itemValue.UseTimes = 0;
|
||||
currentTrackedItem.Durability = 0;
|
||||
|
||||
float durability = 1 - currentTrackedItem.Durability;
|
||||
float multiplier = 1 + ((float)(currentTrackedItem.Tier * tierMultiplier));
|
||||
|
||||
int numBlueprints = (int)(0.16 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierBlueprint);
|
||||
int cash = (int)(9 * (durability * 100 * multiplier) * (1 - barterPerc) * multiplierCash);
|
||||
|
||||
RebirthUtilities.useInventoryBagItem(player, "casinoCoin", cash);
|
||||
RebirthUtilities.useInventoryBagItem(player, "geneticBlueprint" + currentTrackedItem.Blueprint, numBlueprints);
|
||||
|
||||
if (currentTrackedItem.Location == 0)
|
||||
{
|
||||
player.inventory.ForceHoldingItemUpdate();
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnDamage_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
currentTrackedItem.Durability = 0;
|
||||
ItemValue itemValue = null;
|
||||
|
||||
if (currentTrackedItem.Location == 0)
|
||||
{
|
||||
itemValue = player.inventory.slots[currentTrackedItem.Slot].itemStack.itemValue;
|
||||
}
|
||||
else if (currentTrackedItem.Location == 1)
|
||||
{
|
||||
ItemStack[] itemStackArray = player.bag.GetSlots();
|
||||
itemValue = itemStackArray[currentTrackedItem.Slot].itemValue;
|
||||
}
|
||||
else if (currentTrackedItem.Location == 2)
|
||||
{
|
||||
itemValue = player.equipment.GetSlotItem(currentTrackedItem.Slot);
|
||||
}
|
||||
|
||||
if (itemValue != null)
|
||||
{
|
||||
itemValue.UseTimes = itemValue.MaxUseTimes;
|
||||
}
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_RepairItemRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
857
Scripts/XUIC/XUiC_RepairableVehicleStack.cs
Normal file
857
Scripts/XUIC/XUiC_RepairableVehicleStack.cs
Normal file
@@ -0,0 +1,857 @@
|
||||
using Audio;
|
||||
using InControl;
|
||||
using System.Collections.Generic;
|
||||
|
||||
//[Preserve]
|
||||
public class XUiC_RepairableVehicleStack : XUiC_SelectableEntry
|
||||
{
|
||||
private WindowTypeEnum windowType = WindowTypeEnum.None;
|
||||
private ItemStack itemStack = ItemStack.Empty.Clone();
|
||||
public ItemValue itemValue = new ItemValue();
|
||||
private bool isDirty = true;
|
||||
private bool isOver;
|
||||
private Color32 selectedBorderColor = new Color32(222, 206, 163, byte.MaxValue);
|
||||
private Color32 hoverBorderColor = new Color32(182, 166, 123, byte.MaxValue);
|
||||
private Color32 normalBorderColor = new Color32(96, 96, 96, byte.MaxValue);
|
||||
private Color32 normalBackgroundColor = new Color32(96, 96, 96, 96);
|
||||
private bool lastClicked;
|
||||
private string emptySpriteName = "";
|
||||
private string emptyTooltipName = "";
|
||||
private AudioClip pickupSound;
|
||||
public AudioClip placeSound;
|
||||
private RepairableVehicleSlotsEnum repairableVehicleSlots;
|
||||
public int PickupSnapDistance = 4;
|
||||
public static Color32 finalPressedColor = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
|
||||
public static Color32 backgroundColor = new Color32(96, 96, 96, byte.MaxValue);
|
||||
public static Color32 highlightColor = new Color32(222, 206, 163, byte.MaxValue);
|
||||
public Color32 holdingColor = new Color32(byte.MaxValue, 128, 0, byte.MaxValue);
|
||||
private readonly XUiController timer;
|
||||
private XUiController stackValue;
|
||||
private XUiController itemIcon;
|
||||
private XUiController durability;
|
||||
private XUiController durabilityBackground;
|
||||
private XUiController lockTypeIcon;
|
||||
private XUiController tintedOverlay;
|
||||
private XUiController highlightOverlay;
|
||||
private XUiController overlay;
|
||||
private XUiController background;
|
||||
public List<int> SlotIndices = new List<int>();
|
||||
private TweenScale tweenScale;
|
||||
private Vector3 startMousePos = Vector3.zero;
|
||||
|
||||
public RepairableVehicleSlotsEnum RepairableVehicleSlots
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.repairableVehicleSlots;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.repairableVehicleSlots = value;
|
||||
this.SetEmptySpriteNameAndTooltip();
|
||||
}
|
||||
}
|
||||
|
||||
public int SlotNumber
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public event XUiEvent_SlotChangedEventHandler SlotChangedEvent;
|
||||
|
||||
public float HoverIconGrow
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public ItemValue ItemValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.itemValue;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.itemValue != value)
|
||||
{
|
||||
this.itemValue = value;
|
||||
this.itemStack.itemValue = this.itemValue;
|
||||
if (!this.itemStack.itemValue.IsEmpty())
|
||||
{
|
||||
this.itemStack.count = 1;
|
||||
}
|
||||
|
||||
if (value.IsEmpty() && this.Selected)
|
||||
{
|
||||
this.Selected = false;
|
||||
this.InfoWindow?.SetItemStack(null, true);
|
||||
}
|
||||
|
||||
this.SlotChangedEvent?.Invoke(this.SlotNumber, this.itemStack);
|
||||
}
|
||||
|
||||
this.isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack ItemStack
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.itemStack;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (this.itemStack == value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.itemStack = value.Clone();
|
||||
this.ItemValue = this.itemStack.itemValue.Clone();
|
||||
this.isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public XUiC_ItemInfoWindowRebirth InfoWindow
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
public override void SelectedChanged(bool isSelected)
|
||||
{
|
||||
this.SetBorderColor(isSelected ? this.selectedBorderColor : this.normalBorderColor);
|
||||
}
|
||||
|
||||
private void SetBorderColor(Color32 color)
|
||||
{
|
||||
((XUiV_Sprite)this.background.ViewComponent).Color = (Color)color;
|
||||
}
|
||||
|
||||
private void SetEmptySpriteNameAndTooltip()
|
||||
{
|
||||
foreach (RepairableVehicleSlotsEnum key in RebirthVariables.localVehicleParts.Keys)
|
||||
{
|
||||
if (key == this.repairableVehicleSlots)
|
||||
{
|
||||
this.emptySpriteName = RebirthVariables.localVehicleParts[key].emptySpriteName;
|
||||
this.emptyTooltipName = Localization.Get(RebirthVariables.localVehicleParts[key].emptyTooltipName);
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleStack-SetEmptySpriteNameAndTooltip emptySpriteName: " + this.emptySpriteName);
|
||||
//Log.Out("XUiC_RepairableVehicleStack-SetEmptySpriteNameAndTooltip emptyTooltipName: " + this.emptyTooltipName);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.emptyTooltipName == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.emptyTooltipName = this.emptyTooltipName.ToUpper();
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.stackValue = this.GetChildById("stackValue");
|
||||
this.background = this.GetChildById("background");
|
||||
this.SetBorderColor(this.normalBorderColor);
|
||||
this.itemIcon = this.GetChildById("itemIcon");
|
||||
this.durabilityBackground = this.GetChildById("durabilityBackground");
|
||||
this.durability = this.GetChildById("durability");
|
||||
this.tintedOverlay = this.GetChildById("tintedOverlay");
|
||||
this.highlightOverlay = this.GetChildById("highlightOverlay");
|
||||
this.lockTypeIcon = this.GetChildById("lockTypeIcon");
|
||||
this.overlay = this.GetChildById("overlay");
|
||||
this.itemStack.count = 1;
|
||||
this.tweenScale = this.itemIcon.ViewComponent.UiTransform.gameObject.AddComponent<TweenScale>();
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
if (this.WindowGroup.isShowing)
|
||||
{
|
||||
PlayerActionsGUI guiActions = this.xui.playerUI.playerInput.GUIActions;
|
||||
CursorControllerAbs cursorController = this.xui.playerUI.CursorController;
|
||||
Vector3 screenPosition = (Vector3)cursorController.GetScreenPosition();
|
||||
bool mouseButtonUp = cursorController.GetMouseButtonUp(UICamera.MouseButton.LeftButton);
|
||||
bool mouseButtonDown = cursorController.GetMouseButtonDown(UICamera.MouseButton.LeftButton);
|
||||
bool mouseButton = cursorController.GetMouseButton(UICamera.MouseButton.LeftButton);
|
||||
|
||||
if (windowType == WindowTypeEnum.None)
|
||||
{
|
||||
XUiC_VehicleFrameWindowRebirth parentByType = GetParentByType<XUiC_VehicleFrameWindowRebirth>();
|
||||
if (parentByType != null)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update windowType: EntityVehicle");
|
||||
windowType = WindowTypeEnum.EntityVehicle;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update windowType: BlockRepairableVehicle");
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update windowType: BlockRepairableVehicle");
|
||||
windowType = WindowTypeEnum.BlockRepairableVehicle;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isOver && UICamera.hoveredObject == ViewComponent.UiTransform.gameObject && this.ViewComponent.EventOnPress)
|
||||
{
|
||||
////Log.Out("XUiC_RepairableVehicleStack-Update 1");
|
||||
if (guiActions.LastInputType == BindingSourceType.DeviceBindingSource)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 2");
|
||||
bool wasReleased1 = guiActions.Submit.WasReleased;
|
||||
bool wasReleased2 = guiActions.Inspect.WasReleased;
|
||||
bool wasReleased3 = guiActions.RightStick.WasReleased;
|
||||
if (this.xui.dragAndDrop.CurrentStack.IsEmpty() && !this.ItemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 3");
|
||||
if (wasReleased1)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 4");
|
||||
this.SwapItem();
|
||||
}
|
||||
else if (wasReleased3)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 5");
|
||||
this.HandleMoveToPreferredLocation();
|
||||
}
|
||||
else if (wasReleased2)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 6");
|
||||
this.HandleItemInspect();
|
||||
}
|
||||
|
||||
if (this.itemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 7");
|
||||
((XUiV_Sprite)this.background.ViewComponent).Color = (Color)XUiC_RepairableVehicleStack.backgroundColor;
|
||||
}
|
||||
}
|
||||
else if (wasReleased1)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 8");
|
||||
this.HandleStackSwap();
|
||||
}
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 9");
|
||||
if (mouseButtonUp)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 0");
|
||||
this.HandleMoveToPreferredLocation();
|
||||
}
|
||||
}
|
||||
else if (mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 10");
|
||||
if (this.xui.dragAndDrop.CurrentStack.IsEmpty() && !this.ItemStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 11");
|
||||
if (!this.lastClicked)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 12");
|
||||
this.startMousePos = screenPosition;
|
||||
}
|
||||
else if ((double)Mathf.Abs((screenPosition - this.startMousePos).magnitude) > PickupSnapDistance)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 13");
|
||||
this.SwapItem();
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 14");
|
||||
this.SetBorderColor(this.normalBorderColor);
|
||||
}
|
||||
|
||||
if (mouseButtonDown)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 15");
|
||||
this.lastClicked = true;
|
||||
}
|
||||
}
|
||||
else if (mouseButtonUp)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 16");
|
||||
if (this.xui.dragAndDrop.CurrentStack.IsEmpty())
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 17");
|
||||
this.HandleItemInspect();
|
||||
}
|
||||
else if (this.lastClicked)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-Update 18");
|
||||
this.HandleStackSwap();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
////Log.Out("XUiC_RepairableVehicleStack-Update 19");
|
||||
this.lastClicked = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastClicked = false;
|
||||
if (this.isOver || this.itemIcon.ViewComponent.UiTransform.localScale != Vector3.one)
|
||||
{
|
||||
if (this.tweenScale.value != Vector3.one && !this.itemStack.IsEmpty())
|
||||
{
|
||||
this.tweenScale.from = Vector3.one * 1.5f;
|
||||
this.tweenScale.to = Vector3.one;
|
||||
this.tweenScale.enabled = true;
|
||||
this.tweenScale.duration = 0.5f;
|
||||
}
|
||||
|
||||
this.isOver = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.isDirty)
|
||||
{
|
||||
bool flag = !this.itemValue.IsEmpty();
|
||||
ItemClass itemClass = null;
|
||||
if (flag)
|
||||
{
|
||||
itemClass = ItemClass.GetForId(this.itemValue.type);
|
||||
}
|
||||
|
||||
if (this.itemIcon != null)
|
||||
{
|
||||
((XUiV_Sprite)this.itemIcon.ViewComponent).SpriteName = flag ? this.itemStack.itemValue.GetPropertyOverride("CustomIcon", itemClass.GetIconName()) : this.emptySpriteName;
|
||||
((XUiV_Sprite)this.itemIcon.ViewComponent).UIAtlas = flag ? "ItemIconAtlas" : "ItemIconAtlasGreyscale";
|
||||
((XUiV_Sprite)this.itemIcon.ViewComponent).Color = flag ? Color.white : new Color(1f, 1f, 1f, 0.7f);
|
||||
string str = string.Empty;
|
||||
if (flag)
|
||||
{
|
||||
str = itemClass.GetLocalizedItemName();
|
||||
}
|
||||
|
||||
this.ViewComponent.ToolTip = flag ? str : this.emptyTooltipName;
|
||||
}
|
||||
|
||||
if (itemClass != null)
|
||||
{
|
||||
((XUiV_Sprite)this.itemIcon.ViewComponent).Color = this.itemStack.itemValue.ItemClass.GetIconTint(this.itemStack.itemValue);
|
||||
if (itemClass.ShowQualityBar)
|
||||
{
|
||||
if (this.durability != null)
|
||||
{
|
||||
this.durability.ViewComponent.IsVisible = true;
|
||||
this.durabilityBackground.ViewComponent.IsVisible = true;
|
||||
XUiV_Sprite viewComponent = (XUiV_Sprite)this.durability.ViewComponent;
|
||||
viewComponent.Color = QualityInfo.GetQualityColor(this.itemValue.Quality);
|
||||
viewComponent.Fill = this.itemValue.PercentUsesLeft;
|
||||
}
|
||||
|
||||
if (this.stackValue != null)
|
||||
{
|
||||
XUiV_Label viewComponent = (XUiV_Label)this.stackValue.ViewComponent;
|
||||
viewComponent.Alignment = NGUIText.Alignment.Center;
|
||||
viewComponent.Text = this.itemStack.itemValue.Quality > 0 ? this.itemStack.itemValue.Quality.ToString() : (this.itemStack.itemValue.IsMod ? "*" : "");
|
||||
}
|
||||
}
|
||||
else if (this.durability != null)
|
||||
{
|
||||
this.durability.ViewComponent.IsVisible = false;
|
||||
this.durabilityBackground.ViewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
if (this.lockTypeIcon != null)
|
||||
{
|
||||
if (this.itemStack.itemValue.HasMods())
|
||||
{
|
||||
(this.lockTypeIcon.ViewComponent as XUiV_Sprite).SpriteName = "ui_game_symbol_modded";
|
||||
}
|
||||
else
|
||||
{
|
||||
(this.lockTypeIcon.ViewComponent as XUiV_Sprite).SpriteName = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.durability != null)
|
||||
{
|
||||
this.durability.ViewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
if (this.durabilityBackground != null)
|
||||
{
|
||||
this.durabilityBackground.ViewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
if (this.stackValue != null)
|
||||
{
|
||||
((XUiV_Label)this.stackValue.ViewComponent).Text = "";
|
||||
}
|
||||
|
||||
if (this.lockTypeIcon != null)
|
||||
{
|
||||
(this.lockTypeIcon.ViewComponent as XUiV_Sprite).SpriteName = "";
|
||||
}
|
||||
}
|
||||
|
||||
this.isDirty = false;
|
||||
}
|
||||
|
||||
((XUiV_Label)this.stackValue.ViewComponent).Alignment = this.itemStack.itemValue.HasQuality || this.itemStack.itemValue.Modifications.Length != 0 ? NGUIText.Alignment.Center : NGUIText.Alignment.Right;
|
||||
}
|
||||
|
||||
private void HandleItemInspect()
|
||||
{
|
||||
if (!this.ItemStack.IsEmpty() && this.InfoWindow != null)
|
||||
{
|
||||
this.Selected = true;
|
||||
this.InfoWindow.SetItemStack(this, true);
|
||||
}
|
||||
|
||||
this.HandleClickComplete();
|
||||
}
|
||||
|
||||
private void HandleStackSwap()
|
||||
{
|
||||
//Log.Out("StackTrace: '{0}'", Environment.StackTrace);
|
||||
//Log.Out("XUiC_RepairableVehicleStack-HandleStackSwap START");
|
||||
ItemClass itemClass = this.xui.dragAndDrop.CurrentStack.itemValue.ItemClass;
|
||||
if (itemClass == null)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-HandleStackSwap 1");
|
||||
return;
|
||||
}
|
||||
|
||||
RepairableVehicleSlotsEnum slotEnum = RepairableVehicleSlotsEnum.None;
|
||||
if (itemClass.Properties.Values.ContainsKey("VehicleSlot"))
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-HandleStackSwap 2");
|
||||
slotEnum = (RepairableVehicleSlotsEnum)Enum.Parse(typeof(RepairableVehicleSlotsEnum), itemClass.Properties.Values["VehicleSlot"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-HandleStackSwap 3");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int index = 0; index < this.SlotIndices.Count; ++index)
|
||||
{
|
||||
if (RepairableVehicleSlots == slotEnum)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-HandleStackSwap 4");
|
||||
this.SwapItem();
|
||||
this.Selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.Selected = false;
|
||||
this.HandleClickComplete();
|
||||
}
|
||||
|
||||
private void HandleClickComplete()
|
||||
{
|
||||
this.lastClicked = false;
|
||||
if (!this.itemValue.IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.SetBorderColor(this.normalBorderColor);
|
||||
}
|
||||
|
||||
public override void OnHovered(bool _isOver)
|
||||
{
|
||||
this.isOver = _isOver;
|
||||
if (_isOver)
|
||||
{
|
||||
if (!this.Selected)
|
||||
{
|
||||
this.SetBorderColor(this.hoverBorderColor);
|
||||
}
|
||||
|
||||
if (!this.itemStack.IsEmpty())
|
||||
{
|
||||
this.tweenScale.from = Vector3.one;
|
||||
this.tweenScale.to = Vector3.one * 1.5f;
|
||||
this.tweenScale.enabled = true;
|
||||
this.tweenScale.duration = 0.5f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.Selected)
|
||||
{
|
||||
this.SetBorderColor(this.normalBorderColor);
|
||||
}
|
||||
|
||||
this.tweenScale.from = Vector3.one * 1.5f;
|
||||
this.tweenScale.to = Vector3.one;
|
||||
this.tweenScale.enabled = true;
|
||||
this.tweenScale.duration = 0.5f;
|
||||
}
|
||||
|
||||
if (!_isOver && this.tweenScale.value != Vector3.one && !this.itemStack.IsEmpty())
|
||||
{
|
||||
this.tweenScale.from = Vector3.one * 1.5f;
|
||||
this.tweenScale.to = Vector3.one;
|
||||
this.tweenScale.enabled = true;
|
||||
this.tweenScale.duration = 0.5f;
|
||||
}
|
||||
|
||||
base.OnHovered(_isOver);
|
||||
}
|
||||
|
||||
private void SwapItem()
|
||||
{
|
||||
ItemStack currentStack = this.xui.dragAndDrop.CurrentStack;
|
||||
|
||||
if (this.itemStack.IsEmpty())
|
||||
{
|
||||
if (placeSound != null)
|
||||
{
|
||||
Manager.PlayXUiSound(this.placeSound, 0.75f);
|
||||
}
|
||||
}
|
||||
else if (pickupSound != null)
|
||||
{
|
||||
Manager.PlayXUiSound(this.pickupSound, 0.75f);
|
||||
}
|
||||
|
||||
this.xui.dragAndDrop.CurrentStack = this.itemStack.Clone();
|
||||
this.ItemStack = currentStack.Clone();
|
||||
if (this.SlotChangedEvent == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.SlotChangedEvent(this.SlotNumber, this.itemStack);
|
||||
|
||||
ItemValue[] TEItems = null;
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleStack-SwapItem windowType: " + windowType);
|
||||
|
||||
if (windowType == WindowTypeEnum.BlockRepairableVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-SwapItem BlockRepairableVehicle");
|
||||
|
||||
TileEntityDriveableLootContainer tileEntity = GetParentByType<XUiC_RepairableVehicleWindow>().tileEntity;
|
||||
TEItems = tileEntity.GetRepairableVehicleParts();
|
||||
|
||||
TEItems[SlotNumber] = ItemStack.itemValue;
|
||||
tileEntity.SetRepairableVehicleParts(TEItems);
|
||||
|
||||
float increase = 0;
|
||||
|
||||
List<RepairableVehicleSlotsEnum> itemValueEnums = RebirthVariables.localVehicleTypes[tileEntity.blockValue.Block.Properties.Values["VehicleType"]];
|
||||
|
||||
string itemName = "";
|
||||
|
||||
foreach (ItemValue item in TEItems)
|
||||
{
|
||||
if (item.type != ItemValue.None.type)
|
||||
{
|
||||
itemName = item.ItemClass.GetItemName();
|
||||
foreach (RepairableVehicleSlotsEnum part in itemValueEnums)
|
||||
{
|
||||
if (RebirthVariables.localVehicleParts[part].itemName == itemName)
|
||||
{
|
||||
//increase += ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes) * RebirthVariables.localVehicleParts[part].durabilityPerQuality * item.Quality;
|
||||
/*//Log.Out("XUiC_RepairableVehicleWindow-SwapItem itemName: " + itemName);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem PercUsed: " + ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes));
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem Quality: " + item.Quality);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem durabilityPerQuality: " + RebirthVariables.localVehicleParts[part].durabilityPerQuality);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem durability: " + durability);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tileEntity.Durability = tileEntity.baseDurability + increase;
|
||||
tileEntity.vehicleHealth = tileEntity.baseVehicleHealth + increase;
|
||||
|
||||
tileEntity.SetModified();
|
||||
|
||||
XUiC_RepairableVehicleWindow window = GetParentByType<XUiC_RepairableVehicleWindow>();
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
window.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
else if (windowType == WindowTypeEnum.EntityVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleStack-SwapItem EntityVehicle");
|
||||
|
||||
EntityVehicleRebirth vehicle = GetParentByType<XUiC_VehicleFrameWindowRebirth>().Vehicle;
|
||||
TEItems = vehicle.itemValues;
|
||||
|
||||
ItemValue tempItemValue = TEItems[SlotNumber];
|
||||
|
||||
TEItems[SlotNumber] = ItemStack.itemValue;
|
||||
vehicle.itemValues = TEItems;
|
||||
|
||||
float increase = 0;
|
||||
string itemName = "";
|
||||
|
||||
List<RepairableVehicleSlotsEnum> itemValueEnums = RebirthVariables.localVehicleTypes[vehicle.EntityClass.Properties.Values["VehicleType"]];
|
||||
|
||||
foreach (ItemValue item in TEItems)
|
||||
{
|
||||
if (item.type != ItemValue.None.type)
|
||||
{
|
||||
itemName = item.ItemClass.GetItemName();
|
||||
foreach (RepairableVehicleSlotsEnum part in itemValueEnums)
|
||||
{
|
||||
if (RebirthVariables.localVehicleParts[part].itemName == itemName)
|
||||
{
|
||||
//increase += ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes) * RebirthVariables.localVehicleParts[part].durabilityPerQuality * item.Quality;
|
||||
/*//Log.Out("XUiC_RepairableVehicleWindow-SwapItem itemName: " + itemName);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem PercUsed: " + ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes));
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem Quality: " + item.Quality);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem durabilityPerQuality: " + RebirthVariables.localVehicleParts[part].durabilityPerQuality);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem durability: " + durability);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float change = 0;
|
||||
|
||||
if (this.itemStack.IsEmpty())
|
||||
{
|
||||
itemName = tempItemValue.ItemClass.GetItemName();
|
||||
foreach (RepairableVehicleSlotsEnum part in itemValueEnums)
|
||||
{
|
||||
if (RebirthVariables.localVehicleParts[part].itemName == itemName)
|
||||
{
|
||||
//change = ((tempItemValue.MaxUseTimes - tempItemValue.UseTimes) / tempItemValue.MaxUseTimes) * RebirthVariables.localVehicleParts[part].durabilityPerQuality * tempItemValue.Quality;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vehicle.Health = vehicle.Health - (int)change;
|
||||
vehicle.maxBodyDurability = vehicle.maxBodyDurability - (int)change;
|
||||
vehicle.bodyDurability = vehicle.bodyDurability - (int)change;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("ItemStack: " + ItemStack.itemValue.ItemClass.GetItemName());
|
||||
|
||||
itemName = this.itemStack.itemValue.ItemClass.GetItemName();
|
||||
foreach (RepairableVehicleSlotsEnum part in itemValueEnums)
|
||||
{
|
||||
if (RebirthVariables.localVehicleParts[part].itemName == itemName)
|
||||
{
|
||||
//change = ((this.itemStack.itemValue.MaxUseTimes - this.itemStack.itemValue.UseTimes) / this.itemStack.itemValue.MaxUseTimes) * RebirthVariables.localVehicleParts[part].durabilityPerQuality * this.itemStack.itemValue.Quality;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vehicle.Health = vehicle.Health + (int)change;
|
||||
vehicle.maxBodyDurability = vehicle.maxBodyDurability + (int)change;
|
||||
vehicle.bodyDurability = vehicle.bodyDurability + (int)change;
|
||||
}
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
int playerID = this.xui.playerUI.entityPlayer.entityId;
|
||||
int currentVehicleID = vehicle.entityId;
|
||||
float currentItemUseTimes = this.itemStack.itemValue.UseTimes;
|
||||
string currentItemName = "";
|
||||
|
||||
if (this.itemStack.itemValue.type != ItemValue.None.type)
|
||||
{
|
||||
currentItemName = this.itemStack.itemValue.ItemClass.GetItemName();
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem currentItemName: " + currentItemName);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem Degradation: " + currentItemUseTimes + "/" + this.itemStack.itemValue.MaxUseTimes);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem Quality: " + this.itemStack.itemValue.Quality);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem SlotNumber: " + SlotNumber);
|
||||
|
||||
NetPackageVehicleUpdatePartRebirth package = NetPackageManager.GetPackage<NetPackageVehicleUpdatePartRebirth>().Setup(playerID, currentVehicleID, SlotNumber, currentItemUseTimes, this.itemStack.itemValue.Quality, currentItemName);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem vehicle.baseBodyDurability: " + vehicle.baseBodyDurability);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem vehicle.bodyDurability: " + vehicle.bodyDurability);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem increase: " + increase);
|
||||
|
||||
XUiC_VehicleFrameWindowRebirth window = GetParentByType<XUiC_VehicleFrameWindowRebirth>();
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
window.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleMoveToPreferredLocation()
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation START");
|
||||
ItemValue[] TEItems = null;
|
||||
|
||||
ItemStack _itemStack = this.ItemStack.Clone();
|
||||
if (this.xui.PlayerInventory.AddItemToBackpack(_itemStack))
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 1");
|
||||
this.ItemValue = ItemStack.Empty.itemValue.Clone();
|
||||
if (placeSound != null)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 2");
|
||||
Manager.PlayXUiSound(this.placeSound, 0.75f);
|
||||
}
|
||||
|
||||
this.SlotChangedEvent?.Invoke(this.SlotNumber, this.itemStack);
|
||||
|
||||
if (windowType == WindowTypeEnum.BlockRepairableVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 3");
|
||||
TileEntityDriveableLootContainer tileEntity = GetParentByType<XUiC_RepairableVehicleWindow>().tileEntity;
|
||||
TEItems = tileEntity.GetRepairableVehicleParts();
|
||||
TEItems[SlotNumber] = this.itemValue;
|
||||
tileEntity.SetRepairableVehicleParts(TEItems);
|
||||
tileEntity.SetModified();
|
||||
this.ItemStack = ItemStack.Empty;
|
||||
|
||||
|
||||
}
|
||||
else if (windowType == WindowTypeEnum.EntityVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 4");
|
||||
EntityVehicleRebirth vehicle = GetParentByType<XUiC_VehicleFrameWindowRebirth>().Vehicle;
|
||||
TEItems = vehicle.itemValues;
|
||||
TEItems[SlotNumber] = ItemStack.itemValue;
|
||||
vehicle.itemValues = TEItems;
|
||||
this.ItemStack = ItemStack.Empty;
|
||||
|
||||
if (!this.itemStack.IsEmpty() || !this.Selected)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 5");
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
int playerID = this.xui.playerUI.entityPlayer.entityId;
|
||||
int currentVehicleID = vehicle.entityId;
|
||||
float currentItemUseTimes = this.itemStack.itemValue.UseTimes;
|
||||
string currentItemName = "";
|
||||
|
||||
if (this.itemStack.itemValue.type != ItemValue.None.type)
|
||||
{
|
||||
currentItemName = this.itemStack.itemValue.ItemClass.GetItemName();
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem currentItemName: " + currentItemName);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem Degradation: " + currentItemUseTimes + "/" + this.itemStack.itemValue.MaxUseTimes);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem Quality: " + this.itemStack.itemValue.Quality);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SwapItem SlotNumber: " + SlotNumber);
|
||||
|
||||
NetPackageVehicleUpdatePartRebirth package = NetPackageManager.GetPackage<NetPackageVehicleUpdatePartRebirth>().Setup(playerID, currentVehicleID, SlotNumber, currentItemUseTimes, this.itemStack.itemValue.Quality, currentItemName);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.Selected = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.xui.PlayerInventory.AddItemToToolbelt(_itemStack))
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 6");
|
||||
return;
|
||||
}
|
||||
|
||||
this.ItemValue = ItemStack.Empty.itemValue.Clone();
|
||||
if (placeSound != null)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 7");
|
||||
Manager.PlayXUiSound(this.placeSound, 0.75f);
|
||||
}
|
||||
|
||||
this.SlotChangedEvent?.Invoke(this.SlotNumber, this.itemStack);
|
||||
|
||||
if (windowType == WindowTypeEnum.BlockRepairableVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 8");
|
||||
TileEntityDriveableLootContainer tileEntity = GetParentByType<XUiC_RepairableVehicleWindow>().tileEntity;
|
||||
TEItems = tileEntity.GetRepairableVehicleParts();
|
||||
TEItems[SlotNumber] = ItemValue;
|
||||
tileEntity.SetRepairableVehicleParts(TEItems);
|
||||
tileEntity.SetModified();
|
||||
}
|
||||
else if (windowType == WindowTypeEnum.EntityVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 9");
|
||||
EntityVehicleRebirth vehicle = GetParentByType<XUiC_VehicleFrameWindowRebirth>().Vehicle;
|
||||
TEItems = vehicle.itemValues;
|
||||
TEItems[SlotNumber] = ItemStack.itemValue;
|
||||
vehicle.itemValues = TEItems;
|
||||
}
|
||||
|
||||
if (!this.itemStack.IsEmpty() || !this.Selected)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-HandleMoveToPreferredLocation 10");
|
||||
return;
|
||||
}
|
||||
|
||||
this.Selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseAttribute(string name, string value, XUiController _parent)
|
||||
{
|
||||
bool attribute = base.ParseAttribute(name, value, _parent);
|
||||
if (attribute)
|
||||
{
|
||||
return attribute;
|
||||
}
|
||||
|
||||
switch (name)
|
||||
{
|
||||
case "hover_border_color":
|
||||
this.hoverBorderColor = (Color32)StringParsers.ParseColor32(value);
|
||||
break;
|
||||
case "hover_icon_grow":
|
||||
this.HoverIconGrow = StringParsers.ParseFloat(value);
|
||||
break;
|
||||
case "normal_background_color":
|
||||
XUiC_RepairableVehicleStack.finalPressedColor = (Color32)StringParsers.ParseColor32(value);
|
||||
break;
|
||||
case "normal_border_color":
|
||||
this.normalBorderColor = (Color32)StringParsers.ParseColor32(value);
|
||||
break;
|
||||
case "normal_color":
|
||||
this.normalBackgroundColor = (Color32)StringParsers.ParseColor32(value);
|
||||
break;
|
||||
case "pickup_sound":
|
||||
this.xui.LoadData<AudioClip>(value, o => this.pickupSound = o);
|
||||
break;
|
||||
case "place_sound":
|
||||
this.xui.LoadData<AudioClip>(value, o => this.placeSound = o);
|
||||
break;
|
||||
case "selected_border_color":
|
||||
this.selectedBorderColor = (Color32)StringParsers.ParseColor32(value);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
this.isDirty = true;
|
||||
}
|
||||
}
|
||||
237
Scripts/XUIC/XUiC_RepairableVehicleStackGrid.cs
Normal file
237
Scripts/XUIC/XUiC_RepairableVehicleStackGrid.cs
Normal file
@@ -0,0 +1,237 @@
|
||||
using System.Collections.Generic;
|
||||
using PreserveAttribute = UnityEngine.Scripting.PreserveAttribute;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_RepairableVehicleStackGrid : XUiController
|
||||
{
|
||||
private WindowTypeEnum windowType = WindowTypeEnum.None;
|
||||
protected XUiController[] itemControllers;
|
||||
public ItemValue[] items;
|
||||
public readonly List<XUiC_RepairableVehicleStack> RepairableVehiclePartsList = new List<XUiC_RepairableVehicleStack>();
|
||||
private readonly bool slotsSetup;
|
||||
private bool bAwakeCalled;
|
||||
private XUiV_Grid slotGrid;
|
||||
|
||||
private readonly ItemValue[] m_slots = new ItemValue[32];
|
||||
public bool SetSlotItem(int index, ItemValue value, bool isLocal = true)
|
||||
{
|
||||
bool flag = false;
|
||||
this.m_slots[index] = value;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.itemControllers = this.Parent.GetChildrenByType<XUiC_RepairableVehicleStack>();
|
||||
this.slotGrid = base.Parent.GetChildById("slotGrid").ViewComponent as XUiV_Grid;
|
||||
this.bAwakeCalled = true;
|
||||
this.IsDirty = false;
|
||||
}
|
||||
|
||||
public void SetSlotIndexForStack(int slot, RepairableVehicleSlotsEnum repairableVehicleSlots)
|
||||
{
|
||||
if (itemControllers[slot] is XUiC_RepairableVehicleStack && itemControllers[slot] != null)
|
||||
{
|
||||
XUiC_RepairableVehicleStack itemController = itemControllers[slot] as XUiC_RepairableVehicleStack;
|
||||
|
||||
itemController.SlotIndices.Clear();
|
||||
itemController.SlotIndices.Add((int)repairableVehicleSlots);
|
||||
|
||||
itemController.RepairableVehicleSlots = repairableVehicleSlots;
|
||||
this.RepairableVehiclePartsList.Add(itemController);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
if (GameManager.Instance == null || GameManager.Instance.World == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.IsDirty)
|
||||
{
|
||||
if (!this.slotsSetup)
|
||||
{
|
||||
if (windowType == WindowTypeEnum.None)
|
||||
{
|
||||
XUiC_VehicleFrameWindowRebirth parentByType = GetParentByType<XUiC_VehicleFrameWindowRebirth>();
|
||||
if (parentByType != null)
|
||||
{
|
||||
windowType = WindowTypeEnum.EntityVehicle;
|
||||
}
|
||||
else
|
||||
{
|
||||
windowType = WindowTypeEnum.BlockRepairableVehicle;
|
||||
}
|
||||
}
|
||||
|
||||
if (windowType == WindowTypeEnum.BlockRepairableVehicle)
|
||||
{
|
||||
XUiC_RepairableVehicleWindow parentByType = GetParentByType<XUiC_RepairableVehicleWindow>();
|
||||
|
||||
if (parentByType != null)
|
||||
{
|
||||
if (parentByType.tileEntity != null)
|
||||
{
|
||||
string vehicleType = "V6CarRepair";
|
||||
if (parentByType.tileEntity.blockValue.Block.Properties.Values.ContainsKey("VehicleType"))
|
||||
{
|
||||
vehicleType = parentByType.tileEntity.blockValue.Block.Properties.Values["VehicleType"];
|
||||
}
|
||||
|
||||
foreach (string vehicleTypeKey in RebirthVariables.localVehicleTypes.Keys)
|
||||
{
|
||||
if (vehicleTypeKey == vehicleType)
|
||||
{
|
||||
List<RepairableVehicleSlotsEnum> partsList = RebirthVariables.localVehicleTypes[vehicleTypeKey];
|
||||
|
||||
for (int i = 0; i < partsList.Count; i++)
|
||||
{
|
||||
SetSlotIndexForStack(i, partsList[i]);
|
||||
}
|
||||
|
||||
this.items = this.GetSlots();
|
||||
this.SetStacks(this.items);
|
||||
this.IsDirty = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (windowType == WindowTypeEnum.EntityVehicle)
|
||||
{
|
||||
XUiC_VehicleFrameWindowRebirth parentByType = GetParentByType<XUiC_VehicleFrameWindowRebirth>();
|
||||
if (parentByType != null)
|
||||
{
|
||||
string vehicleType = "V6CarRepair";
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleStackGrid-Update this.itemControllers.Length: " + this.itemControllers.Length);
|
||||
|
||||
if (parentByType.Vehicle.EntityClass.Properties.Values.ContainsKey("VehicleType"))
|
||||
{
|
||||
vehicleType = parentByType.Vehicle.EntityClass.Properties.Values["VehicleType"];
|
||||
}
|
||||
|
||||
foreach (string vehicleTypeKey in RebirthVariables.localVehicleTypes.Keys)
|
||||
{
|
||||
if (vehicleTypeKey == vehicleType)
|
||||
{
|
||||
List<RepairableVehicleSlotsEnum> partsList = RebirthVariables.localVehicleTypes[vehicleTypeKey];
|
||||
|
||||
for (int i = 0; i < partsList.Count; i++)
|
||||
{
|
||||
SetSlotIndexForStack(i, partsList[i]);
|
||||
}
|
||||
|
||||
this.items = this.GetSlots();
|
||||
this.SetStacks(this.items);
|
||||
this.IsDirty = false;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Error("XUiC_RepairableVehicleStackGrid-Update parentByType == null!!!");
|
||||
}
|
||||
}
|
||||
|
||||
base.Update(_dt);
|
||||
}
|
||||
|
||||
public virtual ItemValue[] GetSlots()
|
||||
{
|
||||
ItemValue[] itemValues = null;
|
||||
|
||||
if (windowType == WindowTypeEnum.BlockRepairableVehicle)
|
||||
{
|
||||
XUiC_RepairableVehicleWindow parentByType = GetParentByType<XUiC_RepairableVehicleWindow>();
|
||||
if (parentByType != null)
|
||||
{
|
||||
itemValues = parentByType.tileEntity.GetRepairableVehicleParts();
|
||||
}
|
||||
}
|
||||
else if (windowType == WindowTypeEnum.EntityVehicle)
|
||||
{
|
||||
EntityVehicleRebirth vehicle = GetParentByType<XUiC_VehicleFrameWindowRebirth>().Vehicle;
|
||||
|
||||
itemValues = vehicle.itemValues;
|
||||
}
|
||||
|
||||
return itemValues;
|
||||
}
|
||||
|
||||
protected virtual void SetStacks(ItemValue[] stackList)
|
||||
{
|
||||
if (stackList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
XUiC_ItemInfoWindowRebirth parentByType = GetParentByType<XUiC_ItemInfoWindowRebirth>();
|
||||
for (int index = 0; index < stackList.Length && this.itemControllers.Length > index && stackList.Length > index; ++index)
|
||||
{
|
||||
XUiC_RepairableVehicleStack itemController = (XUiC_RepairableVehicleStack)this.itemControllers[index];
|
||||
itemController.SlotChangedEvent -= new XUiEvent_SlotChangedEventHandler(this.HandleSlotChangedEvent);
|
||||
itemController.ItemValue = stackList[index];
|
||||
itemController.SlotChangedEvent += new XUiEvent_SlotChangedEventHandler(this.HandleSlotChangedEvent);
|
||||
itemController.SlotNumber = index;
|
||||
itemController.InfoWindow = parentByType;
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleSlotChangedEvent(int slotNumber, ItemStack stack)
|
||||
{
|
||||
if (stack.IsEmpty())
|
||||
{
|
||||
for (int index = 0; index < this.RepairableVehiclePartsList[slotNumber].SlotIndices.Count; ++index)
|
||||
{
|
||||
SetSlotItem(this.RepairableVehiclePartsList[slotNumber].SlotIndices[index], ItemValue.None.Clone());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (this.items != null)
|
||||
{
|
||||
this.items[slotNumber] = stack.itemValue.Clone();
|
||||
SetSlotItem(slotNumber, stack.itemValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_RepairableVehicleStackGrid-HandleSlotChangedEvent this.items == null");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
if (this.ViewComponent != null && !this.ViewComponent.IsVisible)
|
||||
{
|
||||
this.ViewComponent.IsVisible = true;
|
||||
}
|
||||
|
||||
this.IsDirty = true;
|
||||
this.IsDormant = false;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
for (int index = 0; index < this.itemControllers.Length; ++index)
|
||||
{
|
||||
this.itemControllers[index].Hovered(false);
|
||||
}
|
||||
|
||||
if (this.ViewComponent != null && this.ViewComponent.IsVisible)
|
||||
{
|
||||
this.ViewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
this.IsDormant = true;
|
||||
}
|
||||
}
|
||||
505
Scripts/XUIC/XUiC_RepairableVehicleWindow.cs
Normal file
505
Scripts/XUIC/XUiC_RepairableVehicleWindow.cs
Normal file
@@ -0,0 +1,505 @@
|
||||
using Audio;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_RepairableVehicleWindow : XUiController
|
||||
{
|
||||
private XUiV_Button btnSiphon_Background;
|
||||
private readonly XUiV_Button btnRepair_Background;
|
||||
private XUiV_Button btnHotwire_Background;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
XUiController childById = base.GetChildById("btnSiphon");
|
||||
if (childById != null)
|
||||
{
|
||||
this.btnSiphon_Background = (XUiV_Button)childById.GetChildById("clickable").ViewComponent;
|
||||
this.btnSiphon_Background.Controller.OnPress += this.BtnSiphon_OnPress;
|
||||
}
|
||||
|
||||
XUiController childById2 = base.GetChildById("btnHotwire");
|
||||
if (childById2 != null)
|
||||
{
|
||||
this.btnHotwire_Background = (XUiV_Button)childById2.GetChildById("clickable").ViewComponent;
|
||||
this.btnHotwire_Background.Controller.OnPress += this.BtnHotwire_OnPress;
|
||||
}
|
||||
|
||||
XUiController childById3 = base.GetChildById("btnRepair");
|
||||
if (childById3 != null)
|
||||
{
|
||||
this.btnHotwire_Background = (XUiV_Button)childById3.GetChildById("clickable").ViewComponent;
|
||||
this.btnHotwire_Background.Controller.OnPress += this.BtnRepair_OnPress;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnSiphon_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
ItemStack gas = new ItemStack(ItemClass.GetItem("ammoGasCan"), Mathf.RoundToInt(tileEntity.GasPerc * 500));
|
||||
LocalPlayerUI.GetUIForPlayer(_sender.xui.playerUI.entityPlayer).entityPlayer.AddUIHarvestingItem(gas, true);
|
||||
//_sender.xui.playerUI.entityPlayer.inventory.AddItem(gas);
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("ammoGasCan"), _sender.xui.playerUI.entityPlayer, Mathf.RoundToInt(tileEntity.GasPerc * 500), "useactions/gas_refill");
|
||||
this.tileEntity.GasPerc = 0f;
|
||||
base.RefreshBindings(true);
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
private void BtnHotwire_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
base.RefreshBindings(false);
|
||||
Block block = null;
|
||||
bool foundEmpty = false;
|
||||
ItemValue[] itemValues = { ItemValue.None };
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress tileEntity != null");
|
||||
|
||||
block = tileEntity.blockValue.Block;
|
||||
itemValues = tileEntity.itemValues;
|
||||
Vector3i blockPos = tileEntity.ToWorldPos();
|
||||
|
||||
if (itemValues != null)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress itemValues != null");
|
||||
foundEmpty = false;
|
||||
|
||||
foreach (ItemValue item in itemValues)
|
||||
{
|
||||
if (item == null || item == ItemValue.None || item.ItemClass == null)
|
||||
{
|
||||
//Log.Warning($"Contains: NULL OR EMPTY! {item}");
|
||||
foundEmpty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress item: " + item.ItemClass.GetItemName());
|
||||
Log.Warning($"Contains: {item.ItemClass.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress itemValues == null");
|
||||
foundEmpty = true;
|
||||
}
|
||||
|
||||
if (!foundEmpty)
|
||||
{
|
||||
if (RebirthUtilities.useInventoryBagItem(_sender.xui.playerUI.entityPlayer, "HotwireKit", 1))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("crafting/craft_repair_item", -1, 0f, false);
|
||||
|
||||
float durability = tileEntity.vehicleHealth; // tileEntity.baseDurability;
|
||||
float maxDurability = tileEntity.vehicleHealth;
|
||||
|
||||
List<RepairableVehicleSlotsEnum> itemValueEnums = RebirthVariables.localVehicleTypes[block.Properties.Values["VehicleType"]];
|
||||
|
||||
foreach (ItemValue item in itemValues)
|
||||
{
|
||||
if (item != ItemValue.None)
|
||||
{
|
||||
string itemName = item.ItemClass.GetItemName();
|
||||
foreach (RepairableVehicleSlotsEnum part in itemValueEnums)
|
||||
{
|
||||
if (RebirthVariables.localVehicleParts[part].itemName == itemName)
|
||||
{
|
||||
//durability += ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes) * RebirthVariables.localVehicleParts[part].durabilityPerQuality * item.Quality;
|
||||
/*Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress itemName: " + itemName);
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress PercUsed: " + ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes));
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress Quality: " + item.Quality);
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress durabilityPerQuality: " + RebirthVariables.localVehicleParts[part].durabilityPerQuality);
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress durability: " + durability);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress blockPos: " + blockPos);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress isMultiBlock: " + block.isMultiBlock);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress tileEntity.blockValue.ischild: " + tileEntity.blockValue.ischild);
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress tileEntity.vehicleHealth: " + tileEntity.vehicleHealth);
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnHotwire_OnPress tileEntity.maxDurability: " + tileEntity.maxDurability);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageSpawnVehicleRebirth>().Setup(block.Properties.Values["vehicle_entity_class"],
|
||||
tileEntity.itemValues,
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
durability,
|
||||
_sender.xui.playerUI.entityPlayer.entityId
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.SpawnVehicleCoroutine(
|
||||
blockPos,
|
||||
tileEntity.itemValues,
|
||||
tileEntity.vehicleHealth,
|
||||
tileEntity.GasPerc,
|
||||
tileEntity.OilPerc,
|
||||
tileEntity.vehicleHealth,
|
||||
tileEntity.vehicleHealth,
|
||||
RebirthUtilities.GetBlockAngle(tileEntity.blockValue.rotation),
|
||||
block.Properties.Values["vehicle_entity_class"],
|
||||
_sender.xui.playerUI.entityPlayer.entityId
|
||||
));
|
||||
}
|
||||
|
||||
OnClose();
|
||||
}
|
||||
|
||||
//else
|
||||
//{
|
||||
// XUiC_PopupToolTip.QueueTooltip(_sender.xui, "Missing HotwireKit!", null, "misc/missingitemtorepair", new ToolTipEvent());
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
XUiC_PopupToolTip.QueueTooltip(_sender.xui, Localization.Get("ttMissingOrDamagedParts"), null, "misc/missingitemtorepair", new ToolTipEvent(), true);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Log.Error("onHotwire tileEntity == null!");
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnRepair_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
base.RefreshBindings(false);
|
||||
Block block = null;
|
||||
bool foundEmpty = false;
|
||||
ItemValue[] itemValues = { ItemValue.None };
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
block = tileEntity.blockValue.Block;
|
||||
itemValues = tileEntity.itemValues;
|
||||
Vector3i blockPos = tileEntity.ToWorldPos();
|
||||
|
||||
if (itemValues != null)
|
||||
{
|
||||
foundEmpty = false;
|
||||
|
||||
foreach (ItemValue item in itemValues)
|
||||
{
|
||||
if (item == null || item == ItemValue.None || item.ItemClass == null)
|
||||
{
|
||||
Log.Warning($"Contains: NULL OR EMPTY! {item}");
|
||||
foundEmpty = true;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Log.Warning($"Contains: {item.ItemClass.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
foundEmpty = true;
|
||||
}
|
||||
|
||||
if (!foundEmpty)
|
||||
{
|
||||
if (RebirthUtilities.useInventoryBagItem(_sender.xui.playerUI.entityPlayer, "FuriousRamsayBikeRepairKit", 1))
|
||||
{
|
||||
Manager.PlayInsidePlayerHead("crafting/craft_repair_item", -1, 0f, false);
|
||||
|
||||
Chunk chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(blockPos);
|
||||
|
||||
float gasPerc = tileEntity.GasPerc;
|
||||
float durability = tileEntity.Durability;
|
||||
|
||||
List<RepairableVehicleSlotsEnum> itemValueEnums = RebirthVariables.localVehicleTypes[block.Properties.Values["VehicleType"]];
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress INITIAL durability: " + durability);
|
||||
|
||||
foreach (ItemValue item in itemValues)
|
||||
{
|
||||
if (item != ItemValue.None)
|
||||
{
|
||||
string itemName = item.ItemClass.GetItemName();
|
||||
foreach (RepairableVehicleSlotsEnum part in itemValueEnums)
|
||||
{
|
||||
if (RebirthVariables.localVehicleParts[part].itemName == itemName)
|
||||
{
|
||||
//durability += ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes) * RebirthVariables.localVehicleParts[part].durabilityPerQuality * item.Quality;
|
||||
/*Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress itemName: " + itemName);
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress PercUsed: " + ((item.MaxUseTimes - item.UseTimes) / item.MaxUseTimes));
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress Quality: " + item.Quality);
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress durabilityPerQuality: " + RebirthVariables.localVehicleParts[part].durabilityPerQuality);
|
||||
Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress durability: " + durability);*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-BtnRepair_OnPress TOTAL durability: " + durability);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageSpawnVehicleRebirth>().Setup(block.Properties.Values["vehicle_entity_class"],
|
||||
tileEntity.itemValues,
|
||||
blockPos.x,
|
||||
blockPos.y,
|
||||
blockPos.z,
|
||||
durability,
|
||||
_sender.xui.playerUI.entityPlayer.entityId
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
/*GameManager.Instance.StartCoroutine(RebirthUtilities.SpawnVehicleCoroutine(
|
||||
blockPos,
|
||||
tileEntity.itemValues,
|
||||
tileEntity.baseDurability,
|
||||
tileEntity.GasPerc,
|
||||
tileEntity.OilPerc,
|
||||
durability,
|
||||
tileEntity.maxDurability,
|
||||
RebirthUtilities.GetBlockAngle(tileEntity.blockValue.rotation),
|
||||
block.Properties.Values["vehicle_entity_class"],
|
||||
_sender.xui.playerUI.entityPlayer.entityId
|
||||
));*/
|
||||
GameManager.Instance.StartCoroutine(RebirthUtilities.SpawnVehicleCoroutine(
|
||||
blockPos,
|
||||
tileEntity.itemValues,
|
||||
tileEntity.vehicleHealth,
|
||||
tileEntity.GasPerc,
|
||||
tileEntity.OilPerc,
|
||||
tileEntity.vehicleHealth,
|
||||
tileEntity.vehicleHealth,
|
||||
RebirthUtilities.GetBlockAngle(tileEntity.blockValue.rotation),
|
||||
block.Properties.Values["vehicle_entity_class"],
|
||||
_sender.xui.playerUI.entityPlayer.entityId
|
||||
));
|
||||
}
|
||||
|
||||
OnClose();
|
||||
}
|
||||
else
|
||||
{
|
||||
XUiC_PopupToolTip.QueueTooltip(_sender.xui, Localization.Get("ttMissingRepairKit"), null, "misc/missingitemtorepair", new ToolTipEvent(), true);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
XUiC_PopupToolTip.QueueTooltip(_sender.xui, Localization.Get("ttMissingOrDamagedParts"), null, "misc/missingitemtorepair", new ToolTipEvent(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
if (tileEntity != null)
|
||||
{
|
||||
EntityClass entityClass = null;
|
||||
string entityClassName = "";
|
||||
Block block = tileEntity.blockValue.Block;
|
||||
Dictionary<string, DynamicProperties> propertyMap = Vehicle.PropertyMap;
|
||||
float velocityMax = 0f;
|
||||
|
||||
if (block is BlockVehicleRebirth)
|
||||
{
|
||||
BlockVehicleRebirth blockVehicle = (BlockVehicleRebirth)block;
|
||||
entityClassName = blockVehicle.vehicle_entity_class;
|
||||
var properties = propertyMap[entityClassName.ToLowerInvariant()];
|
||||
velocityMax = Convert.ToSingle(properties.Values["velocityMax_turbo"].Split(',')[2]);
|
||||
entityClass = EntityClass.GetEntityClass(EntityClass.FromString(entityClassName));
|
||||
}
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "oil":
|
||||
value = this.fuelFormatter.Format(Mathf.RoundToInt(tileEntity.OilPerc * 100f));
|
||||
return true;
|
||||
|
||||
case "oiltitle":
|
||||
value = Localization.Get("xuiOil");
|
||||
return true;
|
||||
|
||||
case "fuel":
|
||||
value = this.fuelFormatter.Format(Mathf.RoundToInt(tileEntity.GasPerc * 100f));
|
||||
return true;
|
||||
|
||||
case "fueltitle":
|
||||
value = Localization.Get("xuiGas");
|
||||
return true;
|
||||
|
||||
case "speed":
|
||||
value = speedFormatter.Format(Mathf.RoundToInt(velocityMax));
|
||||
return true;
|
||||
|
||||
case "speedtext":
|
||||
if (velocityMax <= 0f)
|
||||
{
|
||||
value = Localization.Get("xuiVehicleSpeedNone");
|
||||
}
|
||||
else if (velocityMax <= 10f)
|
||||
{
|
||||
value = Localization.Get("xuiVehicleSpeedSlow");
|
||||
}
|
||||
else if (velocityMax <= 20f)
|
||||
{
|
||||
value = Localization.Get("xuiVehicleSpeedNormal");
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Localization.Get("xuiVehicleSpeedFast");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case "speedtitle":
|
||||
value = Localization.Get("xuiSpeed");
|
||||
return true;
|
||||
|
||||
case "bodydurability":
|
||||
|
||||
int health = (int)tileEntity.vehicleHealth;
|
||||
|
||||
value = vehicleDurabilityFormatter.Format(Mathf.RoundToInt(tileEntity.Durability), health);
|
||||
return true;
|
||||
|
||||
case "bodydurabilitytitle":
|
||||
value = Localization.Get("xuiBodyDurability");
|
||||
return true;
|
||||
|
||||
case "vehicleicon":
|
||||
if (entityClassName != "")
|
||||
{
|
||||
value = "ui_game_symbol_4x4";
|
||||
|
||||
if (entityClass != null)
|
||||
{
|
||||
if (entityClass.Properties.Values.ContainsKey("MapIcon"))
|
||||
{
|
||||
value = entityClass.Properties.Values["MapIcon"];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "ui_game_symbol_4x4";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
case "vehiclename":
|
||||
if (entityClassName != "")
|
||||
{
|
||||
value = "Vehicle";
|
||||
|
||||
if (entityClass != null)
|
||||
{
|
||||
value = Localization.Get(entityClass.entityClassName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "Vehicle";
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
if (GameManager.Instance == null || GameManager.Instance.World == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.Update(_dt);
|
||||
if (this.windowGroup.isShowing)
|
||||
{
|
||||
if (!base.xui.playerUI.playerInput.PermanentActions.Activate.IsPressed)
|
||||
{
|
||||
this.wasReleased = true;
|
||||
}
|
||||
|
||||
if (this.wasReleased)
|
||||
{
|
||||
if (base.xui.playerUI.playerInput.PermanentActions.Activate.IsPressed)
|
||||
{
|
||||
this.activeKeyDown = true;
|
||||
}
|
||||
|
||||
if (base.xui.playerUI.playerInput.PermanentActions.Activate.WasReleased && this.activeKeyDown)
|
||||
{
|
||||
this.activeKeyDown = false;
|
||||
base.xui.playerUI.windowManager.CloseAllOpenWindows(null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetTileEntity(TileEntityDriveableLootContainer _te)
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-SetTileEntity START");
|
||||
this.tileEntity = _te;
|
||||
|
||||
if (this.tileEntity != null)
|
||||
{
|
||||
base.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_RepairableVehicleWindow-OnClose START");
|
||||
|
||||
this.wasReleased = false;
|
||||
this.activeKeyDown = false;
|
||||
|
||||
if (this.tileEntity != null)
|
||||
{
|
||||
Vector3i blockPos = this.tileEntity.ToWorldPos();
|
||||
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer && !GameManager.IsDedicatedServer)
|
||||
{
|
||||
RebirthUtilities.removeTileEntityAccess(blockPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SingletonMonoBehaviour<ConnectionManager>.Instance.IsClient)
|
||||
{
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(NetPackageManager.GetPackage<NetPackageCloseTileEntityRebirth>().Setup(blockPos.x, blockPos.y, blockPos.z), false);
|
||||
}
|
||||
}
|
||||
|
||||
this.tileEntity.SetUserAccessing(false);
|
||||
this.tileEntity.SetModified();
|
||||
this.SetTileEntity(null);
|
||||
}
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
public TileEntityDriveableLootContainer tileEntity;
|
||||
private readonly bool isClosing;
|
||||
private bool activeKeyDown;
|
||||
private bool wasReleased;
|
||||
|
||||
private readonly CachedStringFormatterInt speedFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterInt fuelFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatter<int, int> vehicleDurabilityFormatter = new CachedStringFormatter<int, int>((int _i1, int _i2) => string.Format("{0}/{1}", _i1, _i2));
|
||||
}
|
||||
173
Scripts/XUIC/XUiC_ResetQuestsPopupRebirth.cs
Normal file
173
Scripts/XUIC/XUiC_ResetQuestsPopupRebirth.cs
Normal file
@@ -0,0 +1,173 @@
|
||||
using Audio;
|
||||
|
||||
internal class XUiC_ResetQuestsPopupRebirth : XUiController
|
||||
{
|
||||
public XUiV_Label Label;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-Init START");
|
||||
|
||||
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;
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-Init END");
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen START");
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 1");
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
}
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
EntityTrader myEntity = player.world.GetEntity(entityID) as EntityTrader;
|
||||
|
||||
float numQuestCompletionTier = 0;
|
||||
if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestCompletionTier"))
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 3");
|
||||
numQuestCompletionTier = player.Buffs.GetCustomVar("$varFuriousRamsayQuestCompletionTier");
|
||||
}
|
||||
|
||||
int numPrice = 100 + ((int)numQuestCompletionTier * 100);
|
||||
|
||||
if (numPrice > 500)
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen 4");
|
||||
numPrice = 500;
|
||||
}
|
||||
|
||||
if (myEntity != null)
|
||||
{
|
||||
Label.Text = "Pay " + numPrice + " cash to reset the Quests?";
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen RESPONDANT: " + myEntity.EntityName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen NO RESPONDANT");
|
||||
}
|
||||
|
||||
base.OnOpen();
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnOpen END");
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-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)
|
||||
return;
|
||||
|
||||
EntityTrader myEntity = player.world.GetEntity(entityID) as EntityTrader;
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed RESPONDANT: " + myEntity.EntityName);
|
||||
|
||||
if (myEntity != null)
|
||||
{
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 1");
|
||||
|
||||
float numQuestCompletionTier = 0;
|
||||
if (player.Buffs.HasCustomVar("$varFuriousRamsayQuestCompletionTier"))
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 2");
|
||||
numQuestCompletionTier = player.Buffs.GetCustomVar("$varFuriousRamsayQuestCompletionTier");
|
||||
}
|
||||
|
||||
int numPrice = 100 + ((int)numQuestCompletionTier * 100);
|
||||
|
||||
ItemValue item = ItemClass.GetItem("casinoCoin", false);
|
||||
ItemClass itemClass = item.ItemClass;
|
||||
if (itemClass != null)
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_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_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 4");
|
||||
if (itemCount2 > 0)
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 5");
|
||||
player.inventory.DecItem(item, 1, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 6");
|
||||
player.bag.DecItem(item, 1, false);
|
||||
}
|
||||
if (myEntity is EntityTrader)
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 7");
|
||||
myEntity.ClearActiveQuests(player.entityId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 8");
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
|
||||
|
||||
Manager.PlayInsidePlayerHead("misc/missingitemtorepair");
|
||||
GameManager.ShowTooltip(uiforPlayer.entityPlayer, Localization.Get("ttMissingCash"));
|
||||
ItemStack @is = new ItemStack(new ItemValue(itemClass.Id, false), 0);
|
||||
uiforPlayer.entityPlayer.AddUIHarvestingItem(@is, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed 9");
|
||||
}
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnConfirm_OnPressed END");
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnCancel_OnPressed START");
|
||||
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-BtnCancel_OnPressed END");
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnClose START");
|
||||
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
|
||||
//Log.Out("XUiC_ResetQuestsPopupRebirth-OnClose END");
|
||||
}
|
||||
}
|
||||
148
Scripts/XUIC/XUiC_SelectClassRebirth.cs
Normal file
148
Scripts/XUIC/XUiC_SelectClassRebirth.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
internal class XUiC_SelectClassRebirth : XUiController
|
||||
{
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
public XUiV_Sprite classIcon;
|
||||
public XUiV_Label className;
|
||||
public XUiV_Label classDescription;
|
||||
|
||||
public XUiV_Texture imagePreview;
|
||||
private XUiC_ComboBoxList<string> cbxTargetSelectClass;
|
||||
|
||||
public string ModsBasePath = GameIO.GetUserGameDataDir() + "/Mods";
|
||||
public string ModsBasePathLegacy = Application.platform != UnityEngine.RuntimePlatform.OSXPlayer ? (Application.dataPath + "/../Mods") : (Application.dataPath + "/../../Mods");
|
||||
public string imagePath = "";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
((XUiC_SimpleButton)GetChildById("btnConfirm")).OnPressed += BtnConfirm_OnPressed;
|
||||
|
||||
classIcon = (XUiV_Sprite)GetChildById("classImage").ViewComponent;
|
||||
className = (XUiV_Label)GetChildById("className").ViewComponent;
|
||||
classDescription = (XUiV_Label)GetChildById("descriptionClass").ViewComponent;
|
||||
|
||||
this.cbxTargetSelectClass = (base.GetChildById("cbxSelectClass") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxTargetSelectClass != null)
|
||||
{
|
||||
this.cbxTargetSelectClass.Elements.Add("None");
|
||||
this.cbxTargetSelectClass.Elements.Add("Hunter");
|
||||
this.cbxTargetSelectClass.Elements.Add("Thug");
|
||||
this.cbxTargetSelectClass.Elements.Add("Butcher");
|
||||
this.cbxTargetSelectClass.Elements.Add("Soldier");
|
||||
this.cbxTargetSelectClass.Elements.Add("Technogeek");
|
||||
this.cbxTargetSelectClass.Elements.Add("Madman");
|
||||
this.cbxTargetSelectClass.Elements.Add("Builder");
|
||||
this.cbxTargetSelectClass.Elements.Add("Sous-Chef");
|
||||
this.cbxTargetSelectClass.Elements.Add("Witch Doctor");
|
||||
this.cbxTargetSelectClass.Elements.Add("Berserker");
|
||||
this.cbxTargetSelectClass.OnValueChanged += this.cbxTargetSelectClass_OnValueChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void cbxTargetSelectClass_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
changeValue();
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
if (Directory.Exists(ModsBasePathLegacy + "/zzz_REBIRTH__Utils"))
|
||||
{
|
||||
imagePath = ModsBasePathLegacy + "/zzz_REBIRTH__Utils" + "/Resources/Previews/";
|
||||
}
|
||||
else
|
||||
{
|
||||
imagePath = ModsBasePath + "/zzz_REBIRTH__Utils" + "/Resources/Previews/";
|
||||
}
|
||||
|
||||
cbxTargetSelectClass.SelectedIndex = 0;
|
||||
|
||||
changeValue();
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
if (!CheckQuestState())
|
||||
{
|
||||
CloseSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
string classIdentifier = cbxTargetSelectClass.Value.Replace(" ", "").Replace("Sous-", "");
|
||||
|
||||
if (classIdentifier != "None")
|
||||
{
|
||||
Quest quest = QuestClass.CreateQuest("quest_BasicSurvival_" + classIdentifier);
|
||||
base.xui.playerUI.entityPlayer.Buffs.SetCustomVar("$FR_SelectedClass", RebirthUtilities.GetIDFromClassName(classIdentifier));
|
||||
base.xui.playerUI.entityPlayer.QuestJournal.AddQuest(quest);
|
||||
xui.playerUI.entityPlayer.Buffs.SetCustomVar("$FR_InitialClassChosen", 1f);
|
||||
CloseSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_SelectClassRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void changeValue()
|
||||
{
|
||||
string classIdentifier = cbxTargetSelectClass.Value.Replace(" ", "").Replace("Sous-", "");
|
||||
|
||||
classDescription.Text = Localization.Get("xuiClassDescription" + classIdentifier);
|
||||
className.Text = Localization.Get("xuiClassName" + classIdentifier);
|
||||
classIcon.SpriteName = "Class" + classIdentifier;
|
||||
|
||||
if (classIdentifier != "None")
|
||||
{
|
||||
((XUiC_SimpleButton)GetChildById("btnConfirm")).Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
((XUiC_SimpleButton)GetChildById("btnConfirm")).Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckQuestState()
|
||||
{
|
||||
var prereqQuest = xui.playerUI.entityPlayer.QuestJournal.FindQuest("quest_basicsurvival_3");
|
||||
if (prereqQuest == null)
|
||||
{
|
||||
GameManager.ShowTooltip(xui.playerUI.entityPlayer, Localization.Get("ttPrereqClassUninitiated"), string.Empty, "ui_denied");
|
||||
return false;
|
||||
}
|
||||
if (prereqQuest.CurrentState != Quest.QuestState.Completed)
|
||||
{
|
||||
GameManager.ShowTooltip(xui.playerUI.entityPlayer, Localization.Get("ttPrereqClassIncomplete"), string.Empty, "ui_denied");
|
||||
return false;
|
||||
}
|
||||
if ((int)xui.playerUI.entityPlayer.Buffs.GetCustomVar("$FR_InitialClassChosen", 0f) > 0)
|
||||
{
|
||||
GameManager.ShowTooltip(xui.playerUI.entityPlayer, Localization.Get("ttInitialClassChosen"), string.Empty, "ui_denied");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CloseSelf()
|
||||
{
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
}
|
||||
91
Scripts/XUIC/XUiC_ShowDismemberRebirth.cs
Normal file
91
Scripts/XUIC/XUiC_ShowDismemberRebirth.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
internal class XUiC_ShowDismemberRebirth : XUiController
|
||||
{
|
||||
private EntityPlayerLocal LocalPlayer;
|
||||
private readonly CachedStringFormatterXuiRgbaColor stealthColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatter<float> statfillFormatter = new CachedStringFormatter<float>((Func<float, string>)(_i => _i.ToCultureInvariantString()));
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatter<float, float> statmodifiedmaxFormatter = new CachedStringFormatter<float, float>((Func<float, float, string>)((_f1, _f2) => (_f1 / _f2).ToCultureInvariantString()));
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-GetBindingValue START");
|
||||
float flDismemberCountdown = 0;
|
||||
float flDismemberTotalCounter = 0;
|
||||
float flDismemberHUD = 0;
|
||||
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
flDismemberCountdown = this.LocalPlayer.Buffs.GetCustomVar(".FuriousRamsayDismemberedHeadTotalCountdown");
|
||||
flDismemberTotalCounter = this.LocalPlayer.Buffs.GetCustomVar(".FuriousRamsayDismemberedHeadTotalCounter");
|
||||
flDismemberHUD = this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayDismemberHUD");
|
||||
}
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "dismemberCount":
|
||||
value = flDismemberTotalCounter.ToString();
|
||||
return true;
|
||||
case "statDismemberFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-GetBindingValue 2");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = (flDismemberCountdown / 8).ToString();
|
||||
return true;
|
||||
case "statDismemberVisible":
|
||||
if (this.xui.dragAndDrop.InMenu || flDismemberHUD == 0)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-GetBindingValue 4 statDismemberVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (flDismemberCountdown <= 0 || flDismemberTotalCounter <= 0)
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-GetBindingValue 5 statDismemberVisible: " + value);
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-GetBindingValue 6 statDismemberVisible: " + value);
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-OnOpen START");
|
||||
base.OnOpen();
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-OnOpen 1");
|
||||
this.LocalPlayer = this.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
private float currentTime;
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
this.currentTime -= _dt;
|
||||
base.Update(_dt);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_ShowDismemberRebirth-Update 1");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.LocalPlayer.Buffs.HasBuff("FuriousRamsayDismemberedHeadCounter"))
|
||||
{
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
98
Scripts/XUIC/XUiC_ShowRampageRebirth.cs
Normal file
98
Scripts/XUIC/XUiC_ShowRampageRebirth.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
internal class XUiC_ShowRampageRebirth : XUiController
|
||||
{
|
||||
private EntityPlayerLocal LocalPlayer;
|
||||
private readonly CachedStringFormatterXuiRgbaColor stealthColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatter<float> statfillFormatter = new CachedStringFormatter<float>((Func<float, string>)(_i => _i.ToCultureInvariantString()));
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatter<float, float> statmodifiedmaxFormatter = new CachedStringFormatter<float, float>((Func<float, float, string>)((_f1, _f2) => (_f1 / _f2).ToCultureInvariantString()));
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue START");
|
||||
float flRampageCountdown = 0;
|
||||
float flRampageCountdownMax = 0;
|
||||
float flRampageTotalCounter = 0;
|
||||
float flRampageHUD = 0;
|
||||
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
flRampageCountdown = this.LocalPlayer.Buffs.GetCustomVar(".FuriousRamsayRampageCounter");
|
||||
flRampageCountdownMax = this.LocalPlayer.Buffs.GetCustomVar(".FuriousRamsayRampageCounterMax");
|
||||
flRampageTotalCounter = this.LocalPlayer.Buffs.GetCustomVar(".FuriousRamsayRampageKillCounter");
|
||||
flRampageHUD = this.LocalPlayer.Buffs.GetCustomVar("$varFuriousRamsayRampageHUD");
|
||||
}
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "rampageCount":
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue RampageCount: " + value);
|
||||
value = flRampageTotalCounter.ToString();
|
||||
return true;
|
||||
case "statRampageFill":
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue statRampageFill: " + value);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue 2");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = (flRampageCountdown / flRampageCountdownMax).ToString();
|
||||
return true;
|
||||
case "statRampageVisible":
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue statRampageVisible: " + value);
|
||||
if (this.xui.dragAndDrop.InMenu || flRampageHUD == 0)
|
||||
{
|
||||
value = "false";
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue 4 statRampageVisible: " + value);
|
||||
return true;
|
||||
}
|
||||
if (flRampageCountdown <= 0 || flRampageTotalCounter <= 0)
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue 5 statRampageVisible: " + value);
|
||||
value = "false";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-GetBindingValue 6 statRampageVisible: " + value);
|
||||
value = "true";
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-OnOpen START");
|
||||
base.OnOpen();
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-OnOpen 1");
|
||||
this.LocalPlayer = this.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
private float currentTime;
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-Update START");
|
||||
this.currentTime -= _dt;
|
||||
base.Update(_dt);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-Update 1");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.LocalPlayer.Buffs.HasBuff("FuriousRamsayRampage"))
|
||||
{
|
||||
//Log.Out("XUiC_ShowRampageRebirth-Update 2");
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Scripts/XUIC/XUiC_StatsHUDRebirth.cs
Normal file
134
Scripts/XUIC/XUiC_StatsHUDRebirth.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
internal class XUiC_StatsHUDRebirth : XUiController
|
||||
{
|
||||
private readonly CachedStringFormatter<int> dayFormatter = new CachedStringFormatter<int>((int _i) => _i.ToString());
|
||||
private readonly CachedStringFormatter<int, int> timeFormatter = new CachedStringFormatter<int, int>((int _hour, int _min) => string.Format("{0:00}:{1:00}", _hour, _min));
|
||||
private float lastValueStamina = 0.0f;
|
||||
private float lastValueHealth = 0.0f;
|
||||
private float lastValueWater = 0.0f;
|
||||
private float lastValueFood = 0.0f;
|
||||
private float lastValueStaminaPerc = 0.0f;
|
||||
private float lastValueHealthPerc = 0.0f;
|
||||
private float lastValueWaterPerc = 0.0f;
|
||||
private float lastValueFoodPerc = 0.0f;
|
||||
private float deltaTime;
|
||||
private EntityPlayerLocal LocalPlayer;
|
||||
private readonly CachedStringFormatterXuiRgbaColor stealthColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatter<float> statfillFormatter = new CachedStringFormatter<float>((Func<float, string>)(_i => _i.ToCultureInvariantString()));
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatter<float, float> statmodifiedmaxFormatter = new CachedStringFormatter<float, float>((Func<float, float, string>)((_f1, _f2) => (_f1 / _f2).ToCultureInvariantString()));
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue START");
|
||||
bool bHide = flUpdateTime < 80;
|
||||
|
||||
if (flUpdateTime < 80)
|
||||
{
|
||||
flUpdateTime = flUpdateTime + .1f;
|
||||
}
|
||||
|
||||
/*Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 0 flShowStatsHUDHealth: " + flShowStatsHUDHealth);
|
||||
Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 0 flShowStatsHUDStamina: " + flShowStatsHUDStamina);
|
||||
|
||||
Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 0 bindingName: " + bindingName);*/
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "playerStaminaModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Stamina.ModifiedMax / this.LocalPlayer.Stats.Stamina.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 1 playerStaminaModifiedMax: " + value);
|
||||
return true;
|
||||
case "statStaminaFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueStamina, 0.0f) * 1.01f);
|
||||
lastValueStaminaPerc = this.lastValueStamina * 100;
|
||||
this.lastValueStamina = Mathf.Lerp(this.lastValueStamina, this.LocalPlayer.Stats.Stamina.ValuePercentUI, this.deltaTime * 3f);
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 3 statStaminaFill: " + value);
|
||||
return true;
|
||||
case "playerHealthModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Health.ModifiedMax / this.LocalPlayer.Stats.Health.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 1 playerHealthModifiedMax: " + value);
|
||||
return true;
|
||||
case "statHealthFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueHealth, 0.0f) * 1.01f);
|
||||
this.lastValueHealth = Mathf.Lerp(this.lastValueHealth, this.LocalPlayer.Stats.Health.ValuePercentUI, this.deltaTime * 3f);
|
||||
lastValueHealthPerc = this.lastValueHealth * 100;
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 3 statHealthFill: " + value);
|
||||
return true;
|
||||
case "playerWaterModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Water.ModifiedMax / this.LocalPlayer.Stats.Water.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 1 playerWaterModifiedMax: " + value);
|
||||
return true;
|
||||
case "statWaterFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueWater, 0.0f) * 1.01f);
|
||||
this.lastValueWater = Mathf.Lerp(this.lastValueWater, this.LocalPlayer.Stats.Water.ValuePercentUI, this.deltaTime * 3f);
|
||||
lastValueWaterPerc = this.lastValueWater * 100;
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 3 statWaterFill: " + value);
|
||||
return true;
|
||||
case "playerFoodModifiedMax":
|
||||
value = (this.LocalPlayer != null) ? (this.LocalPlayer.Stats.Food.ModifiedMax / this.LocalPlayer.Stats.Food.Max).ToString("0.##") : "0";
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 1 playerFoodModifiedMax: " + value);
|
||||
return true;
|
||||
case "statFoodFill":
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 4");
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
value = this.statfillFormatter.Format(Math.Max(this.lastValueFood, 0.0f) * 1.01f);
|
||||
this.lastValueFood = Mathf.Lerp(this.lastValueFood, this.LocalPlayer.Stats.Food.ValuePercentUI, this.deltaTime * 3f);
|
||||
lastValueFoodPerc = this.lastValueFood * 100;
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 3 statFoodFill: " + value);
|
||||
return true;
|
||||
default:
|
||||
//Log.Out("XUiC_StatsHUDRebirth-GetBindingValue 12");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-OnOpen START");
|
||||
base.OnOpen();
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-OnOpen 1");
|
||||
this.LocalPlayer = this.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-Update START");
|
||||
base.Update(_dt);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_StatsHUDRebirth-Update 1");
|
||||
return;
|
||||
}
|
||||
this.deltaTime = _dt;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
protected float flUpdateTime;
|
||||
}
|
||||
404
Scripts/XUIC/XUiC_TargetBarRebirth.cs
Normal file
404
Scripts/XUIC/XUiC_TargetBarRebirth.cs
Normal file
@@ -0,0 +1,404 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_TargetBarRebirth : XUiController
|
||||
{
|
||||
private float lastValue;
|
||||
private float deltaTime;
|
||||
private float noTargetFadeTime;
|
||||
private float noTargetFadeTimeMax = 0.1f;
|
||||
private XUiC_TargetBarRebirth.EVisibility visibility;
|
||||
private string defaultBossIcon = "ui_game_symbol_twitch_boss_bar_default";
|
||||
private GameEventManager gameEventManager;
|
||||
private BossGroup CurrentBossGroup;
|
||||
private readonly CachedStringFormatterInt statcurrentFormatterInt = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatter<int, int> statcurrentWMaxFormatterAOfB = new CachedStringFormatter<int, int>((Func<int, int, string>)((_i, _i1) => string.Format("{0}/{1}", (object)_i, (object)_i1)));
|
||||
private readonly CachedStringFormatterFloat statfillFormatter = new CachedStringFormatterFloat();
|
||||
|
||||
public EntityAlive Target { get; set; }
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.IsDirty = true;
|
||||
this.viewComponent.IsVisible = false;
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if (Target is EntityZombieSDX)
|
||||
{
|
||||
if (Target.HasAnyTags(FastTags<TagGroup.Global>.Parse("invisible")))
|
||||
{
|
||||
//Log.Out("====================INVISIBLE====================");
|
||||
this.Target = null;
|
||||
this.viewComponent.IsVisible = false;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.deltaTime = _dt;
|
||||
if (this.gameEventManager == null)
|
||||
this.gameEventManager = GameEventManager.Current;
|
||||
if (!this.xui.playerUI.entityPlayer.IsAlive())
|
||||
{
|
||||
this.viewComponent.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.gameEventManager.CurrentBossGroup != null)
|
||||
{
|
||||
this.CurrentBossGroup = this.gameEventManager.CurrentBossGroup;
|
||||
this.Target = this.CurrentBossGroup.BossEntity;
|
||||
bool flag = false;
|
||||
if (this.Target != null && this.Target.IsAlive())
|
||||
flag = true;
|
||||
if (this.CurrentBossGroup.MinionCount != 0)
|
||||
flag = true;
|
||||
if (flag)
|
||||
{
|
||||
this.viewComponent.IsVisible = true;
|
||||
this.noTargetFadeTime = 0.0f;
|
||||
}
|
||||
else if ((double)this.noTargetFadeTime >= (double)this.noTargetFadeTimeMax)
|
||||
{
|
||||
this.Target = null;
|
||||
this.viewComponent.IsVisible = false;
|
||||
this.CurrentBossGroup.BossEntity = null;
|
||||
}
|
||||
else
|
||||
this.noTargetFadeTime += Time.deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.CurrentBossGroup != null)
|
||||
{
|
||||
this.Target = null;
|
||||
this.CurrentBossGroup = null;
|
||||
}
|
||||
|
||||
if (this.visibility == XUiC_TargetBarRebirth.EVisibility.Never)
|
||||
{
|
||||
this.viewComponent.IsVisible = false;
|
||||
return;
|
||||
}
|
||||
if (this.visibility == XUiC_TargetBarRebirth.EVisibility.GodMode && !this.xui.playerUI.entityPlayer.IsGodMode.Value)
|
||||
{
|
||||
if (RebirthVariables.customTargetBarVisibility == "none")
|
||||
{
|
||||
this.viewComponent.IsVisible = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool flag = false;
|
||||
WorldRayHitInfo hitInfo = this.xui.playerUI.entityPlayer.HitInfo;
|
||||
if (hitInfo.bHitValid && (bool)hitInfo.transform && hitInfo.tag.StartsWith("E_", StringComparison.Ordinal))
|
||||
{
|
||||
Transform hitRootTransform = GameUtils.GetHitRootTransform(hitInfo.tag, hitInfo.transform);
|
||||
EntityAlive entityAlive = null;
|
||||
if (hitRootTransform != null)
|
||||
entityAlive = hitRootTransform.GetComponent<EntityAlive>();
|
||||
if (entityAlive != null && entityAlive.IsAlive())
|
||||
{
|
||||
flag = true;
|
||||
this.Target = entityAlive;
|
||||
}
|
||||
}
|
||||
if (this.Target == null)
|
||||
{
|
||||
this.viewComponent.IsVisible = false;
|
||||
this.noTargetFadeTime = this.noTargetFadeTimeMax;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_TargetBarRebirth-Update tags: " + this.Target.EntityTags);
|
||||
|
||||
bool canSeeTarget = true;
|
||||
|
||||
if (RebirthVariables.customTargetBarVisibility == "default")
|
||||
{
|
||||
canSeeTarget = RebirthUtilities.CanSeeTargetHealth(this.xui.playerUI.entityPlayer, this.Target);
|
||||
|
||||
bool randomNames = RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNames") == "true";
|
||||
|
||||
if (randomNames)
|
||||
{
|
||||
canSeeTarget = true;
|
||||
}
|
||||
|
||||
if (!canSeeTarget)
|
||||
{
|
||||
bool shouldAttack = RebirthUtilities.VerifyFactionStanding(this.xui.playerUI.entityPlayer, this.Target);
|
||||
|
||||
if (this.Target.HasAnyTags(FastTags<TagGroup.Global>.Parse("npc")) &&
|
||||
!shouldAttack)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
this.viewComponent.IsVisible = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
this.viewComponent.IsVisible = true;
|
||||
this.noTargetFadeTime = 0.0f;
|
||||
}
|
||||
else if ((double)this.noTargetFadeTime >= (double)this.noTargetFadeTimeMax)
|
||||
{
|
||||
this.Target = null;
|
||||
this.viewComponent.IsVisible = false;
|
||||
}
|
||||
else
|
||||
this.noTargetFadeTime += Time.deltaTime;
|
||||
if (this.Target != null && (this.Target.IsDead() || this.Target.Health == 0))
|
||||
{
|
||||
this.Target = null;
|
||||
this.viewComponent.IsVisible = false;
|
||||
this.noTargetFadeTime = this.noTargetFadeTimeMax;
|
||||
}
|
||||
}
|
||||
this.RefreshBindings(this.IsDirty);
|
||||
this.IsDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
switch (bindingName)
|
||||
{
|
||||
case "posY":
|
||||
if (RebirthVariables.customScenario == "purge" && RebirthVariables.purgeDisplay)
|
||||
{
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
value = "-150";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "-135";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (RebirthUtilities.IsHordeNight())
|
||||
{
|
||||
value = "-100";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "-85";
|
||||
}
|
||||
|
||||
return true;
|
||||
case "boss_sprite":
|
||||
if (this.gameEventManager == null || this.CurrentBossGroup == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
value = this.CurrentBossGroup.BossIcon == "" ? this.defaultBossIcon : this.CurrentBossGroup.BossIcon;
|
||||
return true;
|
||||
case "current":
|
||||
if (this.Target == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
value = this.statcurrentFormatterInt.Format(this.Target.Health);
|
||||
return true;
|
||||
case "currentwithmax":
|
||||
if (this.Target == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
int health = (int)this.Target.Stats.Health.Value;
|
||||
|
||||
if (this.Target is EntityVehicleRebirth)
|
||||
{
|
||||
health = (int)this.Target.Health;
|
||||
}
|
||||
|
||||
value = this.statcurrentWMaxFormatterAOfB.Format(this.Target.IsAlive() ? health : 0, (int)this.Target.Stats.Health.Max);
|
||||
return true;
|
||||
case "fill":
|
||||
if (this.Target == null)
|
||||
{
|
||||
value = "0";
|
||||
return true;
|
||||
}
|
||||
float b = (float)this.Target.Health / (float)this.Target.GetMaxHealth();
|
||||
float _v1 = Math.Max(this.lastValue, 0.0f) * 1.01f;
|
||||
value = this.statfillFormatter.Format(_v1);
|
||||
this.lastValue = Mathf.Lerp(this.lastValue, b, this.deltaTime * 3f);
|
||||
return true;
|
||||
case "randNamesColor":
|
||||
value = RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "RandomNamesColor");
|
||||
|
||||
if (this.Target != null && this.Target.HasAnyTags(FastTags<TagGroup.Global>.Parse("boss")))
|
||||
{
|
||||
value = RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "BossNameColor");
|
||||
}
|
||||
|
||||
return true;
|
||||
case "israndomnames":
|
||||
value = "false";
|
||||
|
||||
//Log.Out("XUiC_TargetBarRebirth-Update IS RANDOM NAMES");
|
||||
|
||||
if (RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNames") == "true")
|
||||
{
|
||||
bool canSeeTarget = RebirthUtilities.CanSeeTargetHealth(this.xui.playerUI.entityPlayer, this.Target);
|
||||
|
||||
//Log.Out("XUiC_TargetBarRebirth-Update IS RANDOM NAMES, canSeeTarget: " + canSeeTarget);
|
||||
|
||||
if (!canSeeTarget)
|
||||
{
|
||||
value = "true";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "isboss":
|
||||
if (this.gameEventManager == null)
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
value = (this.CurrentBossGroup != null).ToString();
|
||||
|
||||
return true;
|
||||
case "isnotboss":
|
||||
if (this.gameEventManager == null)
|
||||
{
|
||||
value = "false";
|
||||
return true;
|
||||
}
|
||||
value = (this.CurrentBossGroup == null).ToString();
|
||||
|
||||
//Log.Out("XUiC_TargetBarRebirth-Update IS NOT BOSS");
|
||||
|
||||
if (RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNames") == "true")
|
||||
{
|
||||
bool canSeeTarget = RebirthUtilities.CanSeeTargetHealth(this.xui.playerUI.entityPlayer, this.Target);
|
||||
|
||||
//Log.Out("XUiC_TargetBarRebirth-Update IS NOT BOSS, canSeeTarget: " + canSeeTarget);
|
||||
|
||||
if (!canSeeTarget)
|
||||
{
|
||||
value = "false";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
case "minioncount":
|
||||
if (this.gameEventManager == null || this.CurrentBossGroup == null)
|
||||
{
|
||||
value = "";
|
||||
return true;
|
||||
}
|
||||
value = this.CurrentBossGroup.MinionCount.ToString();
|
||||
return true;
|
||||
case "name":
|
||||
if (this.Target == null)
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityPlayer target = this.Target as EntityPlayer;
|
||||
|
||||
if (this.Target is EntityPlayer ||
|
||||
this.Target is EntityNPCRebirth ||
|
||||
this.Target is EntityAnimalChickenRebirth
|
||||
)
|
||||
{
|
||||
value = this.Target.EntityName;
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue this.Target.EntityTags: " + this.Target.EntityTags);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = Localization.Get(EntityClass.list[this.Target.entityClass].entityClassName);
|
||||
}
|
||||
|
||||
bool showEntityName = false;
|
||||
|
||||
string useRandomNames = RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNames");
|
||||
|
||||
if (useRandomNames.ToLower() == "true")
|
||||
{
|
||||
bool excludeTags = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesTagsExclude")));
|
||||
|
||||
bool group1Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroup1Tags")));
|
||||
bool group2Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroup2Tags")));
|
||||
bool group3Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroup3Tags")));
|
||||
bool group4Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroup4Tags")));
|
||||
|
||||
bool groupNPC1Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroupNPC1Tags")));
|
||||
bool groupNPC2Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroupNPC2Tags")));
|
||||
bool groupNPC3Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroupNPC3Tags")));
|
||||
bool groupNPC4Names = this.Target.EntityTags.Test_AnySet(FastTags<TagGroup.Global>.Parse(RebirthUtilities.GetPropertyValue("AdvancedNPCFeatures", "UseRandomNamesGroupNPC4Tags")));
|
||||
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue excludeTags: " + excludeTags);
|
||||
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue group1Names: " + group1Names);
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue group2Names: " + group2Names);
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue group3Names: " + group3Names);
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue group4Names: " + group4Names);
|
||||
|
||||
if (!excludeTags &&
|
||||
(group1Names || group2Names || group3Names || group4Names ||
|
||||
groupNPC1Names || groupNPC2Names || groupNPC3Names || groupNPC4Names)
|
||||
)
|
||||
{
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue 1");
|
||||
showEntityName = true;
|
||||
}
|
||||
|
||||
if (this.Target is EntityNPCRebirth || this.Target is EntityAnimalChickenRebirth || showEntityName || this.Target is EntityZombieSDX)
|
||||
{
|
||||
//Log.Out("XUiC_TargetBarRebirthRebirth-GetBindingValue this.Target.EntityName: " + this.Target.EntityName);
|
||||
value = this.Target.EntityName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseAttribute(string _name, string _value, XUiController _parent)
|
||||
{
|
||||
if (!(_name == "visibility"))
|
||||
{
|
||||
if (!(_name == "default_boss_icon"))
|
||||
return base.ParseAttribute(_name, _value, _parent);
|
||||
this.defaultBossIcon = _value;
|
||||
return true;
|
||||
}
|
||||
this.visibility = EnumUtils.Parse<XUiC_TargetBarRebirth.EVisibility>(_value, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum EVisibility
|
||||
{
|
||||
Never,
|
||||
GodMode,
|
||||
Always,
|
||||
Boss,
|
||||
}
|
||||
}
|
||||
129
Scripts/XUIC/XUiC_ToolbeltWindowRebirth.cs
Normal file
129
Scripts/XUIC/XUiC_ToolbeltWindowRebirth.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System.Globalization;
|
||||
|
||||
public class XUiC_ToolbeltWindowRebirth : XUiController
|
||||
{
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
this.deltaTime = _dt;
|
||||
if ((DateTime.Now - this.updateTime).TotalSeconds > 0.5)
|
||||
{
|
||||
this.updateTime = DateTime.Now;
|
||||
}
|
||||
base.RefreshBindings(false);
|
||||
base.ViewComponent.IsVisible = ((!(this.localPlayer.AttachedToEntity != null) || !(this.localPlayer.AttachedToEntity is EntityVehicle)) && !this.localPlayer.IsDead());
|
||||
if (this.CustomAttributes.ContainsKey("standard_xp_color"))
|
||||
{
|
||||
this.standardXPColor = this.CustomAttributes["standard_xp_color"];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.standardXPColor = "128,4,128";
|
||||
}
|
||||
if (this.CustomAttributes.ContainsKey("updating_xp_color"))
|
||||
{
|
||||
this.updatingXPColor = this.CustomAttributes["updating_xp_color"];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.updatingXPColor = "128,4,128";
|
||||
}
|
||||
if (this.CustomAttributes.ContainsKey("deficit_xp_color"))
|
||||
{
|
||||
this.expDeficitColor = this.CustomAttributes["deficit_xp_color"];
|
||||
}
|
||||
else
|
||||
{
|
||||
this.expDeficitColor = "222,20,20";
|
||||
}
|
||||
if (this.CustomAttributes.ContainsKey("xp_fill_speed"))
|
||||
{
|
||||
this.xpFillSpeed = StringParsers.ParseFloat(this.CustomAttributes["xp_fill_speed"], 0, -1, NumberStyles.Any);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
if (this.localPlayer == null)
|
||||
{
|
||||
this.localPlayer = base.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.currentValue = (this.lastValue = XUiM_Player.GetLevelPercent(this.localPlayer));
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
if (bindingName != null)
|
||||
{
|
||||
if (bindingName == "xp")
|
||||
{
|
||||
if (this.localPlayer != null)
|
||||
{
|
||||
if (this.localPlayer.Progression.ExpDeficit > 0)
|
||||
{
|
||||
float v = Math.Max(this.lastDeficitValue, 0f) * 1.01f;
|
||||
value = this.bindingXp.Format(v);
|
||||
this.currentValue = (float)this.localPlayer.Progression.ExpDeficit / (float)this.localPlayer.Progression.GetExpForNextLevel();
|
||||
if (this.currentValue != this.lastDeficitValue)
|
||||
{
|
||||
this.lastDeficitValue = Mathf.Lerp(this.lastDeficitValue, this.currentValue, Time.deltaTime * this.xpFillSpeed);
|
||||
if (Mathf.Abs(this.currentValue - this.lastDeficitValue) < 0.005f)
|
||||
{
|
||||
this.lastDeficitValue = this.currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float v2 = Math.Max(this.lastValue, 0f) * 1.01f;
|
||||
value = this.bindingXp.Format(v2);
|
||||
this.currentValue = XUiM_Player.GetLevelPercent(this.localPlayer);
|
||||
if (this.currentValue != this.lastValue)
|
||||
{
|
||||
this.lastValue = Mathf.Lerp(this.lastValue, this.currentValue, Time.deltaTime * this.xpFillSpeed);
|
||||
if (Mathf.Abs(this.currentValue - this.lastValue) < 0.005f)
|
||||
{
|
||||
this.lastValue = this.currentValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (bindingName == "xpcolor")
|
||||
{
|
||||
if (this.localPlayer != null)
|
||||
{
|
||||
if (this.localPlayer.Progression.ExpDeficit > 0)
|
||||
{
|
||||
value = this.expDeficitColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ((this.currentValue == this.lastValue) ? this.standardXPColor : this.updatingXPColor);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private EntityPlayer localPlayer;
|
||||
private DateTime updateTime;
|
||||
private float lmpPositionAdjustment = 0.05f;
|
||||
private float lastValue;
|
||||
private float currentValue;
|
||||
private float lastDeficitValue;
|
||||
private float deltaTime;
|
||||
private string standardXPColor = "";
|
||||
private string updatingXPColor = "";
|
||||
private string expDeficitColor = "";
|
||||
private float xpFillSpeed = 2.5f;
|
||||
private CachedStringFormatter<float> bindingXp = new CachedStringFormatter<float>((float _f) => _f.ToCultureInvariantString());
|
||||
}
|
||||
325
Scripts/XUIC/XUiC_TradeAmmoRebirth.cs
Normal file
325
Scripts/XUIC/XUiC_TradeAmmoRebirth.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
|
||||
internal class XUiC_TradeAmmoRebirth : XUiController
|
||||
{
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
public float barterPerc = 0f;
|
||||
|
||||
public XUiV_Label LabelTotal;
|
||||
private XUiC_ComboBoxList<string> cbxTargetAmmoType;
|
||||
|
||||
public XUiC_ComboBoxInt combo9mm;
|
||||
public XUiC_ComboBoxInt combo762;
|
||||
public XUiC_ComboBoxInt combo44;
|
||||
public XUiC_ComboBoxInt comboShell;
|
||||
public XUiV_Label Resource;
|
||||
public XUiV_Label ResourceMultiplier;
|
||||
public XUiV_Label GatherType;
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
public XUiV_Sprite spriteAmmoImage;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-Init START");
|
||||
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;
|
||||
|
||||
spriteAmmoImage = (XUiV_Sprite)GetChildById("AmmoImage").ViewComponent;
|
||||
|
||||
LabelTotal = (XUiV_Label)Panel.Controller.GetChildById("lblTotal").ViewComponent;
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
|
||||
LabelTotal.Enabled = false;
|
||||
|
||||
this.cbxTargetAmmoType = (base.GetChildById("cbxAmmoType") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxTargetAmmoType != null)
|
||||
{
|
||||
this.cbxTargetAmmoType.Elements.Add("9mm");
|
||||
this.cbxTargetAmmoType.Elements.Add(".44");
|
||||
this.cbxTargetAmmoType.Elements.Add("762");
|
||||
this.cbxTargetAmmoType.Elements.Add("Shell");
|
||||
this.cbxTargetAmmoType.OnValueChanged += this.cbxTargetAmmoType_OnValueChanged;
|
||||
}
|
||||
|
||||
combo9mm = GetChildById("cbx9mm").GetChildByType<XUiC_ComboBoxInt>();
|
||||
combo762 = GetChildById("cbx762").GetChildByType<XUiC_ComboBoxInt>();
|
||||
combo44 = GetChildById("cbx44").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboShell = GetChildById("cbxShell").GetChildByType<XUiC_ComboBoxInt>();
|
||||
|
||||
this.combo9mm.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.combo9mm_OnValueChanged);
|
||||
this.combo762.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.combo762_OnValueChanged);
|
||||
this.combo44.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.combo44_OnValueChanged);
|
||||
this.comboShell.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboShell_OnValueChanged);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void combo9mm_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
CalculateAmmoTotal();
|
||||
}
|
||||
private void combo762_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
CalculateAmmoTotal();
|
||||
}
|
||||
private void combo44_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
CalculateAmmoTotal();
|
||||
}
|
||||
private void comboShell_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
CalculateAmmoTotal();
|
||||
}
|
||||
|
||||
private void cbxTargetAmmoType_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-XUiC_TradeAmmoRebirth cbxTargetAmmoType: " + cbxTargetAmmoType.Value);
|
||||
ResetAmmoCount(player, cbxTargetAmmoType.Value);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-Update 1");
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-OnOpen START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
{
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-OnOpen 1, entityID: " + entityID);
|
||||
}
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
float progressionLevel = 0;
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkBetterBarter");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
}
|
||||
|
||||
barterPerc = 0.5f + (progressionLevel * 0.05f);
|
||||
|
||||
LabelDescription.Text = Localization.Get("xuiTradeAmmoDescription").Replace("{0}", ((int)(barterPerc * 100)).ToString() + "%");
|
||||
|
||||
//combo9mm.Value = 0;
|
||||
cbxTargetAmmoType.SelectedIndex = 0;
|
||||
|
||||
ResetAmmoCount(player, "9mm");
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void CalculateAmmoTotal()
|
||||
{
|
||||
float total = 0;
|
||||
|
||||
string ammoType = cbxTargetAmmoType.Value;
|
||||
|
||||
combo9mm.Enabled = true;
|
||||
combo762.Enabled = true;
|
||||
combo44.Enabled = true;
|
||||
comboShell.Enabled = true;
|
||||
|
||||
if (ammoType == "9mm")
|
||||
{
|
||||
combo9mm.Max = 0;
|
||||
combo9mm.Value = 0;
|
||||
combo9mm.Enabled = false;
|
||||
|
||||
total = (combo762.Value * barterPerc * 2090 +
|
||||
combo44.Value * barterPerc * 1740 +
|
||||
comboShell.Value * barterPerc * 1500) / 1590;
|
||||
}
|
||||
if (ammoType == "762")
|
||||
{
|
||||
combo762.Max = 0;
|
||||
combo762.Value = 0;
|
||||
combo762.Enabled = false;
|
||||
|
||||
total = (combo9mm.Value * barterPerc * 1590 +
|
||||
combo44.Value * barterPerc * 1740 +
|
||||
comboShell.Value * barterPerc * 1500) / 2090;
|
||||
}
|
||||
if (ammoType == ".44")
|
||||
{
|
||||
combo44.Max = 0;
|
||||
combo44.Value = 0;
|
||||
combo44.Enabled = false;
|
||||
|
||||
total = (combo762.Value * barterPerc * 2090 +
|
||||
combo9mm.Value * barterPerc * 1590 +
|
||||
comboShell.Value * barterPerc * 1500) / 1740;
|
||||
}
|
||||
if (ammoType == "Shell")
|
||||
{
|
||||
comboShell.Max = 0;
|
||||
comboShell.Value = 0;
|
||||
comboShell.Enabled = false;
|
||||
|
||||
total = (combo762.Value * barterPerc * 2090 +
|
||||
combo44.Value * barterPerc * 1740 +
|
||||
combo9mm.Value * barterPerc * 1590) / 1500;
|
||||
}
|
||||
|
||||
LabelTotal.Text = ((int)total).ToString();
|
||||
}
|
||||
|
||||
private void ResetAmmoCount(EntityPlayer player, string ammoType)
|
||||
{
|
||||
combo9mm.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("ammo9mmBulletBall", false), player);
|
||||
combo762.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("ammo762mmBulletBall", false), player);
|
||||
combo44.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("ammo44MagnumBulletBall", false), player);
|
||||
comboShell.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("ammoShotgunShell", false), player);
|
||||
|
||||
if (ammoType == "9mm")
|
||||
{
|
||||
combo9mm.Max = 0;
|
||||
}
|
||||
if (ammoType == "762")
|
||||
{
|
||||
combo762.Max = 0;
|
||||
}
|
||||
if (ammoType == ".44")
|
||||
{
|
||||
combo44.Max = 0;
|
||||
}
|
||||
if (ammoType == "Shell")
|
||||
{
|
||||
comboShell.Max = 0;
|
||||
}
|
||||
|
||||
combo9mm.Value = combo9mm.Max;
|
||||
combo762.Value = combo762.Max;
|
||||
combo44.Value = combo44.Max;
|
||||
comboShell.Value = comboShell.Max;
|
||||
|
||||
CalculateAmmoTotal();
|
||||
|
||||
string iconName = "";
|
||||
|
||||
if (ammoType == "9mm")
|
||||
{
|
||||
iconName = "ammo9mmBulletBall";
|
||||
}
|
||||
if (ammoType == "762")
|
||||
{
|
||||
iconName = "ammo762mmBulletBall";
|
||||
}
|
||||
if (ammoType == ".44")
|
||||
{
|
||||
iconName = "ammo44MagnumBulletBall";
|
||||
}
|
||||
if (ammoType == "Shell")
|
||||
{
|
||||
iconName = "ammoShotgunShell";
|
||||
}
|
||||
|
||||
spriteAmmoImage.SpriteName = "ui_game_symbol_" + iconName;
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnConfirm_OnPressed START");
|
||||
int totalReceived = Int32.Parse(LabelTotal.Text);
|
||||
|
||||
if (totalReceived == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
string ammoType = cbxTargetAmmoType.Value;
|
||||
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnConfirm_OnPressed ammoType: " + ammoType);
|
||||
|
||||
int num9mm = (int)combo9mm.Value;
|
||||
if (num9mm > 0 && ammoType != "9mm")
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnConfirm_OnPressed dec 9mm");
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("ammo9mmBulletBall", false), num9mm, player);
|
||||
}
|
||||
|
||||
int num762 = (int)combo762.Value;
|
||||
if (num762 > 0 && ammoType != "762")
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnConfirm_OnPressed dec 762");
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("ammo762mmBulletBall", false), num762, player);
|
||||
}
|
||||
|
||||
int num44 = (int)combo44.Value;
|
||||
if (num44 > 0 && ammoType != ".44")
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnConfirm_OnPressed dec .44");
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("ammo44MagnumBulletBall", false), num44, player);
|
||||
}
|
||||
|
||||
int numShell = (int)comboShell.Value;
|
||||
if (numShell > 0 && ammoType != "Shell")
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnConfirm_OnPressed dec Shell");
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("ammoShotgunShell", false), numShell, player);
|
||||
}
|
||||
|
||||
string itemTradeFor = "";
|
||||
|
||||
if (ammoType == "9mm")
|
||||
{
|
||||
itemTradeFor = "ammo9mmBulletBall";
|
||||
}
|
||||
if (ammoType == "762")
|
||||
{
|
||||
itemTradeFor = "ammo762mmBulletBall";
|
||||
}
|
||||
if (ammoType == ".44")
|
||||
{
|
||||
itemTradeFor = "ammo44MagnumBulletBall";
|
||||
}
|
||||
if (ammoType == "Shell")
|
||||
{
|
||||
itemTradeFor = "ammoShotgunShell";
|
||||
}
|
||||
|
||||
ItemValue itemReceived = ItemClass.GetItem(itemTradeFor, false);
|
||||
|
||||
RebirthUtilities.addToPlayerInventory(itemReceived, player, totalReceived);
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-BtnCancel_OnPressed START");
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_TradeAmmoRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
451
Scripts/XUIC/XUiC_TradeDNABlueprintsForBoostsRebirth.cs
Normal file
451
Scripts/XUIC/XUiC_TradeDNABlueprintsForBoostsRebirth.cs
Normal file
@@ -0,0 +1,451 @@
|
||||
internal class XUiC_TradeDNABlueprintsForBoostsRebirth : XUiController
|
||||
{
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
|
||||
public XUiV_Label LabelTotal;
|
||||
private XUiC_ComboBoxList<string> cbxDNABoostType;
|
||||
|
||||
public XUiC_ComboBoxInt comboStrength;
|
||||
public XUiC_ComboBoxInt comboDexterity;
|
||||
public XUiC_ComboBoxInt comboConstitution;
|
||||
public XUiC_ComboBoxInt comboIntelligence;
|
||||
public XUiC_ComboBoxInt comboCharisma;
|
||||
public XUiV_Label Resource;
|
||||
public XUiV_Label ResourceMultiplier;
|
||||
public XUiV_Label GatherType;
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
public XUiV_Sprite spriteDNABoostImage;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-Init START");
|
||||
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;
|
||||
|
||||
spriteDNABoostImage = (XUiV_Sprite)GetChildById("DNABoostImage").ViewComponent;
|
||||
|
||||
LabelTotal = (XUiV_Label)Panel.Controller.GetChildById("lblTotal").ViewComponent;
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
|
||||
LabelTotal.Enabled = false;
|
||||
|
||||
this.cbxDNABoostType = (base.GetChildById("cbxDNABoostType") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxDNABoostType != null)
|
||||
{
|
||||
this.cbxDNABoostType.Elements.Add("Strength");
|
||||
this.cbxDNABoostType.Elements.Add("Dexterity");
|
||||
this.cbxDNABoostType.Elements.Add("Constitution");
|
||||
this.cbxDNABoostType.Elements.Add("Intelligence");
|
||||
this.cbxDNABoostType.Elements.Add("Charisma");
|
||||
this.cbxDNABoostType.OnValueChanged += this.cbxDNABoostType_OnValueChanged;
|
||||
}
|
||||
|
||||
comboStrength = GetChildById("cbxStrength").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboDexterity = GetChildById("cbxDexterity").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboConstitution = GetChildById("cbxConstitution").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboIntelligence = GetChildById("cbxIntelligence").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboCharisma = GetChildById("cbxCharisma").GetChildByType<XUiC_ComboBoxInt>();
|
||||
|
||||
this.comboStrength.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboStrength_OnValueChanged);
|
||||
this.comboDexterity.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboDexterity_OnValueChanged);
|
||||
this.comboConstitution.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboConstitution_OnValueChanged);
|
||||
this.comboIntelligence.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboIntelligence_OnValueChanged);
|
||||
this.comboCharisma.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboCharisma_OnValueChanged);
|
||||
}
|
||||
|
||||
private void comboStrength_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int maxUnits = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintStrength", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradable = maxUnits * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
int maxUnitsOldValue = (int)_oldValue / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradableOldValue = maxUnitsOldValue * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
/*Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged maxUnits: " + maxUnits);
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged maxTradable: " + maxTradable);
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged maxUnitsOldValue: " + maxUnitsOldValue);
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged maxTradableOldValue: " + maxTradableOldValue);
|
||||
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged _oldValue: " + _oldValue);
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged _newValue: " + _newValue);*/
|
||||
|
||||
if (_oldValue < _newValue)
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged _oldValue < _newValue maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboStrength.Value = _newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboStrength_OnValueChanged _oldValue > _newValue maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboStrength.Value = _newValue;
|
||||
}
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboDexterity_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int maxUnits = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintDexterity", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradable = maxUnits * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
int maxUnitsOldValue = (int)_oldValue / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradableOldValue = maxUnitsOldValue * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
if (_oldValue < _newValue)
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboDexterity_OnValueChanged _oldValue < _newValue maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboDexterity.Value = _newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboDexterity_OnValueChanged _oldValue > _newValue maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboDexterity.Value = _newValue;
|
||||
}
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboConstitution_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int maxUnits = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintConstitution", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradable = maxUnits * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
int maxUnitsOldValue = (int)_oldValue / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradableOldValue = maxUnitsOldValue * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
if (_oldValue < _newValue)
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboConstitution_OnValueChanged _oldValue < _newValue maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboConstitution.Value = _newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboConstitution_OnValueChanged _oldValue > _newValue maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboConstitution.Value = _newValue;
|
||||
}
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboIntelligence_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int maxUnits = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintIntelligence", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradable = maxUnits * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
int maxUnitsOldValue = (int)_oldValue / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradableOldValue = maxUnitsOldValue * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
if (_oldValue < _newValue)
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboIntelligence_OnValueChanged _oldValue < _newValue maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboIntelligence.Value = _newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboIntelligence_OnValueChanged _oldValue > _newValue maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboIntelligence.Value = _newValue;
|
||||
}
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboCharisma_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
int maxUnits = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintCharisma", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradable = maxUnits * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
int maxUnitsOldValue = (int)_oldValue / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
int maxTradableOldValue = maxUnitsOldValue * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
if (_oldValue < _newValue)
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboCharisma_OnValueChanged _oldValue < _newValue maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue++ * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboCharisma.Value = _newValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-comboCharisma_OnValueChanged _oldValue > _newValue maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio: " + maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
_newValue = maxUnitsOldValue-- * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboCharisma.Value = _newValue;
|
||||
}
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void cbxDNABoostType_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-cbxDNABoostType_OnValueChanged START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-XUiC_TradeDNABlueprintsForBoostsRebirth cbxDNABoostType: " + cbxDNABoostType.Value);
|
||||
ResetDNABlueprintsCount(player, cbxDNABoostType.Value);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-Update 1");
|
||||
}
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-OnOpen START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
{
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-OnOpen 1, entityID: " + entityID);
|
||||
}
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
LabelDescription.Text = Localization.Get("xuiTradeDNABlueprintsForBoostsDescription").Replace("{0}", RebirthVariables.geneticsBlueprintToDNABoostRatio.ToString());
|
||||
|
||||
cbxDNABoostType.SelectedIndex = 0;
|
||||
|
||||
ResetDNABlueprintsCount(player, "Strength");
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void CalculateDNABlueprintsTotal(EntityPlayer player)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-CalculateDNABlueprintsTotal START");
|
||||
float total = 0;
|
||||
|
||||
string DNABlueprintsType = cbxDNABoostType.Value;
|
||||
|
||||
comboStrength.Enabled = false;
|
||||
comboDexterity.Enabled = false;
|
||||
comboConstitution.Enabled = false;
|
||||
comboIntelligence.Enabled = false;
|
||||
comboCharisma.Enabled = false;
|
||||
|
||||
if (DNABlueprintsType == "Strength")
|
||||
{
|
||||
comboStrength.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintStrength", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboStrength.Enabled = true;
|
||||
|
||||
total = (comboStrength.Value) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
}
|
||||
if (DNABlueprintsType == "Dexterity")
|
||||
{
|
||||
comboDexterity.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintDexterity", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboDexterity.Enabled = true;
|
||||
|
||||
total = (comboDexterity.Value) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
}
|
||||
if (DNABlueprintsType == "Constitution")
|
||||
{
|
||||
comboConstitution.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintConstitution", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboConstitution.Enabled = true;
|
||||
|
||||
total = (comboConstitution.Value) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
}
|
||||
if (DNABlueprintsType == "Intelligence")
|
||||
{
|
||||
comboIntelligence.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintIntelligence", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboIntelligence.Enabled = true;
|
||||
|
||||
total = (comboIntelligence.Value) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
}
|
||||
if (DNABlueprintsType == "Charisma")
|
||||
{
|
||||
comboCharisma.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintCharisma", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboCharisma.Enabled = true;
|
||||
|
||||
total = (comboCharisma.Value) / RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
}
|
||||
|
||||
LabelTotal.Text = ((int)total).ToString();
|
||||
}
|
||||
|
||||
private void ResetDNABlueprintsCount(EntityPlayer player, string DNABlueprintsType)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-ResetDNABlueprintsCount START");
|
||||
comboStrength.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintStrength", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboDexterity.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintDexterity", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboConstitution.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintConstitution", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboIntelligence.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintIntelligence", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
comboCharisma.Max = (RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintCharisma", false), player) / RebirthVariables.geneticsBlueprintToDNABoostRatio) * RebirthVariables.geneticsBlueprintToDNABoostRatio;
|
||||
|
||||
if (DNABlueprintsType == "Strength")
|
||||
{
|
||||
comboStrength.Value = comboStrength.Max;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-ResetDNABlueprintsCount comboStrength.Value: " + comboStrength.Value);
|
||||
comboDexterity.Max = 0;
|
||||
comboConstitution.Max = 0;
|
||||
comboIntelligence.Max = 0;
|
||||
comboCharisma.Max = 0;
|
||||
comboDexterity.Value = 0;
|
||||
comboConstitution.Value = 0;
|
||||
comboIntelligence.Value = 0;
|
||||
comboCharisma.Value = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Dexterity")
|
||||
{
|
||||
comboDexterity.Value = comboDexterity.Max;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-ResetDNABlueprintsCount comboDexterity.Value: " + comboDexterity.Value);
|
||||
comboStrength.Max = 0;
|
||||
comboConstitution.Max = 0;
|
||||
comboIntelligence.Max = 0;
|
||||
comboCharisma.Max = 0;
|
||||
comboStrength.Value = 0;
|
||||
comboConstitution.Value = 0;
|
||||
comboIntelligence.Value = 0;
|
||||
comboCharisma.Value = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Constitution")
|
||||
{
|
||||
comboConstitution.Value = comboConstitution.Max;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-ResetDNABlueprintsCount comboConstitution.Value: " + comboConstitution.Value);
|
||||
comboStrength.Max = 0;
|
||||
comboDexterity.Max = 0;
|
||||
comboIntelligence.Max = 0;
|
||||
comboCharisma.Max = 0;
|
||||
comboStrength.Value = 0;
|
||||
comboDexterity.Value = 0;
|
||||
comboIntelligence.Value = 0;
|
||||
comboCharisma.Value = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Intelligence")
|
||||
{
|
||||
comboIntelligence.Value = comboIntelligence.Max;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-ResetDNABlueprintsCount comboIntelligence.Value: " + comboIntelligence.Value);
|
||||
comboStrength.Max = 0;
|
||||
comboDexterity.Max = 0;
|
||||
comboConstitution.Max = 0;
|
||||
comboCharisma.Max = 0;
|
||||
comboStrength.Value = 0;
|
||||
comboDexterity.Value = 0;
|
||||
comboConstitution.Value = 0;
|
||||
comboCharisma.Value = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Charisma")
|
||||
{
|
||||
comboCharisma.Value = comboCharisma.Max;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-ResetDNABlueprintsCount comboCharisma.Value: " + comboCharisma.Value);
|
||||
comboStrength.Max = 0;
|
||||
comboDexterity.Max = 0;
|
||||
comboConstitution.Max = 0;
|
||||
comboIntelligence.Max = 0;
|
||||
comboStrength.Value = 0;
|
||||
comboDexterity.Value = 0;
|
||||
comboConstitution.Value = 0;
|
||||
comboIntelligence.Value = 0;
|
||||
}
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
spriteDNABoostImage.SpriteName = "ui_game_symbol_FR_DNA" + cbxDNABoostType.Value + "_icon";
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed START");
|
||||
int totalReceived = Int32.Parse(LabelTotal.Text);
|
||||
|
||||
if (totalReceived == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
string DNABlueprintsType = cbxDNABoostType.Value;
|
||||
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed DNABlueprintsType: " + DNABlueprintsType);
|
||||
|
||||
string itemTradeFor = "";
|
||||
|
||||
int numStrength = (int)(comboStrength.Value / RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
if (numStrength > 0 && DNABlueprintsType == "Strength")
|
||||
{
|
||||
itemTradeFor = "FuriousRamsayPillStrength";
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed dec Strength: " + numStrength);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintStrength", false), numStrength * RebirthVariables.geneticsBlueprintToDNABoostRatio, player);
|
||||
}
|
||||
|
||||
int numDexterity = (int)(comboDexterity.Value / RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
if (numDexterity > 0 && DNABlueprintsType == "Dexterity")
|
||||
{
|
||||
itemTradeFor = "FuriousRamsayPillDexterity";
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed dec Dexterity: " + numDexterity);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintDexterity", false), numDexterity * RebirthVariables.geneticsBlueprintToDNABoostRatio, player);
|
||||
}
|
||||
|
||||
int numConstitution = (int)(comboConstitution.Value / RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
if (numConstitution > 0 && DNABlueprintsType == "Constitution")
|
||||
{
|
||||
itemTradeFor = "FuriousRamsayPillConstitution";
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed dec Constitution: " + numConstitution);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintConstitution", false), numConstitution * RebirthVariables.geneticsBlueprintToDNABoostRatio, player);
|
||||
}
|
||||
|
||||
int numIntelligence = (int)(comboIntelligence.Value / RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
if (numIntelligence > 0 && DNABlueprintsType == "Intelligence")
|
||||
{
|
||||
itemTradeFor = "FuriousRamsayPillIntelligence";
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed dec Intelligence: " + numIntelligence);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintIntelligence", false), numIntelligence * RebirthVariables.geneticsBlueprintToDNABoostRatio, player);
|
||||
}
|
||||
|
||||
int numCharisma = (int)(comboCharisma.Value / RebirthVariables.geneticsBlueprintToDNABoostRatio);
|
||||
if (numCharisma > 0 && DNABlueprintsType == "Charisma")
|
||||
{
|
||||
itemTradeFor = "FuriousRamsayPillCharisma";
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnConfirm_OnPressed dec Charisma: " + numCharisma);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintCharisma", false), numCharisma * RebirthVariables.geneticsBlueprintToDNABoostRatio, player);
|
||||
}
|
||||
|
||||
ItemValue itemReceived = ItemClass.GetItem(itemTradeFor, false);
|
||||
|
||||
RebirthUtilities.addToPlayerInventory(itemReceived, player, totalReceived);
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-BtnCancel_OnPressed START");
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsForBoostsRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
318
Scripts/XUIC/XUiC_TradeDNABlueprintsRebirth.cs
Normal file
318
Scripts/XUIC/XUiC_TradeDNABlueprintsRebirth.cs
Normal file
@@ -0,0 +1,318 @@
|
||||
|
||||
internal class XUiC_TradeDNABlueprintsRebirth : XUiController
|
||||
{
|
||||
private static float uiCheck = 0f;
|
||||
public float uiTick = 0.5f;
|
||||
public float barterPerc = 0f;
|
||||
|
||||
public XUiV_Label LabelTotal;
|
||||
private XUiC_ComboBoxList<string> cbxTargetDNABlueprintsType;
|
||||
|
||||
public XUiC_ComboBoxInt comboStrength;
|
||||
public XUiC_ComboBoxInt comboDexterity;
|
||||
public XUiC_ComboBoxInt comboConstitution;
|
||||
public XUiC_ComboBoxInt comboIntelligence;
|
||||
public XUiC_ComboBoxInt comboCharisma;
|
||||
public XUiV_Label Resource;
|
||||
public XUiV_Label ResourceMultiplier;
|
||||
public XUiV_Label GatherType;
|
||||
public XUiV_Label LabelDescription;
|
||||
public XUiV_Panel Panel;
|
||||
|
||||
public XUiV_Sprite spriteDNABlueprintImage;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-Init START");
|
||||
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;
|
||||
|
||||
spriteDNABlueprintImage = (XUiV_Sprite)GetChildById("DNABlueprintsImage").ViewComponent;
|
||||
|
||||
LabelTotal = (XUiV_Label)Panel.Controller.GetChildById("lblTotal").ViewComponent;
|
||||
LabelDescription = (XUiV_Label)Panel.Controller.GetChildById("lblDescription").ViewComponent;
|
||||
|
||||
LabelTotal.Enabled = false;
|
||||
|
||||
this.cbxTargetDNABlueprintsType = (base.GetChildById("cbxDNABlueprintsType") as XUiC_ComboBoxList<string>);
|
||||
if (this.cbxTargetDNABlueprintsType != null)
|
||||
{
|
||||
this.cbxTargetDNABlueprintsType.Elements.Add("Strength");
|
||||
this.cbxTargetDNABlueprintsType.Elements.Add("Dexterity");
|
||||
this.cbxTargetDNABlueprintsType.Elements.Add("Constitution");
|
||||
this.cbxTargetDNABlueprintsType.Elements.Add("Intelligence");
|
||||
this.cbxTargetDNABlueprintsType.Elements.Add("Charisma");
|
||||
this.cbxTargetDNABlueprintsType.OnValueChanged += this.cbxTargetDNABlueprintsType_OnValueChanged;
|
||||
}
|
||||
|
||||
comboStrength = GetChildById("cbxStrength").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboDexterity = GetChildById("cbxDexterity").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboConstitution = GetChildById("cbxConstitution").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboIntelligence = GetChildById("cbxIntelligence").GetChildByType<XUiC_ComboBoxInt>();
|
||||
comboCharisma = GetChildById("cbxCharisma").GetChildByType<XUiC_ComboBoxInt>();
|
||||
|
||||
this.comboStrength.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboStrength_OnValueChanged);
|
||||
this.comboDexterity.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboDexterity_OnValueChanged);
|
||||
this.comboConstitution.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboConstitution_OnValueChanged);
|
||||
this.comboIntelligence.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboIntelligence_OnValueChanged);
|
||||
this.comboCharisma.OnValueChanged += new XUiC_ComboBox<long>.XUiEvent_ValueChanged(this.comboCharisma_OnValueChanged);
|
||||
}
|
||||
|
||||
private void comboStrength_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboDexterity_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboConstitution_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboIntelligence_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void comboCharisma_OnValueChanged(XUiController _sender, long _oldValue, long _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
}
|
||||
|
||||
private void cbxTargetDNABlueprintsType_OnValueChanged(XUiController _sender, string _oldValue, string _newValue)
|
||||
{
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-XUiC_TradeDNABlueprintsRebirth cbxTargetDNABlueprintsType: " + cbxTargetDNABlueprintsType.Value);
|
||||
ResetDNABlueprintsCount(player, cbxTargetDNABlueprintsType.Value);
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
base.Update(_dt);
|
||||
|
||||
if ((Time.time - uiCheck) > uiTick)
|
||||
{
|
||||
uiCheck = Time.time;
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-Update 1");
|
||||
}
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-OnOpen START");
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
|
||||
var entityID = 0;
|
||||
if (player.Buffs.HasCustomVar("CurrentNPC"))
|
||||
{
|
||||
entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-OnOpen 1, entityID: " + entityID);
|
||||
}
|
||||
|
||||
if (entityID == 0)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-OnOpen 2");
|
||||
return;
|
||||
}
|
||||
|
||||
float progressionLevel = 0;
|
||||
ProgressionValue progressionValue = player.Progression.GetProgressionValue("perkBetterBarter");
|
||||
if (progressionValue != null)
|
||||
{
|
||||
progressionLevel = RebirthUtilities.GetCalculatedLevel(player, progressionValue);
|
||||
}
|
||||
|
||||
barterPerc = 0.5f + (progressionLevel * 0.05f);
|
||||
|
||||
LabelDescription.Text = Localization.Get("xuiTradeDNABlueprintsDescription").Replace("{0}", ((int)(barterPerc * 100)).ToString() + "%");
|
||||
|
||||
//comboStrength.Value = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintStrength", false), player); ;
|
||||
cbxTargetDNABlueprintsType.SelectedIndex = 0;
|
||||
|
||||
ResetDNABlueprintsCount(player, "Strength");
|
||||
|
||||
base.OnOpen();
|
||||
}
|
||||
|
||||
private void CalculateDNABlueprintsTotal(EntityPlayer player)
|
||||
{
|
||||
float total = 0;
|
||||
|
||||
string DNABlueprintsType = cbxTargetDNABlueprintsType.Value;
|
||||
|
||||
comboStrength.Enabled = true;
|
||||
comboDexterity.Enabled = true;
|
||||
comboConstitution.Enabled = true;
|
||||
comboIntelligence.Enabled = true;
|
||||
comboCharisma.Enabled = true;
|
||||
|
||||
if (DNABlueprintsType == "Strength")
|
||||
{
|
||||
comboStrength.Max = 0;
|
||||
comboStrength.Value = 0;
|
||||
comboStrength.Enabled = false;
|
||||
|
||||
total = (comboDexterity.Value + comboConstitution.Value + comboIntelligence.Value + comboCharisma.Value) * barterPerc;
|
||||
}
|
||||
if (DNABlueprintsType == "Dexterity")
|
||||
{
|
||||
comboDexterity.Max = 0;
|
||||
comboDexterity.Value = 0;
|
||||
comboDexterity.Enabled = false;
|
||||
|
||||
total = (comboStrength.Value + comboConstitution.Value + comboIntelligence.Value + comboCharisma.Value) * barterPerc;
|
||||
}
|
||||
if (DNABlueprintsType == "Constitution")
|
||||
{
|
||||
comboConstitution.Max = 0;
|
||||
comboConstitution.Value = 0;
|
||||
comboConstitution.Enabled = false;
|
||||
|
||||
total = (comboStrength.Value + comboDexterity.Value + comboIntelligence.Value + comboCharisma.Value) * barterPerc;
|
||||
}
|
||||
if (DNABlueprintsType == "Intelligence")
|
||||
{
|
||||
comboIntelligence.Max = 0;
|
||||
comboIntelligence.Value = 0;
|
||||
comboIntelligence.Enabled = false;
|
||||
|
||||
total = (comboStrength.Value + comboDexterity.Value + comboConstitution.Value + comboCharisma.Value) * barterPerc;
|
||||
}
|
||||
if (DNABlueprintsType == "Charisma")
|
||||
{
|
||||
comboCharisma.Max = 0;
|
||||
comboCharisma.Value = 0;
|
||||
comboCharisma.Enabled = false;
|
||||
|
||||
total = (comboStrength.Value + comboDexterity.Value + comboConstitution.Value + comboIntelligence.Value) * barterPerc;
|
||||
}
|
||||
|
||||
LabelTotal.Text = ((int)total).ToString();
|
||||
}
|
||||
|
||||
private void ResetDNABlueprintsCount(EntityPlayer player, string DNABlueprintsType)
|
||||
{
|
||||
comboStrength.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintStrength", false), player);
|
||||
comboDexterity.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintDexterity", false), player);
|
||||
comboConstitution.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintConstitution", false), player);
|
||||
comboIntelligence.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintIntelligence", false), player);
|
||||
comboCharisma.Max = RebirthUtilities.GetNonProtectedBagItemCount(ItemClass.GetItem("geneticBlueprintCharisma", false), player);
|
||||
|
||||
if (DNABlueprintsType == "Strength")
|
||||
{
|
||||
comboStrength.Max = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Dexterity")
|
||||
{
|
||||
comboDexterity.Max = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Constitution")
|
||||
{
|
||||
comboConstitution.Max = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Intelligence")
|
||||
{
|
||||
comboIntelligence.Max = 0;
|
||||
}
|
||||
if (DNABlueprintsType == "Charisma")
|
||||
{
|
||||
comboCharisma.Max = 0;
|
||||
}
|
||||
|
||||
comboStrength.Value = comboStrength.Max;
|
||||
comboDexterity.Value = comboDexterity.Max;
|
||||
comboConstitution.Value = comboConstitution.Max;
|
||||
comboIntelligence.Value = comboIntelligence.Max;
|
||||
comboCharisma.Value = comboCharisma.Max;
|
||||
|
||||
CalculateDNABlueprintsTotal(player);
|
||||
spriteDNABlueprintImage.SpriteName = "ui_game_symbol_FR_Blueprint" + cbxTargetDNABlueprintsType.Value;
|
||||
}
|
||||
|
||||
private void BtnConfirm_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed START");
|
||||
int totalReceived = Int32.Parse(LabelTotal.Text);
|
||||
|
||||
if (totalReceived == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EntityPlayer player = xui.playerUI.entityPlayer;
|
||||
string DNABlueprintsType = cbxTargetDNABlueprintsType.Value;
|
||||
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed DNABlueprintsType: " + DNABlueprintsType);
|
||||
|
||||
string itemTradeFor = "";
|
||||
|
||||
int numStrength = (int)(comboStrength.Value);
|
||||
if (numStrength > 0 && DNABlueprintsType != "Strength")
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed dec Strength: " + numStrength);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintStrength", false), numStrength, player);
|
||||
}
|
||||
|
||||
int numDexterity = (int)(comboDexterity.Value);
|
||||
if (numDexterity > 0 && DNABlueprintsType != "Dexterity")
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed dec Dexterity: " + numDexterity);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintDexterity", false), numDexterity, player);
|
||||
}
|
||||
|
||||
int numConstitution = (int)(comboConstitution.Value);
|
||||
if (numConstitution > 0 && DNABlueprintsType != "Constitution")
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed dec Constitution: " + numConstitution);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintConstitution", false), numConstitution, player);
|
||||
}
|
||||
|
||||
int numIntelligence = (int)(comboIntelligence.Value);
|
||||
if (numIntelligence > 0 && DNABlueprintsType != "Intelligence")
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed dec Intelligence: " + numIntelligence);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintIntelligence", false), numIntelligence, player);
|
||||
}
|
||||
|
||||
int numCharisma = (int)(comboCharisma.Value);
|
||||
if (numCharisma > 0 && DNABlueprintsType != "Charisma")
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnConfirm_OnPressed dec Charisma: " + numCharisma);
|
||||
RebirthUtilities.DecBagItem(ItemClass.GetItem("geneticBlueprintCharisma", false), numCharisma, player);
|
||||
}
|
||||
|
||||
ItemValue itemReceived = ItemClass.GetItem("geneticBlueprint" + DNABlueprintsType, false);
|
||||
|
||||
RebirthUtilities.addToPlayerInventory(itemReceived, player, totalReceived);
|
||||
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
private void BtnCancel_OnPressed(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-BtnCancel_OnPressed START");
|
||||
Panel.IsVisible = false;
|
||||
xui.playerUI.windowManager.Close(windowGroup.ID);
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
//Log.Out("XUiC_TradeDNABlueprintsRebirth-OnClose START");
|
||||
if (xui.playerUI.windowManager.HasWindow("dialog") && xui.playerUI.windowManager.IsWindowOpen("dialog"))
|
||||
xui.playerUI.windowManager.Close("dialog");
|
||||
base.OnClose();
|
||||
}
|
||||
}
|
||||
447
Scripts/XUIC/XUiC_VehicleFrameWindowRebirth.cs
Normal file
447
Scripts/XUIC/XUiC_VehicleFrameWindowRebirth.cs
Normal file
@@ -0,0 +1,447 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_VehicleFrameWindowRebirth : XUiC_AssembleWindow
|
||||
{
|
||||
public XUiC_VehicleWindowGroupRebirth group;
|
||||
private bool RefuelButtonHovered;
|
||||
private XUiV_Button btnSiphon_Background;
|
||||
private XUiV_Button btnRepair_Background;
|
||||
private XUiV_Button btnRefuel_Background;
|
||||
private XUiV_Button btnAutoLoot_Background;
|
||||
private XUiV_Button btnTopUpOil_Background;
|
||||
private EntityVehicleRebirth vehicle;
|
||||
private readonly CachedStringFormatter<string, string> vehicleNameQualityFormatter = new CachedStringFormatter<string, string>((_s1, _s2) => string.Format(_s1, _s2));
|
||||
private readonly CachedStringFormatterInt vehicleQualityFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterXuiRgbaColor vehicleQualityColorFormatter = new CachedStringFormatterXuiRgbaColor();
|
||||
private readonly CachedStringFormatter<int, int> vehicleDurabilityFormatter = new CachedStringFormatter<int, int>((_i1, _i2) => string.Format("{0}/{1}", _i1, _i2));
|
||||
private readonly CachedStringFormatterInt speedFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterInt protectionFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterInt fuelFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterInt passengersFormatter = new CachedStringFormatterInt();
|
||||
private readonly CachedStringFormatterFloat potentialFuelFillFormatter = new CachedStringFormatterFloat();
|
||||
private readonly CachedStringFormatterFloat fuelFillFormatter = new CachedStringFormatterFloat();
|
||||
private bool activeKeyDown;
|
||||
private bool wasReleased;
|
||||
|
||||
public EntityVehicleRebirth Vehicle
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.vehicle;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.vehicle = value;
|
||||
this.RefreshBindings();
|
||||
this.isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
XUiController childById = base.GetChildById("btnSiphon");
|
||||
if (childById != null)
|
||||
{
|
||||
this.btnSiphon_Background = (XUiV_Button)childById.GetChildById("clickable").ViewComponent;
|
||||
this.btnSiphon_Background.Controller.OnPress += new XUiEvent_OnPressEventHandler(this.BtnSiphon_OnPress);
|
||||
}
|
||||
|
||||
XUiController childById1 = this.GetChildById("btnRepair");
|
||||
if (childById1 != null)
|
||||
{
|
||||
this.btnRepair_Background = (XUiV_Button)childById1.GetChildById("clickable").ViewComponent;
|
||||
this.btnRepair_Background.Controller.OnPress += new XUiEvent_OnPressEventHandler(this.BtnRepair_OnPress);
|
||||
}
|
||||
|
||||
XUiController childById2 = this.GetChildById("btnTopUpOil");
|
||||
if (childById2 != null)
|
||||
{
|
||||
this.btnTopUpOil_Background = (XUiV_Button)childById2.GetChildById("clickable").ViewComponent;
|
||||
this.btnTopUpOil_Background.Controller.OnPress += new XUiEvent_OnPressEventHandler(this.BtnTopUpOil_OnPress);
|
||||
}
|
||||
|
||||
XUiController childById3 = this.GetChildById("btnAutoLoot");
|
||||
if (childById3 != null)
|
||||
{
|
||||
this.btnAutoLoot_Background = (XUiV_Button)childById3.GetChildById("clickable").ViewComponent;
|
||||
this.btnAutoLoot_Background.Controller.OnPress += new XUiEvent_OnPressEventHandler(this.BtnAutoLoot_OnPress);
|
||||
}
|
||||
|
||||
XUiController childById4 = this.GetChildById("btnRefuel");
|
||||
if (childById4 == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.btnRefuel_Background = (XUiV_Button)childById4.GetChildById("clickable").ViewComponent;
|
||||
this.btnRefuel_Background.Controller.OnPress += new XUiEvent_OnPressEventHandler(this.BtnRefuel_OnPress);
|
||||
this.btnRefuel_Background.Controller.OnHover += new XUiEvent_OnHoverEventHandler(this.btnRefuel_OnHover);
|
||||
}
|
||||
|
||||
private void BtnSiphon_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnSiphon_OnPress START");
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnSiphon_OnPress this.Vehicle.vehicle.GetFuelPercent(): " + this.Vehicle.vehicle.GetFuelPercent());
|
||||
if (this.Vehicle.vehicle.GetFuelPercent() > 0f)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnSiphon_OnPress 1");
|
||||
if ((Vehicle != null && !this.Vehicle.GetVehicle().HasEnginePart()))
|
||||
{
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnSiphon_OnPress 2");
|
||||
return;
|
||||
}
|
||||
|
||||
float fuelLevel = this.Vehicle.vehicle.GetFuelLevel() * 25;
|
||||
|
||||
int numGas = Mathf.RoundToInt(fuelLevel);
|
||||
|
||||
ItemStack gas = new ItemStack(ItemClass.GetItem("ammoGasCan"), numGas);
|
||||
LocalPlayerUI.GetUIForPlayer(_sender.xui.playerUI.entityPlayer).entityPlayer.AddUIHarvestingItem(gas, true);
|
||||
|
||||
RebirthUtilities.addToPlayerBag(ItemClass.GetItem("ammoGasCan"), _sender.xui.playerUI.entityPlayer, numGas, "useactions/gas_refill");
|
||||
|
||||
this.xui.vehicle.vehicle.SetFuelLevel(0f);
|
||||
base.RefreshBindings(true);
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnRepair_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnRepair_OnPress Vehicle.bodyDurability: " + Vehicle.bodyDurability);
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnRepair_OnPress Vehicle.maxBodyDurability: " + Vehicle.maxBodyDurability);
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnRepair_OnPress Vehicle.Health: " + Vehicle.Health);
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-BtnRepair_OnPress Vehicle.GetMaxHealth(): " + Vehicle.GetMaxHealth());
|
||||
|
||||
if (Vehicle.Health < Vehicle.GetMaxHealth() && RebirthUtilities.useInventoryBagItem(xui.playerUI.entityPlayer, "resourceRepairKit", 1))
|
||||
{
|
||||
float health = Vehicle.Health + 2500f;
|
||||
|
||||
if (health > Vehicle.GetMaxHealth())
|
||||
{
|
||||
health = Vehicle.GetMaxHealth();
|
||||
}
|
||||
|
||||
vehicle.Health = (int)health;
|
||||
//Vehicle.AddHealth(5000 - Mathf.RoundToInt(Vehicle.bodyDurability));
|
||||
//Vehicle.bodyDurability = health;
|
||||
|
||||
Vehicle.PlayOneShot("craft_complete_item", false);
|
||||
|
||||
RefreshBindings();
|
||||
isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnAutoLoot_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
string optionQoL = RebirthVariables.customQualityOfLife;
|
||||
|
||||
if (optionQoL == "none" || optionQoL == "quickstackonly")
|
||||
{
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
GameManager.ShowTooltip(primaryPlayer, Localization.Get("xuiFeatureOff"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.vehicle != null)
|
||||
{
|
||||
EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer();
|
||||
|
||||
if (primaryPlayer != null)
|
||||
{
|
||||
ProgressionValue progressionValue = primaryPlayer.Progression.GetProgressionValue("perkPackMule");
|
||||
|
||||
if (RebirthUtilities.GetCalculatedLevel(primaryPlayer, progressionValue) >= 4)
|
||||
{
|
||||
float isAutoLootOn = this.vehicle.Buffs.GetCustomVar("$autoLoot");
|
||||
|
||||
if (isAutoLootOn == 0)
|
||||
{
|
||||
this.vehicle.Buffs.SetCustomVar("$autoLoot", 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.vehicle.Buffs.SetCustomVar("$autoLoot", 0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.vehicle.Buffs.SetCustomVar("$autoLoot", 0f);
|
||||
GameManager.ShowTooltip(primaryPlayer, Localization.Get("xuiAutoLootDenied"), string.Empty, "ui_denied", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshBindings();
|
||||
isDirty = true;
|
||||
}
|
||||
|
||||
private void BtnTopUpOil_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
if (Vehicle.OilPerc < 1f)
|
||||
{
|
||||
if (RebirthUtilities.useInventoryBagItem(xui.playerUI.entityPlayer, "resourceOil", 1))
|
||||
{
|
||||
Vehicle.OilPerc += 0.25f;
|
||||
Vehicle.OilPerc = Mathf.Clamp01(Vehicle.OilPerc);
|
||||
|
||||
xui.playerUI.entityPlayer.PlayOneShot("useactions/gas_refill", false);
|
||||
|
||||
if (!SingletonMonoBehaviour<ConnectionManager>.Instance.IsServer)
|
||||
{
|
||||
int playerID = this.xui.playerUI.entityPlayer.entityId;
|
||||
int currentVehicleID = vehicle.entityId;
|
||||
|
||||
NetPackageVehicleUpdateStatsRebirth package = NetPackageManager.GetPackage<NetPackageVehicleUpdateStatsRebirth>().Setup(playerID, currentVehicleID, Vehicle.OilPerc);
|
||||
SingletonMonoBehaviour<ConnectionManager>.Instance.SendToServer(package, false);
|
||||
}
|
||||
|
||||
this.RefreshBindings();
|
||||
isDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RebirthUtilities.notifyMissingItem(ItemClass.GetItem("resourceOil"), this.xui.playerUI.entityPlayer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnRefuel_OnHover(XUiController _sender, bool _isOver)
|
||||
{
|
||||
if (Vehicle != null && !this.Vehicle.GetVehicle().HasEnginePart())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.RefuelButtonHovered = _isOver;
|
||||
this.RefreshBindings();
|
||||
}
|
||||
|
||||
private void BtnRefuel_OnPress(XUiController _sender, int _mouseButton)
|
||||
{
|
||||
if (this.Vehicle.vehicle.GetFuelPercent() < 1f)
|
||||
{
|
||||
if (!RebirthUtilities.hasItem(ItemClass.GetItem("ammoGasCan"), this.xui.playerUI.entityPlayer))
|
||||
{
|
||||
RebirthUtilities.notifyMissingItem(ItemClass.GetItem("ammoGasCan"), this.xui.playerUI.entityPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Vehicle != null && !this.Vehicle.GetVehicle().HasEnginePart()) || !this.xui.vehicle.AddFuelFromInventory(xui.playerUI.entityPlayer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.RefreshBindings();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
global::Vehicle vehicle = (UnityEngine.Object)this.vehicle != (UnityEngine.Object)null ? this.vehicle.GetVehicle() : (global::Vehicle)null;
|
||||
switch (bindingName)
|
||||
{
|
||||
case "oil":
|
||||
if (this.Vehicle != null)
|
||||
{
|
||||
value = ((int)(this.Vehicle.OilPerc * 100)).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "N/A";
|
||||
}
|
||||
|
||||
return true;
|
||||
case "oiltitle":
|
||||
value = Localization.Get("xuiOil");
|
||||
return true;
|
||||
case "bodydurability":
|
||||
if (this.Vehicle != null)
|
||||
{
|
||||
value = ((int)this.Vehicle.bodyDurability).ToString() + "/" + ((int)this.Vehicle.maxBodyDurability).ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "N/A";
|
||||
}
|
||||
|
||||
return true;
|
||||
case "bodydurabilitytitle":
|
||||
value = Localization.Get("xuiBodyDurability");
|
||||
return true;
|
||||
case "fuel":
|
||||
value = this.fuelFormatter.Format((int)XUiM_Vehicle.GetFuelLevel(this.xui));
|
||||
return true;
|
||||
case "fuelfill":
|
||||
value = this.fuelFillFormatter.Format(XUiM_Vehicle.GetFuelFill(this.xui));
|
||||
return true;
|
||||
case "fueltitle":
|
||||
value = Localization.Get("xuiGas");
|
||||
return true;
|
||||
case "locktype":
|
||||
value = Localization.Get("none");
|
||||
return true;
|
||||
case "noise":
|
||||
value = XUiM_Vehicle.GetNoise(this.xui);
|
||||
return true;
|
||||
case "noisetitle":
|
||||
value = Localization.Get("xuiNoise");
|
||||
return true;
|
||||
case "passengers":
|
||||
value = this.passengersFormatter.Format(XUiM_Vehicle.GetPassengers(xui));
|
||||
return true;
|
||||
case "passengerstitle":
|
||||
value = Localization.Get("xuiSeats");
|
||||
return true;
|
||||
case "potentialfuelfill":
|
||||
value = this.RefuelButtonHovered ? this.potentialFuelFillFormatter.Format(vehicle.GetFuelPercent()) : "0";
|
||||
return true;
|
||||
case "protection":
|
||||
value = this.protectionFormatter.Format((int)XUiM_Vehicle.GetProtection(this.xui));
|
||||
return true;
|
||||
case "protectiontitle":
|
||||
value = Localization.Get("xuiDefense");
|
||||
return true;
|
||||
case "refueltext":
|
||||
value = !(Vehicle != null) || !this.Vehicle.GetVehicle().HasEnginePart() ? Localization.Get("xuiRefuelNotAllowed") : Localization.Get("xuiRefuel");
|
||||
return true;
|
||||
case "showfuel":
|
||||
value = (Vehicle != null && this.Vehicle.GetVehicle().HasEnginePart()).ToString();
|
||||
return true;
|
||||
case "speed":
|
||||
value = this.speedFormatter.Format((int)XUiM_Vehicle.GetSpeed(this.xui));
|
||||
return true;
|
||||
case "speedtext":
|
||||
value = XUiM_Vehicle.GetSpeedText(this.xui);
|
||||
return true;
|
||||
case "speedtitle":
|
||||
value = Localization.Get("xuiSpeed");
|
||||
return true;
|
||||
case "storage":
|
||||
value = "BASKET";
|
||||
return true;
|
||||
case "vehicledurability":
|
||||
value = vehicle != null ? this.vehicleDurabilityFormatter.Format(vehicle.entity.Health, vehicle.GetMaxHealth()) : "";
|
||||
return true;
|
||||
case "vehicledurabilitytitle":
|
||||
value = Localization.Get("xuiDurability");
|
||||
return true;
|
||||
case "vehicleicon":
|
||||
value = this.vehicle != null ? this.vehicle.GetMapIcon() : "";
|
||||
return true;
|
||||
case "vehiclename":
|
||||
value = Localization.Get(XUiM_Vehicle.GetEntityName(this.xui));
|
||||
return true;
|
||||
case "vehiclenamequality":
|
||||
value = "";
|
||||
return true;
|
||||
case "vehiclequality":
|
||||
value = "";
|
||||
return true;
|
||||
case "vehiclequalitycolor":
|
||||
if (this.vehicle != null)
|
||||
{
|
||||
Color32 qualityColor = (Color32)QualityInfo.GetQualityColor(vehicle.GetVehicleQuality());
|
||||
value = this.vehicleQualityColorFormatter.Format(qualityColor);
|
||||
}
|
||||
|
||||
return true;
|
||||
case "vehiclequalitytitle":
|
||||
value = "";
|
||||
return true;
|
||||
case "vehiclestatstitle":
|
||||
value = Localization.Get("xuiStats");
|
||||
return true;
|
||||
case "autoLootColor":
|
||||
if (this.vehicle != null)
|
||||
{
|
||||
float isAutoLootOn = this.vehicle.Buffs.GetCustomVar("$autoLoot");
|
||||
|
||||
if (isAutoLootOn == 1f)
|
||||
{
|
||||
value = "54, 97, 40";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
value = "97, 40, 40";
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
if (this.isDirty)
|
||||
{
|
||||
this.btnRefuel_Background.Enabled = Vehicle != null && this.Vehicle.GetVehicle().HasEnginePart();
|
||||
}
|
||||
|
||||
if (this.windowGroup.isShowing)
|
||||
{
|
||||
if (!base.xui.playerUI.playerInput.PermanentActions.Activate.IsPressed)
|
||||
{
|
||||
this.wasReleased = true;
|
||||
}
|
||||
|
||||
if (this.wasReleased)
|
||||
{
|
||||
if (base.xui.playerUI.playerInput.PermanentActions.Activate.IsPressed)
|
||||
{
|
||||
this.activeKeyDown = true;
|
||||
}
|
||||
|
||||
if (base.xui.playerUI.playerInput.PermanentActions.Activate.WasReleased && this.activeKeyDown)
|
||||
{
|
||||
this.activeKeyDown = false;
|
||||
base.xui.playerUI.windowManager.CloseAllOpenWindows(null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.Update(_dt);
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
this.isDirty = true;
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
this.wasReleased = false;
|
||||
this.activeKeyDown = false;
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
public override ItemStack ItemStack
|
||||
{
|
||||
set
|
||||
{
|
||||
this.vehicle.GetVehicle().SetItemValueMods(value.itemValue);
|
||||
base.ItemStack = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChanged()
|
||||
{
|
||||
//Log.Out("XUiC_VehicleFrameWindowRebirth-OnChanged this.ItemStack.count:" + this.ItemStack.count);
|
||||
|
||||
this.group = base.GetParentByType<XUiC_VehicleWindowGroupRebirth>();
|
||||
|
||||
this.group.OnItemChanged(this.ItemStack);
|
||||
this.isDirty = true;
|
||||
}
|
||||
}
|
||||
137
Scripts/XUIC/XUiC_VehicleHUD.cs
Normal file
137
Scripts/XUIC/XUiC_VehicleHUD.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using Quartz.Settings;
|
||||
|
||||
|
||||
internal class XUiC_VehicleHUD : XUiController
|
||||
{
|
||||
private EntityPlayerLocal LocalPlayer;
|
||||
|
||||
public override bool GetBindingValue(ref string value, string bindingName)
|
||||
{
|
||||
bool hasVehicle = false;
|
||||
|
||||
if (this.LocalPlayer != null)
|
||||
{
|
||||
bool isAttached = this.LocalPlayer.AttachedToEntity;
|
||||
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue isAttached: " + isAttached);
|
||||
|
||||
if (isAttached)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue Attached to Entity Class: " + __instance.LocalPlayer.AttachedToEntity.EntityClass.entityClassName);
|
||||
if (this.LocalPlayer.AttachedToEntity is EntityVehicle)
|
||||
{
|
||||
hasVehicle = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (bindingName)
|
||||
{
|
||||
case "autoRunText":
|
||||
value = "";
|
||||
|
||||
if (hasVehicle)
|
||||
{
|
||||
if (RebirthVariables.autoRun == 1)
|
||||
{
|
||||
value = Localization.Get("ttCruiseNormal");
|
||||
}
|
||||
else if (RebirthVariables.autoRun == 2f)
|
||||
{
|
||||
value = Localization.Get("ttCruiseFast");
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue autoRunText value: " + value);
|
||||
|
||||
return true;
|
||||
case "autoRunColor":
|
||||
value = "242, 236, 167, 128";
|
||||
|
||||
if (hasVehicle)
|
||||
{
|
||||
if (RebirthVariables.autoRun == 1)
|
||||
{
|
||||
value = "242, 236, 167, 128";
|
||||
}
|
||||
else if (RebirthVariables.autoRun == 2f)
|
||||
{
|
||||
value = "86, 145, 78, 128";
|
||||
}
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue autoRunText value: " + value);
|
||||
|
||||
return true;
|
||||
case "autoRunPosition":
|
||||
value = "0,-10000";
|
||||
|
||||
if (hasVehicle)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue B VEHICLE EXISTS");
|
||||
if (RebirthVariables.autoRun > 0)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue AUTORUN > 0");
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue entityClassName: " + this.LocalPlayer.AttachedToEntity.EntityClass.entityClassName);
|
||||
if (this.LocalPlayer.AttachedToEntity.EntityClass.entityClassName.ToLower() == "vehiclebicycle")
|
||||
{
|
||||
value = "0,250";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (MinimapSettings.Enabled)
|
||||
{
|
||||
value = "0,300";
|
||||
}
|
||||
else
|
||||
{
|
||||
value = "0,50";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue AUTORUN == 0");
|
||||
value = "0,-10000";
|
||||
}
|
||||
|
||||
//Log.Out("XUiC_VehicleHUD-GetBindingValue showAutoRun value: " + value);
|
||||
}
|
||||
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-OnOpen START");
|
||||
base.OnOpen();
|
||||
if (this.LocalPlayer == null && XUi.IsGameRunning())
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-OnOpen 1");
|
||||
this.LocalPlayer = this.xui.playerUI.entityPlayer;
|
||||
}
|
||||
this.IsDirty = true;
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
|
||||
private float currentTime;
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-Update START");
|
||||
this.currentTime -= _dt;
|
||||
base.Update(_dt);
|
||||
if (this.LocalPlayer == null)
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-Update 1");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("XUiC_VehicleHUD-Update 2");
|
||||
this.RefreshBindings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
117
Scripts/XUIC/XUiC_VehicleWindowGroupRebirth.cs
Normal file
117
Scripts/XUIC/XUiC_VehicleWindowGroupRebirth.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
[Preserve]
|
||||
public class XUiC_VehicleWindowGroupRebirth : XUiController
|
||||
{
|
||||
public EntityVehicle CurrentVehicleEntity
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.currentVehicleEntity;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.xui.vehicle = value;
|
||||
this.currentVehicleEntity = value;
|
||||
this.frameWindow.Vehicle = (EntityVehicleRebirth)value;
|
||||
Vehicle vehicle = value.GetVehicle();
|
||||
ItemValue updatedItemValue = vehicle.GetUpdatedItemValue();
|
||||
ItemStack currentItem = new ItemStack(updatedItemValue, 1);
|
||||
this.partGrid.AssembleWindow = this.frameWindow;
|
||||
this.partGrid.CurrentVehicle = vehicle;
|
||||
this.partGrid.CurrentItem = currentItem;
|
||||
this.partGrid.SetMods(updatedItemValue.Modifications);
|
||||
this.cosmeticGrid.AssembleWindow = this.frameWindow;
|
||||
this.cosmeticGrid.CurrentItem = currentItem;
|
||||
this.cosmeticGrid.SetParts(updatedItemValue.CosmeticMods);
|
||||
XUiM_AssembleItem assembleItem = base.xui.AssembleItem;
|
||||
assembleItem.AssembleWindow = this.frameWindow;
|
||||
assembleItem.CurrentItem = currentItem;
|
||||
assembleItem.CurrentItemStackController = null;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
this.nonPagingHeaderWindow = base.GetChildByType<XUiC_WindowNonPagingHeader>();
|
||||
this.headerName = Localization.Get("xuiVehicle");
|
||||
this.frameWindow = base.GetChildByType<XUiC_VehicleFrameWindowRebirth>();
|
||||
this.partGrid = base.GetChildByType<XUiC_VehiclePartStackGrid>();
|
||||
this.cosmeticGrid = base.GetChildByType<XUiC_ItemCosmeticStackGrid>();
|
||||
}
|
||||
|
||||
public override void Update(float _dt)
|
||||
{
|
||||
if (this.windowGroup.isShowing)
|
||||
{
|
||||
if (!base.xui.playerUI.playerInput.PermanentActions.Activate.IsPressed)
|
||||
{
|
||||
this.wasReleased = true;
|
||||
}
|
||||
if (this.wasReleased)
|
||||
{
|
||||
if (base.xui.playerUI.playerInput.PermanentActions.Activate.IsPressed)
|
||||
{
|
||||
this.activeKeyDown = true;
|
||||
}
|
||||
if (base.xui.playerUI.playerInput.PermanentActions.Activate.WasReleased && this.activeKeyDown)
|
||||
{
|
||||
this.activeKeyDown = false;
|
||||
if (!base.xui.playerUI.windowManager.IsInputActive())
|
||||
{
|
||||
base.xui.playerUI.windowManager.CloseAllOpenWindows(null, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.currentVehicleEntity != null && !this.currentVehicleEntity.CheckUIInteraction())
|
||||
{
|
||||
base.xui.playerUI.windowManager.Close(XUiC_VehicleWindowGroupRebirth.ID);
|
||||
}
|
||||
base.Update(_dt);
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
if (this.nonPagingHeaderWindow != null)
|
||||
{
|
||||
this.nonPagingHeaderWindow.SetHeader(this.headerName);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
XUiM_AssembleItem assembleItem = base.xui.AssembleItem;
|
||||
assembleItem.AssembleWindow = null;
|
||||
if (assembleItem.CurrentItem.itemValue == base.xui.vehicle.GetVehicle().GetUpdatedItemValue())
|
||||
{
|
||||
assembleItem.CurrentItem = null;
|
||||
assembleItem.CurrentItemStackController = null;
|
||||
}
|
||||
this.wasReleased = false;
|
||||
this.activeKeyDown = false;
|
||||
this.CurrentVehicleEntity.StopUIInteraction();
|
||||
base.xui.vehicle = null;
|
||||
}
|
||||
|
||||
public void OnItemChanged(ItemStack itemStack)
|
||||
{
|
||||
this.partGrid.CurrentItem = itemStack;
|
||||
this.partGrid.SetMods(itemStack.itemValue.Modifications);
|
||||
this.cosmeticGrid.CurrentItem = itemStack;
|
||||
this.cosmeticGrid.SetParts(itemStack.itemValue.CosmeticMods);
|
||||
}
|
||||
|
||||
public static string ID = "vehicle";
|
||||
private XUiC_VehicleFrameWindowRebirth frameWindow;
|
||||
private XUiC_WindowNonPagingHeader nonPagingHeaderWindow;
|
||||
private XUiC_VehiclePartStackGrid partGrid;
|
||||
private XUiC_ItemCosmeticStackGrid cosmeticGrid;
|
||||
private string headerName;
|
||||
private EntityVehicle currentVehicleEntity;
|
||||
private bool activeKeyDown;
|
||||
private bool wasReleased;
|
||||
}
|
||||
72
Scripts/XUIC/XUiC_WorkstationFuelGridRebirth.cs
Normal file
72
Scripts/XUIC/XUiC_WorkstationFuelGridRebirth.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using UnityEngine.Scripting;
|
||||
|
||||
#nullable disable
|
||||
[Preserve]
|
||||
public class XUiC_WorkstationFuelGridRebirth : XUiC_WorkstationFuelGrid
|
||||
{
|
||||
public string requiredFuels = "";
|
||||
[PublicizedFrom(EAccessModifier.Private)]
|
||||
public bool requiredFuelsOnly;
|
||||
|
||||
public event XuiEvent_WorkstationItemsChanged OnWorkstationFuelsChanged;
|
||||
public override void Init()
|
||||
{
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-Init START");
|
||||
base.Init();
|
||||
string[] strArray = this.requiredFuels.Split(',', StringSplitOptions.None);
|
||||
for (int index = 0; index < this.itemControllers.Length; ++index)
|
||||
{
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-Init index: " + index);
|
||||
if (index < strArray.Length)
|
||||
{
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-Init GetItemClass: " + ItemClass.GetItemClass(strArray[index]));
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-Init this.requiredFuelsOnly: " + this.requiredFuelsOnly);
|
||||
|
||||
((XUiC_RequiredItemStack)this.itemControllers[index]).RequiredItemClass = ItemClass.GetItemClass(strArray[index]);
|
||||
((XUiC_RequiredItemStack)this.itemControllers[index]).RequiredItemOnly = this.requiredFuelsOnly;
|
||||
}
|
||||
else
|
||||
{
|
||||
((XUiC_RequiredItemStack)this.itemControllers[index]).RequiredItemClass = (ItemClass)null;
|
||||
((XUiC_RequiredItemStack)this.itemControllers[index]).RequiredItemOnly = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*public bool AddItem(ItemClass _itemClass, ItemStack _itemStack)
|
||||
{
|
||||
Log.Out("XUiC_WorkstationFuelGridRebirth-AddItem START");
|
||||
if (!this.requiredFuelsOnly)
|
||||
{
|
||||
Log.Out("XUiC_WorkstationFuelGridRebirth-AddItem REQUIRED ONLY");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log.Out("XUiC_WorkstationFuelGridRebirth-AddItem BYPASSED");
|
||||
|
||||
this.TryStackItem(this.isOn ? 1 : 0, _itemStack);
|
||||
return _itemStack.count > 0 && this.AddItem(_itemStack);
|
||||
}*/
|
||||
|
||||
public override bool ParseAttribute(string name, string value, XUiController _parent)
|
||||
{
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-ParseAttribute START, name: " + name);
|
||||
bool attribute = base.ParseAttribute(name, value, _parent);
|
||||
if (attribute)
|
||||
return attribute;
|
||||
switch (name)
|
||||
{
|
||||
case "required_fuels":
|
||||
this.requiredFuels = value;
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-Init this.requiredFuels: " + this.requiredFuels);
|
||||
break;
|
||||
case "required_fuels_only":
|
||||
this.requiredFuelsOnly = StringParsers.ParseBool(value);
|
||||
//Log.Out("XUiC_WorkstationFuelGridRebirth-Init this.requiredFuelsOnly: " + this.requiredFuelsOnly);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user