Reflected Visibility
Ships are now more visible in lit areas (depending on cross section stat in Reflector behavior) Refactored all behaviors to remove context & entity references (can get them from equipped item reference if needed) Fixed crash when enemy dies of heatstroke while targeted Exponential decay for visibility now uses correct time-independent formula Refactored item inspection in properties panel (now consistent between equipped items vs. inventory and store items, shows effect of heat on stats) Reordered item properties and added spacing between groups
This commit is contained in:
parent
b0b2717294
commit
a51c402fc5
59 changed files with 557 additions and 1405 deletions
|
|
@ -321,8 +321,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
}
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = cargoEvent.Position;
|
||||
PropertiesPanel.Clear();
|
||||
PropertiesPanel.AddItemProperties(item);
|
||||
PropertiesPanel.Inspect(item);
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = cargoEvent.CargoBay.Cargo[item];
|
||||
_selectedItem = item;
|
||||
|
|
@ -374,7 +373,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
PropertiesPanel.Inspect(entityEvent.Entity, item);
|
||||
PropertiesPanel.Inspect(item);
|
||||
_selectedPanel = panel;
|
||||
_selectedPosition = item.Position;
|
||||
_selectedItem = item.EquippableItem;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ using static Unity.Mathematics.math;
|
|||
|
||||
public class PropertiesPanel : MonoBehaviour
|
||||
{
|
||||
public RectTransform Spacer;
|
||||
public DropdownMenu Dropdown;
|
||||
public TextMeshProUGUI Title;
|
||||
public RectTransform Section;
|
||||
|
|
@ -86,6 +87,14 @@ public class PropertiesPanel : MonoBehaviour
|
|||
SelectedChild = null;
|
||||
}
|
||||
|
||||
public RectTransform AddSpacer()
|
||||
{
|
||||
var spacer = Instantiate(Spacer, Content ?? transform);
|
||||
Properties.Add(spacer.gameObject);
|
||||
OnPropertyAdded?.Invoke(spacer.gameObject);
|
||||
return spacer;
|
||||
}
|
||||
|
||||
public RectTransform AddSection(string name)
|
||||
{
|
||||
var section = Instantiate(Section, Content ?? transform);
|
||||
|
|
@ -352,68 +361,116 @@ public class PropertiesPanel : MonoBehaviour
|
|||
RefreshValues();
|
||||
}
|
||||
|
||||
public void AddEntityProperties(Entity entity)
|
||||
private void AddEntityProperties(Entity entity)
|
||||
{
|
||||
AddField("Name", () => entity.Name, name => entity.Name = name);
|
||||
AddProperty("Mass", () => $"{entity.Mass.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
}
|
||||
|
||||
public void AddItemProperties(Entity entity, ItemInstance item)
|
||||
private void AddItemProperties(ItemInstance item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
AddProperty(data.Description);//.Label.fontStyle = FontStyles.Normal;
|
||||
|
||||
AddProperty(data.Description);
|
||||
|
||||
var manufacturer = Context.ItemData.Get<Faction>(data.Manufacturer);
|
||||
if (manufacturer != null)
|
||||
{
|
||||
AddProperty("Manufacturer", () => manufacturer.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddProperty("Manufacturer", () => "GameCult");
|
||||
}
|
||||
AddProperty("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
|
||||
if (item is SimpleCommodity simpleCommodity)
|
||||
AddProperty("Quantity", () => simpleCommodity.Quantity.ToString());
|
||||
|
||||
AddProperty("Mass", () => Context.GetMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
if (item is EquippableItem gear)
|
||||
//AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
}
|
||||
|
||||
private void AddEquippableItemProperties(EquippableItem item, Func<PerformanceStat, float> statValueFunction)
|
||||
{
|
||||
if (item.Durability < .01f)
|
||||
{
|
||||
var (tier, upgrades) = entity.ItemManager.GetTier(gear);
|
||||
Title.text =
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
if (gear.Durability < .01f)
|
||||
AddProperty("Item destroyed!");
|
||||
return;
|
||||
}
|
||||
|
||||
var gearData = Context.GetData(item);
|
||||
AddProperty("Durability", () => $"{(int)(item.Durability / gearData.Durability * 100)}%");
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
{
|
||||
AddProperty("Item destroyed!");
|
||||
}
|
||||
else
|
||||
{
|
||||
var gearData = Context.GetData(gear);
|
||||
AddProperty("Durability", () =>
|
||||
$"{gear.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}/{gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
foreach (var behavior in gearData.Behaviors)
|
||||
foreach (var field in type.GetFields().Where(f => f.GetCustomAttribute<RuntimeInspectable>() != null))
|
||||
{
|
||||
var type = behavior.GetType();
|
||||
if (type.GetCustomAttribute(typeof(RuntimeInspectable)) != null)
|
||||
var fieldType = field.FieldType;
|
||||
if (fieldType == typeof(float))
|
||||
AddProperty(field.Name, () => $"{((float) field.GetValue(behavior)).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
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)}");
|
||||
else if (fieldType == typeof(int))
|
||||
AddProperty(field.Name, () => $"{(int) field.GetValue(behavior)}");
|
||||
else if (fieldType == typeof(PerformanceStat))
|
||||
{
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
AddProperty(field.Name, () => $"{Context.Evaluate(stat, gear).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
}
|
||||
}
|
||||
var stat = (PerformanceStat) field.GetValue(behavior);
|
||||
AddProperty(field.Name, () => $"{statValueFunction(stat).SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AddItemDataProperties(ItemData data)
|
||||
private string GetTitle(EquippableItem item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
var (tier, upgrades) = Context.GetTier(item);
|
||||
return
|
||||
$"<color=#{ColorUtility.ToHtmlStringRGB(tier.Color.ToColor())}>{data.Name}</color><smallcaps><size=60%> ({tier.Name}{new string('+', upgrades)})";
|
||||
}
|
||||
|
||||
public void Inspect(EquippedItem item)
|
||||
{
|
||||
Clear();
|
||||
if (item?.EquippableItem == null) return;
|
||||
|
||||
Title.text = GetTitle(item.EquippableItem);
|
||||
|
||||
AddItemProperties(item.EquippableItem);
|
||||
AddSpacer();
|
||||
|
||||
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)
|
||||
{
|
||||
switch (behavior)
|
||||
{
|
||||
case Thermotoggle thermotoggle when thermotoggle.ThermotoggleData.Adjustable:
|
||||
AddField("Target Temperature",
|
||||
() => thermotoggle.TargetTemperature,
|
||||
temp => thermotoggle.TargetTemperature = temp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RefreshValues();
|
||||
}
|
||||
|
||||
public void Inspect(ItemInstance item)
|
||||
{
|
||||
Clear();
|
||||
|
||||
AddItemProperties(item);
|
||||
|
||||
if (item is EquippableItem gear)
|
||||
{
|
||||
Title.text = GetTitle(gear);
|
||||
AddSpacer();
|
||||
AddEquippableItemProperties(gear, stat => Context.Evaluate(stat, gear));
|
||||
}
|
||||
|
||||
RefreshValues();
|
||||
}
|
||||
|
||||
public void Inspect(ItemData data)
|
||||
{
|
||||
AddProperty("Type", () => data.Name);
|
||||
AddProperty(data.Description).Label.fontStyle = FontStyles.Normal;
|
||||
|
|
@ -453,60 +510,6 @@ public class PropertiesPanel : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public void AddItemProperties(ItemInstance item)
|
||||
{
|
||||
var data = Context.ItemData.Get<ItemData>(item.Data);
|
||||
AddItemDataProperties(data);
|
||||
AddProperty("Mass", () => Context.GetMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
AddProperty("Thermal Mass", () => Context.GetThermalMass(item).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
if (item is EquippableItem gear)
|
||||
{
|
||||
var gearData = Context.GetData(gear);
|
||||
AddProperty("Durability", () =>
|
||||
$"{gear.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}/{gearData.Durability.SignificantDigits(Context.GameplaySettings.SignificantDigits)}");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Inspect(Entity entity, EquippedItem item)
|
||||
{
|
||||
if (this is PropertiesList list)
|
||||
{
|
||||
if (list.Expanded)
|
||||
InspectGearInternal();
|
||||
else
|
||||
list.OnExpand += b =>
|
||||
{
|
||||
if (b) InspectGearInternal();
|
||||
};
|
||||
}
|
||||
else
|
||||
InspectGearInternal();
|
||||
|
||||
void InspectGearInternal()
|
||||
{
|
||||
//Debug.Log($"Refreshing {hardpoint.Gear.Name} properties");
|
||||
Clear();
|
||||
if (item.EquippableItem != null)
|
||||
{
|
||||
AddField("Override Shutdown", () => item.EquippableItem.OverrideShutdown, b => item.EquippableItem.OverrideShutdown = b);
|
||||
AddProperty("Temperature", () => (item.Temperature - 273.15f).SignificantDigits(Context.GameplaySettings.SignificantDigits));
|
||||
AddItemProperties(entity, item.EquippableItem);
|
||||
foreach (var behavior in item.Behaviors)
|
||||
{
|
||||
if(behavior is IPopulationAssignment populationAssignment)
|
||||
AddIncrementField("Assigned Population",
|
||||
() => populationAssignment.AssignedPopulation,
|
||||
p => populationAssignment.AssignedPopulation = p,
|
||||
() => 0, () => entity.Population - entity.AssignedPopulation + populationAssignment.AssignedPopulation);
|
||||
if (behavior is Thermotoggle thermotoggle)
|
||||
AddField("Target Temperature", () => thermotoggle.TargetTemperature, temp => thermotoggle.TargetTemperature = temp);
|
||||
}
|
||||
}
|
||||
RefreshValues();
|
||||
}
|
||||
}
|
||||
|
||||
// public void Inspect(object obj, bool inspectablesOnly = false, bool readWrite = false, bool topLevel = true)
|
||||
// {
|
||||
// if(topLevel)
|
||||
|
|
|
|||
|
|
@ -311,11 +311,7 @@ public class TradeMenu : MonoBehaviour
|
|||
Output = x.output(i),
|
||||
SortKey = x.sortKey(i.data)
|
||||
}).ToArray(),
|
||||
OnClick = () =>
|
||||
{
|
||||
Properties.Clear();
|
||||
Properties.AddItemProperties(i.item);
|
||||
},
|
||||
OnClick = () => Properties.Inspect(i.item),
|
||||
OnDoubleClick = () =>
|
||||
{
|
||||
switch (i.item)
|
||||
|
|
|
|||
|
|
@ -298,8 +298,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
}).ToArray(),
|
||||
OnClick = () =>
|
||||
{
|
||||
Properties.Clear();
|
||||
Properties.AddItemDataProperties(i);
|
||||
Properties.Inspect(i);
|
||||
},
|
||||
OnDoubleClick = () =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue