Trade Menu

Implemented Trade Menu
Item Filtering by size, hardpoint, behavior
Buying from trade menu on double click
This commit is contained in:
Reinier Vens 2021-01-14 23:47:08 +00:00
commit f4ee26e96c
22 changed files with 631 additions and 73 deletions

View file

@ -11,7 +11,7 @@ using Newtonsoft.Json;
public class EnergyDrawData : BehaviorData
{
[InspectableField, JsonProperty("draw"), Key(1), RuntimeInspectable]
public PerformanceStat Draw = new PerformanceStat();
public PerformanceStat EnergyDraw = new PerformanceStat();
[InspectableField, JsonProperty("perSecond"), Key(2)]
public bool PerSecond;
@ -42,7 +42,7 @@ public class EnergyDraw : IBehavior
public bool Execute(float delta)
{
Entity.Energy -= Context.Evaluate(_data.Draw, Item.EquippableItem, Entity) * (_data.PerSecond ? delta : 1);
Entity.Energy -= Context.Evaluate(_data.EnergyDraw, Item.EquippableItem, Entity) * (_data.PerSecond ? delta : 1);
return true;
}
}

View file

@ -27,8 +27,8 @@ public class LauncherData : InstantWeaponData
[InspectableField, JsonProperty("launchSpeed"), Key(14)]
public PerformanceStat LaunchSpeed = new PerformanceStat();
[InspectableField, JsonProperty("missileSpeed"), Key(15)]
public PerformanceStat MissileSpeed = new PerformanceStat();
[InspectableField, JsonProperty("missileSpeed"), Key(15), RuntimeInspectable]
public PerformanceStat Velocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
{

View file

@ -9,13 +9,13 @@ using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ProjectileWeaponData : InstantWeaponData
{
[InspectableField, JsonProperty("spread"), Key(9)]
[InspectableField, JsonProperty("spread"), Key(9), RuntimeInspectable]
public PerformanceStat Spread = new PerformanceStat();
[InspectableField, JsonProperty("bulletInherit"), Key(10)]
public float Inherit;
[InspectableField, JsonProperty("bulletVelocity"), Key(11)]
[InspectableField, JsonProperty("bulletVelocity"), Key(11), RuntimeInspectable]
public PerformanceStat Velocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -12,18 +12,18 @@ using static Unity.Mathematics.math;
public class TargetLockData : BehaviorData
{
[InspectableField, JsonProperty("speed"), Key(1), RuntimeInspectable]
public PerformanceStat Speed = new PerformanceStat();
public PerformanceStat LockSpeed = new PerformanceStat();
[InspectableField, JsonProperty("sensorImpact"), Key(2), RuntimeInspectable]
[InspectableField, JsonProperty("sensorImpact"), Key(2)]
public PerformanceStat SensorImpact = new PerformanceStat();
[InspectableField, JsonProperty("threshold"), Key(3), RuntimeInspectable]
public PerformanceStat Threshold = new PerformanceStat();
public PerformanceStat LockAngle = new PerformanceStat();
[InspectableField, JsonProperty("directionImpact"), Key(4), RuntimeInspectable]
[InspectableField, JsonProperty("directionImpact"), Key(4)]
public PerformanceStat DirectionImpact = new PerformanceStat();
[InspectableField, JsonProperty("decay"), Key(5), RuntimeInspectable]
[InspectableField, JsonProperty("decay"), Key(5)]
public PerformanceStat Decay = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
@ -75,9 +75,9 @@ public class TargetLock : IBehavior, IAlwaysUpdatedBehavior
}
if (Entity.Target.Value != null)
{
Speed = Context.Evaluate(_data.Speed, Item.EquippableItem, Entity);
Speed = Context.Evaluate(_data.LockSpeed, Item.EquippableItem, Entity);
SensorImpact = Context.Evaluate(_data.SensorImpact, Item.EquippableItem, Entity);
Threshold = Context.Evaluate(_data.Threshold, Item.EquippableItem, Entity);
Threshold = Context.Evaluate(_data.LockAngle, Item.EquippableItem, Entity);
DirectionImpact = Context.Evaluate(_data.DirectionImpact, Item.EquippableItem, Entity);
Decay = Context.Evaluate(_data.Decay, Item.EquippableItem, Entity);

View file

@ -13,10 +13,10 @@ public class ThrusterData : BehaviorData
[InspectableField, JsonProperty("thrust"), Key(1), RuntimeInspectable]
public PerformanceStat Thrust = new PerformanceStat();
[InspectableField, JsonProperty("visibility"), Key(2)]
[InspectableField, JsonProperty("visibility"), Key(2), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[InspectableField, JsonProperty("heat"), Key(3)]
[InspectableField, JsonProperty("heat"), Key(3), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[InspectablePrefab, JsonProperty("Particles"), Key(4)]

View file

@ -8,32 +8,32 @@ using Newtonsoft.Json;
[Union(0, typeof(ProjectileWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ConstantWeaponData))]
Union(2, typeof(ConstantWeaponData)), RuntimeInspectable]
public abstract class WeaponData : BehaviorData
{
[InspectableField, JsonProperty("damageType"), Key(1)]
[InspectableField, JsonProperty("damageType"), Key(1), RuntimeInspectable]
public DamageType DamageType;
[InspectableField, JsonProperty("damage"), Key(2)]
[InspectableField, JsonProperty("damage"), Key(2), RuntimeInspectable]
public PerformanceStat Damage = new PerformanceStat();
[RangedFloatInspectable(0,1), JsonProperty("penetration"), Key(3)]
[RangedFloatInspectable(0,1), JsonProperty("penetration"), Key(3), RuntimeInspectable]
public PerformanceStat Penetration = new PerformanceStat();
[RangedFloatInspectable(0,1), JsonProperty("damageSpread"), Key(4)]
public PerformanceStat DamageSpread = new PerformanceStat();
[InspectableField, JsonProperty("range"), Key(5)]
[InspectableField, JsonProperty("range"), Key(5), RuntimeInspectable]
public PerformanceStat Range = new PerformanceStat();
[InspectablePrefab, JsonProperty("effect"), Key(6)]
public string EffectPrefab;
}
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public abstract class InstantWeaponData : WeaponData
{
[InspectableField, JsonProperty("burstCount"), Key(7)]
[InspectableField, JsonProperty("burstCount"), Key(7), RuntimeInspectable]
public int BurstCount;
[InspectableField, JsonProperty("burstTime"), Key(8)]

View file

@ -109,14 +109,22 @@ public static class Extensions
);
}
public static string FormatTypeName(this string typeName)
{
return (typeName.EndsWith("Data")
? typeName.Substring(0, typeName.Length - 4)
: typeName).SplitCamelCase();
}
public static string SignificantDigits(this float d, int digits=10)
{
int magnitude = (d == 0.0f) ? 0 : (int)Math.Floor(Math.Log10(Math.Abs(d))) + 1;
int magnitude = d == 0.0f ? 0 : (int)Math.Floor(Math.Log10(Math.Abs(d))) + 1;
digits -= magnitude;
if (digits < 0)
digits = 0;
string fmt = "f" + digits.ToString();
return d.ToString(fmt);
string fmt = "f" + digits;
string strdec = d.ToString(fmt);
return strdec.Contains(".") ? strdec.TrimEnd('0').TrimEnd('.') : strdec;
}
private static Random? _random;