Properties Panel Overhaul
Marking player location on galaxy map Fixed non-input field focus disabling global key map Player start ship is now always the same Loadout generator now demands exact match for item dimensions Thermal damage now triggers ItemDamaged event = player can die from cockpit wear! Properties panel now has a much more attractive UI Implemented curve control for properties UI Centralized number formatting in player settings Moved significant digits to player settings Added temperature unit option in player settings
This commit is contained in:
parent
ec1f8f56d4
commit
54f7e3a66f
152 changed files with 8691 additions and 179 deletions
|
|
@ -34,9 +34,11 @@ public class PropertiesPanel : MonoBehaviour
|
|||
public PropertyButton PropertyButton;
|
||||
public ButtonField ButtonField;
|
||||
public IncrementField IncrementField;
|
||||
public StatSheet StatSheet;
|
||||
public CurveField CurveField;
|
||||
public RectTransform Content;
|
||||
[HideInInspector] public FlatFlatButton SelectedChild;
|
||||
[HideInInspector] public ItemManager Context;
|
||||
[HideInInspector] public ActionGameManager GameManager;
|
||||
|
||||
protected List<GameObject> Properties = new List<GameObject>();
|
||||
protected List<FlatFlatButton> Buttons = new List<FlatFlatButton>();
|
||||
|
|
@ -133,10 +135,19 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return property;
|
||||
}
|
||||
|
||||
public StatSheet AddStatSheet()
|
||||
{
|
||||
var sheet = Instantiate(StatSheet, Content ?? transform);
|
||||
Properties.Add(sheet.gameObject);
|
||||
OnPropertyAdded?.Invoke(sheet.gameObject);
|
||||
RefreshPropertyValues += () => sheet.RefreshValues();
|
||||
return sheet;
|
||||
}
|
||||
|
||||
public PropertiesList AddList(string name) //, IEnumerable<(string, Func<string>)> elements)
|
||||
{
|
||||
var list = Instantiate(List, Content ?? transform);
|
||||
list.Context = Context;
|
||||
list.GameManager = GameManager;
|
||||
list.Dropdown = Dropdown;
|
||||
list.Title.text = name;
|
||||
// foreach (var element in elements)
|
||||
|
|
@ -165,6 +176,13 @@ public class PropertiesPanel : MonoBehaviour
|
|||
return attributeInstance;
|
||||
}
|
||||
|
||||
public CurveField AddCurveField()
|
||||
{
|
||||
var curveInstance = Instantiate(CurveField, Content ?? transform);
|
||||
Properties.Add(curveInstance.gameObject);
|
||||
return curveInstance;
|
||||
}
|
||||
|
||||
public virtual PropertyButton AddButton(string name, Action onClick)
|
||||
{
|
||||
var button = Instantiate(PropertyButton, Content ?? transform);
|
||||
|
|
@ -344,42 +362,43 @@ public class PropertiesPanel : MonoBehaviour
|
|||
OnPropertyAdded?.Invoke(field.gameObject);
|
||||
}
|
||||
|
||||
public void Inspect(Entity entity)
|
||||
{
|
||||
Clear();
|
||||
Title.text = entity.Name;
|
||||
var hullData = Context.GetData(entity.Hull) as HullData;
|
||||
AddSection(
|
||||
hullData.HullType == HullType.Ship ? "Ship" :
|
||||
hullData.HullType == HullType.Station ? "Station" :
|
||||
"Platform");
|
||||
//AddList(hullData.Name).Inspect(hull, entity);
|
||||
//PropertiesPanel.AddProperty("Hull", () => $"{hullData.Name}");
|
||||
AddEntityProperties(entity);
|
||||
//cargoList.SetExpanded(false,true);
|
||||
|
||||
RefreshValues();
|
||||
}
|
||||
// public void Inspect(Entity entity)
|
||||
// {
|
||||
// Clear();
|
||||
// Title.text = entity.Name;
|
||||
// var hullData = Context.GetData(entity.Hull) as HullData;
|
||||
// AddSection(
|
||||
// hullData.HullType == HullType.Ship ? "Ship" :
|
||||
// hullData.HullType == HullType.Station ? "Station" :
|
||||
// "Platform");
|
||||
// //AddList(hullData.Name).Inspect(hull, entity);
|
||||
// //PropertiesPanel.AddProperty("Hull", () => $"{hullData.Name}");
|
||||
// AddEntityProperties(entity);
|
||||
// //cargoList.SetExpanded(false,true);
|
||||
//
|
||||
// RefreshValues();
|
||||
// }
|
||||
|
||||
private void AddEntityProperties(Entity entity)
|
||||
{
|
||||
AddField("Name", () => entity.Name, name => entity.Name = name);
|
||||
AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
}
|
||||
// private void AddEntityProperties(Entity entity)
|
||||
// {
|
||||
// AddField("Name", () => entity.Name, name => entity.Name = name);
|
||||
// AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
// }
|
||||
|
||||
private void AddItemProperties(ItemInstance item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
var data = ActionGameManager.CultCache.Get<ItemData>(item.Data);
|
||||
|
||||
AddProperty(data.Description);
|
||||
|
||||
var manufacturer = Context.ItemData.Get<Faction>(data.Manufacturer);
|
||||
AddProperty("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
|
||||
if (item is SimpleCommodity simpleCommodity)
|
||||
AddProperty("Quantity", () => simpleCommodity.Quantity.ToString());
|
||||
|
||||
AddProperty("Mass", () => Context.GetMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
var sheet = AddStatSheet();
|
||||
var manufacturer = ActionGameManager.CultCache.Get<Faction>(data.Manufacturer);
|
||||
sheet.AddStat("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
sheet.AddStat("Mass", () => ActionGameManager.PlayerSettings.Format(GameManager.ItemManager.GetMass(item)));
|
||||
|
||||
//AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
}
|
||||
|
||||
|
|
@ -387,38 +406,49 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
if (item.Durability < .01f)
|
||||
{
|
||||
AddProperty("Item destroyed!");
|
||||
return;
|
||||
}
|
||||
|
||||
var gearData = Context.GetData(item);
|
||||
AddProperty("Durability", () => $"{(int)(item.Durability / gearData.Durability * 100)}%");
|
||||
var gearData = GameManager.ItemManager.GetData(item);
|
||||
|
||||
var sheet = AddStatSheet();
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
if (behavior is StatModifierData statMod)
|
||||
{
|
||||
sheet.AddStat($"{statMod.Stat.Target.SplitCamelCase()}:{statMod.Stat.Stat.SplitCamelCase()}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.PlayerSettings.Format(statValueFunction(statMod.Modifier))}");
|
||||
}
|
||||
else
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) == null) continue;
|
||||
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
|
||||
{
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior))}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
AddProperty(field.Name, () => $"{statValueFunction(stat).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name.SplitCamelCase(), () => $"{ActionGameManager.PlayerSettings.Format(statValueFunction(stat))}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gearData.Behaviors.FirstOrDefault(b => b is WeaponData) is WeaponData weapon)
|
||||
{
|
||||
var range = AddCurveField();
|
||||
range.Show("Damage Range", weapon.DamageCurve, t => ActionGameManager.PlayerSettings.Format(lerp(statValueFunction(weapon.MinRange), statValueFunction(weapon.Range), t)));
|
||||
}
|
||||
}
|
||||
|
||||
private string GetTitle(EquippableItem item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
var (tier, upgrades) = Context.GetTier(item);
|
||||
var data = ActionGameManager.CultCache.Get<ItemData>(item.Data);
|
||||
var (tier, upgrades) = GameManager.ItemManager.GetTier(item);
|
||||
return
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
}
|
||||
|
|
@ -433,11 +463,24 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddItemProperties(item.EquippableItem);
|
||||
AddSpacer();
|
||||
|
||||
var gearData = GameManager.ItemManager.GetData(item.EquippableItem);
|
||||
var statusSheet = AddStatSheet();
|
||||
if (item.EquippableItem.Durability < .01f)
|
||||
statusSheet.AddStat("Durability", () => "Item Destroyed!");
|
||||
else statusSheet.AddStat("Durability", () => $"{(int)(item.EquippableItem.Durability / gearData.Durability * 100)}%");
|
||||
statusSheet.AddStat("Temperature", () => ActionGameManager.PlayerSettings.FormatTemperature(item.Temperature));
|
||||
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
gearData.HeatPerformanceCurve,
|
||||
t => ActionGameManager.PlayerSettings.FormatTemperature(lerp(gearData.MinimumTemperature, gearData.MaximumTemperature, t)),
|
||||
true);
|
||||
RefreshPropertyValues += () => heatCurve.SetCurrent(unlerp(gearData.MinimumTemperature, gearData.MaximumTemperature, item.Temperature));
|
||||
AddEquippableItemProperties(item.EquippableItem, item.Evaluate);
|
||||
AddSpacer();
|
||||
|
||||
AddField("Override Shutdown", () => item.EquippableItem.OverrideShutdown, b => item.EquippableItem.OverrideShutdown = b);
|
||||
AddProperty("Temperature", () => (item.Temperature - 273.15f).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
|
||||
foreach (var behavior in item.Behaviors)
|
||||
{
|
||||
|
|
@ -464,7 +507,16 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
Title.text = GetTitle(gear);
|
||||
AddSpacer();
|
||||
AddEquippableItemProperties(gear, stat => Context.Evaluate(stat, gear));
|
||||
var gearData = GameManager.ItemManager.GetData(gear);
|
||||
var statusSheet = AddStatSheet();
|
||||
statusSheet.AddStat("Durability", () => $"{(int)(gear.Durability / gearData.Durability * 100)}%");
|
||||
var heatCurve = AddCurveField();
|
||||
heatCurve.Show(
|
||||
"Thermal Performance",
|
||||
gearData.HeatPerformanceCurve,
|
||||
t => ActionGameManager.PlayerSettings.FormatTemperature(lerp(gearData.MinimumTemperature, gearData.MaximumTemperature, t)),
|
||||
true);
|
||||
AddEquippableItemProperties(gear, stat => GameManager.ItemManager.Evaluate(stat, gear));
|
||||
}
|
||||
|
||||
RefreshValues();
|
||||
|
|
@ -476,15 +528,16 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddProperty(data.Description).Label.fontStyle = FontStyles.Normal;
|
||||
if (data is EquippableItemData gearData)
|
||||
{
|
||||
AddProperty("Durability", () => gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
AddProperty("Durability", () => ActionGameManager.PlayerSettings.Format(gearData.Durability));
|
||||
var sheet = AddStatSheet();
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
{
|
||||
if (behavior is StatModifierData statMod)
|
||||
{
|
||||
if(Math.Abs(statMod.Modifier.Min - statMod.Modifier.Max) < .001f)
|
||||
AddProperty("Stat Mod", () => $"{statMod.Stat.Target}:{statMod.Stat.Stat}{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{statMod.Modifier.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat($"{statMod.Stat.Target}:{statMod.Stat.Stat}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.PlayerSettings.Format(statMod.Modifier.Min)}");
|
||||
else
|
||||
AddProperty("Stat Mod", () => $"{statMod.Stat.Target}:{statMod.Stat.Stat}{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{statMod.Modifier.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}-{statMod.Modifier.Max.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat($"{statMod.Stat.Target}:{statMod.Stat.Stat}", () => $"{(statMod.Type == StatModifierType.Constant ? "+" : "x")}{ActionGameManager.PlayerSettings.Format(statMod.Modifier.Min)}-{ActionGameManager.PlayerSettings.Format(statMod.Modifier.Max)}");
|
||||
}
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
|
|
@ -493,16 +546,16 @@ public class PropertiesPanel : MonoBehaviour
|
|||
{
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name, () => $"{ActionGameManager.PlayerSettings.Format((float) field.GetValue(behavior))}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
sheet.AddStat(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
if(Math.Abs(stat.Min - stat.Max) < .001f)
|
||||
AddProperty(field.Name, () => $"{stat.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name, () => $"{ActionGameManager.PlayerSettings.Format(stat.Min)}");
|
||||
else
|
||||
AddProperty(field.Name, () => $"{stat.Min.SignificantDigits(Context.GameplaySettings.SignificantDigits)}-{stat.Max.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
sheet.AddStat(field.Name, () => $"{ActionGameManager.PlayerSettings.Format(stat.Min)}-{ActionGameManager.PlayerSettings.Format(stat.Max)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue