736 lines
33 KiB
C#
736 lines
33 KiB
C#
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;
|
|
}
|
|
}
|