Drag and Drop + Zoooooooom
Refactored inventory drag & drop to use new global drag & drop management Enabled Drag & Drop from inventory panel to action bar Enabled gear and consumable item binding Fixed stat modifier behavior to allow it to be toggled Fixed Switch behavior to make it bindable Added lambda multiplier to aether drive so that stat mod can target it
This commit is contained in:
parent
82c8041765
commit
7cfc5cd04f
21 changed files with 352 additions and 323 deletions
|
|
@ -22,19 +22,22 @@ public class AetherDriveData : BehaviorData
|
|||
[Inspectable, JsonProperty("couplingLambdas"), Key(4)]
|
||||
public float3 CouplingLambda;
|
||||
|
||||
[Inspectable, JsonProperty("couplingEfficiency"), Key(5), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("lambdaMultiplier"), Key(5)]
|
||||
public PerformanceStat LambdaMultiplier;
|
||||
|
||||
[Inspectable, JsonProperty("couplingEfficiency"), Key(6), RuntimeInspectable]
|
||||
public PerformanceStat CouplingEfficiency;
|
||||
|
||||
[Inspectable, JsonProperty("torque"), Key(6), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("torque"), Key(7), RuntimeInspectable]
|
||||
public PerformanceStat Torque;
|
||||
|
||||
[Inspectable, JsonProperty("torqueProfile"), Key(7), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("torqueProfile"), Key(8), RuntimeInspectable]
|
||||
public BezierCurve TorqueProfile;
|
||||
|
||||
[Inspectable, JsonProperty("draw"), Key(8), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("draw"), Key(9), RuntimeInspectable]
|
||||
public PerformanceStat EnergyDraw;
|
||||
|
||||
[Inspectable, JsonProperty("passiveCoupling"), Key(9), RuntimeInspectable]
|
||||
[Inspectable, JsonProperty("passiveCoupling"), Key(10), RuntimeInspectable]
|
||||
public PerformanceStat PassiveCoupling;
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
|
|
@ -88,7 +91,7 @@ public class AetherDrive : Behavior
|
|||
|
||||
Thrust = (Rpm - AetheriaMath.Decay(Rpm, _data.CouplingLambda, dt)) * _data.RotorMass * efficiency;
|
||||
|
||||
var couplingLambda = _data.CouplingLambda * max(abs(_axis), Evaluate(_data.PassiveCoupling));
|
||||
var couplingLambda = _data.CouplingLambda * Item.Evaluate(_data.LambdaMultiplier) * max(abs(_axis), Evaluate(_data.PassiveCoupling));
|
||||
var previousRpm = Rpm;
|
||||
Rpm = AetheriaMath.Decay(Rpm, couplingLambda, dt);
|
||||
var rpmLoss = previousRpm - Rpm;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ public class StatModifierData : BehaviorData
|
|||
}
|
||||
|
||||
[Order(-4)]
|
||||
public class StatModifier : Behavior, IInitializableBehavior, IDisposable
|
||||
public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwaysUpdatedBehavior
|
||||
{
|
||||
private StatModifierData _data;
|
||||
|
||||
|
|
@ -42,6 +42,9 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable
|
|||
|
||||
private static Type[] _statObjects;
|
||||
|
||||
private bool _applied;
|
||||
private bool _executed;
|
||||
|
||||
private static Type[] StatObjects => _statObjects = _statObjects ?? typeof(BehaviorData).GetAllChildClasses()
|
||||
.Concat(typeof(EquippableItemData).GetAllChildClasses()).ToArray();
|
||||
|
||||
|
|
@ -83,19 +86,41 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
private void ApplyModifier()
|
||||
{
|
||||
_applied = true;
|
||||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant
|
||||
? stat.GetConstantModifiers(Entity)
|
||||
: stat.GetScaleModifiers(Entity))[this] = Evaluate(_data.Modifier);
|
||||
}
|
||||
|
||||
private void RemoveModifier()
|
||||
{
|
||||
_applied = false;
|
||||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant ? stat.GetConstantModifiers(Entity) : stat.GetScaleModifiers(Entity)).Remove(this);
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
_executed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant ? stat.GetConstantModifiers(Entity) : stat.GetScaleModifiers(Entity)).Remove(this);
|
||||
if(_applied)
|
||||
RemoveModifier();
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
if(_executed && !_applied)
|
||||
ApplyModifier();
|
||||
if(!_executed && _applied)
|
||||
RemoveModifier();
|
||||
_executed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class SwitchData : BehaviorData
|
|||
}
|
||||
}
|
||||
|
||||
public class Switch : Behavior
|
||||
public class Switch : Behavior, IActivatedBehavior
|
||||
{
|
||||
private SwitchData _data;
|
||||
|
||||
|
|
@ -39,4 +39,14 @@ public class Switch : Behavior
|
|||
{
|
||||
return Activated;
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Activated = true;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
Activated = false;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,17 +14,18 @@ public class TypeFormatter : MessagePack.Formatters.IMessagePackFormatter<Type>
|
|||
|
||||
public void Serialize(ref MessagePackWriter writer, Type value, MessagePackSerializerOptions options)
|
||||
{
|
||||
writer.Write(value.AssemblyQualifiedName);
|
||||
writer.Write(value == null ? "" : value.AssemblyQualifiedName);
|
||||
}
|
||||
|
||||
public Type Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
|
||||
{
|
||||
if (reader.IsNil)
|
||||
{
|
||||
throw new InvalidOperationException("typecode is null, struct not supported");
|
||||
return null; //throw new InvalidOperationException("typecode is null, struct not supported");
|
||||
}
|
||||
|
||||
var assemblyQualifiedName = reader.ReadString();
|
||||
if (string.IsNullOrEmpty(assemblyQualifiedName)) return null;
|
||||
|
||||
return Type.GetType(assemblyQualifiedName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -992,7 +992,7 @@ public class ConsumableItemEffect
|
|||
Data = (ConsumableItemData) item.Data.Value;
|
||||
RemainingDuration = Data.Duration;
|
||||
|
||||
Behaviors = Data.StatModifiers
|
||||
Behaviors = Data.Behaviors
|
||||
.Select(bd => bd.CreateInstance(this))
|
||||
.ToArray();
|
||||
}
|
||||
|
|
@ -1117,7 +1117,8 @@ public class EquippedItem
|
|||
var quality = pow(EquippableItem.Quality, stat.QualityExponent);
|
||||
|
||||
var scaleModifier = 1.0f;
|
||||
foreach (var value in stat.GetScaleModifiers(Entity).Values) scaleModifier = scaleModifier * value;
|
||||
var scaleModifiers = stat.GetScaleModifiers(Entity).Values;
|
||||
foreach (var value in scaleModifiers) scaleModifier *= value;
|
||||
|
||||
float constantModifier = 0;
|
||||
foreach (var value in stat.GetConstantModifiers(Entity).Values) constantModifier += value;
|
||||
|
|
@ -1150,9 +1151,6 @@ public class EquippedItem
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
foreach (var behavior in Behaviors)
|
||||
if(behavior is IAlwaysUpdatedBehavior alwaysUpdatedBehavior) alwaysUpdatedBehavior.Update(delta);
|
||||
|
||||
if (Active.Value)
|
||||
{
|
||||
foreach (var group in BehaviorGroups.Values)
|
||||
|
|
@ -1164,9 +1162,12 @@ public class EquippedItem
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var behavior in Behaviors)
|
||||
if(behavior is IAlwaysUpdatedBehavior alwaysUpdatedBehavior) alwaysUpdatedBehavior.Update(delta);
|
||||
}
|
||||
|
||||
public T GetBehavior<T>() where T : Behavior
|
||||
public T GetBehavior<T>() where T : class
|
||||
{
|
||||
foreach (var behavior in Behaviors)
|
||||
if (behavior is T b)
|
||||
|
|
|
|||
|
|
@ -302,7 +302,7 @@ public class CompoundCommodityData : CraftedItemData
|
|||
public class ConsumableItemData : CraftedItemData
|
||||
{
|
||||
[Inspectable, JsonProperty("behaviors"), Key(10)]
|
||||
public List<StatModifierData> StatModifiers = new List<StatModifierData>();
|
||||
public List<BehaviorData> Behaviors = new List<BehaviorData>();
|
||||
|
||||
[Inspectable, JsonProperty("stackable"), Key(11)]
|
||||
public bool Stackable;
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ public class Ship : Entity
|
|||
deltaRot = 0;
|
||||
Direction = lerp(Direction, look, min(delta, 1));
|
||||
}
|
||||
deltaRot = pow(abs(deltaRot), .75f) * sign(deltaRot);
|
||||
deltaRot = pow(abs(deltaRot), .5f) * sign(deltaRot);
|
||||
|
||||
foreach (var thruster in _clockwiseThrusters) thruster.Axis += deltaRot;
|
||||
foreach (var thruster in _counterClockwiseThrusters) thruster.Axis += -deltaRot;
|
||||
|
|
|
|||
Loading…
Reference in a new issue