Thermal Performance Threshold & Thermal Override
Items will switch themselves off below a customizable threshold to avoid damage Player can toggle thermal override to disable safety shutdown Selecting an item allows player to select whether the item will override Clicking on the background of an inventory panel will display general ship settings (including thermal shutdown threshold) Performance Stat evaluation has been moved to EquippedItem, slight performance improvement Item online and active status are now reactive properties Created player settings file to store e.g. shutdown threshold Fixed crash when entering wormhole while enemies are visible
This commit is contained in:
parent
2f088b5590
commit
1092159063
66 changed files with 756 additions and 206 deletions
|
|
@ -53,8 +53,8 @@ public class Capacitor : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Capacity = Context.Evaluate(_data.Capacity, Item);
|
||||
Efficiency = Context.Evaluate(_data.Efficiency, Item);
|
||||
Capacity = Item.Evaluate(_data.Capacity);
|
||||
Efficiency = Item.Evaluate(_data.Efficiency);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -100,9 +100,9 @@ public class ChargedWeapon : InstantWeapon
|
|||
protected override void UpdateStats()
|
||||
{
|
||||
base.UpdateStats();
|
||||
ChargeTime = Context.Evaluate(_data.ChargeTime, Item);
|
||||
ChargeEnergy = Context.Evaluate(_data.ChargeEnergy, Item);
|
||||
ChargeHeat = Context.Evaluate(_data.ChargeHeat, Item);
|
||||
ChargeTime = Item.Evaluate(_data.ChargeTime);
|
||||
ChargeEnergy = Item.Evaluate(_data.ChargeEnergy);
|
||||
ChargeHeat = Item.Evaluate(_data.ChargeHeat);
|
||||
Damage *= lerp(1, _data.ChargeFiringDamageMultiplier, saturate(_charge));
|
||||
Heat *= lerp(1, _data.ChargeFiringHeatMultiplier, saturate(_charge));
|
||||
Spread *= lerp(1, _data.ChargeFiringSpreadMultiplier, saturate(_charge));
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior
|
|||
base.Execute(delta);
|
||||
if (_firing)
|
||||
{
|
||||
if (!Entity.TryConsumeEnergy(Context.Evaluate(_data.Energy, Item) * delta))
|
||||
if (!Entity.TryConsumeEnergy(Item.Evaluate(_data.Energy) * delta))
|
||||
{
|
||||
_firing = false;
|
||||
OnStopFiring?.Invoke();
|
||||
|
|
@ -115,9 +115,9 @@ public class ConstantWeapon : Weapon, IProgressBehavior
|
|||
}
|
||||
}
|
||||
|
||||
Item.EquippableItem.Durability -= Wear * delta;
|
||||
Item.AddHeat(Context.Evaluate(_data.Heat, Item) * delta);
|
||||
Entity.VisibilitySources[this] = Context.Evaluate(_data.Visibility, Item);
|
||||
Item.EquippableItem.Durability -= Item.Wear * delta;
|
||||
Item.AddHeat(Item.Evaluate(_data.Heat) * delta);
|
||||
Entity.VisibilitySources[this] = Item.Evaluate(_data.Visibility);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,6 @@ public class Cooldown : IBehavior, IAlwaysUpdatedBehavior, IProgressBehavior
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
_cooldown -= delta / Context.Evaluate(_data.Cooldown, Item);
|
||||
_cooldown -= delta / Item.Evaluate(_data.Cooldown);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,6 +42,6 @@ public class EnergyDraw : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
return Entity.TryConsumeEnergy(Context.Evaluate(_data.EnergyDraw, Item) * (_data.PerSecond ? delta : 1));
|
||||
return Entity.TryConsumeEnergy(Item.Evaluate(_data.EnergyDraw) * (_data.PerSecond ? delta : 1));
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class Heat : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Item.AddHeat(Context.Evaluate(_data.Heat, Item) * (_data.PerSecond ? delta : 1));
|
||||
Item.AddHeat(Item.Evaluate(_data.Heat) * (_data.PerSecond ? delta : 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,9 +92,9 @@ public class InstantWeapon : Weapon, IProgressBehavior
|
|||
protected override void UpdateStats()
|
||||
{
|
||||
base.UpdateStats();
|
||||
BurstCount = Context.Evaluate(_data.Count, Item);
|
||||
BurstTime = Context.Evaluate(_data.BurstTime, Item);
|
||||
Cooldown = Context.Evaluate(_data.Cooldown, Item);
|
||||
BurstCount = Item.Evaluate(_data.Count);
|
||||
BurstTime = Item.Evaluate(_data.BurstTime);
|
||||
Cooldown = Item.Evaluate(_data.Cooldown);
|
||||
|
||||
Damage /= (int) BurstCount;
|
||||
Heat /= (int) BurstCount;
|
||||
|
|
@ -165,7 +165,7 @@ public class InstantWeapon : Weapon, IProgressBehavior
|
|||
_burstRemaining--;
|
||||
_burstTimer -= _burstInterval;
|
||||
OnFire?.Invoke();
|
||||
Item.EquippableItem.Durability -= Wear;
|
||||
Item.EquippableItem.Durability -= Item.Wear;
|
||||
Item.AddHeat(Heat);
|
||||
Entity.VisibilitySources[this] = Visibility;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ public class LockWeapon : InstantWeapon
|
|||
|
||||
if (Entity.Target.Value != null)
|
||||
{
|
||||
LockSpeed = Context.Evaluate(_data.LockSpeed, Item);
|
||||
SensorImpact = Context.Evaluate(_data.SensorImpact, Item);
|
||||
LockAngle = Context.Evaluate(_data.LockAngle, Item);
|
||||
DirectionImpact = Context.Evaluate(_data.DirectionImpact, Item);
|
||||
Decay = Context.Evaluate(_data.Decay, Item);
|
||||
LockSpeed = Item.Evaluate(_data.LockSpeed);
|
||||
SensorImpact = Item.Evaluate(_data.SensorImpact);
|
||||
LockAngle = Item.Evaluate(_data.LockAngle);
|
||||
DirectionImpact = Item.Evaluate(_data.DirectionImpact);
|
||||
Decay = Item.Evaluate(_data.Decay);
|
||||
|
||||
var degrees = acos(dot(normalize(Entity.Target.Value.Position - Entity.Position), normalize(Entity.LookDirection))) * 57.2958f;
|
||||
if (degrees < LockAngle)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class MiningTool : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Range = Context.Evaluate(_data.Range, Item);
|
||||
Range = Item.Evaluate(_data.Range);
|
||||
var belt = Entity.Zone.AsteroidBelts[AsteroidBelt];
|
||||
if (AsteroidBelt != Guid.Empty &&
|
||||
Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) &&
|
||||
|
|
@ -64,9 +64,9 @@ public class MiningTool : IBehavior
|
|||
Entity,
|
||||
AsteroidBelt,
|
||||
Asteroid,
|
||||
Context.Evaluate(_data.DamagePerSecond, Item) * delta,
|
||||
Context.Evaluate(_data.Efficiency, Item),
|
||||
Context.Evaluate(_data.Penetration, Item));
|
||||
Item.Evaluate(_data.DamagePerSecond) * delta,
|
||||
Item.Evaluate(_data.Efficiency),
|
||||
Item.Evaluate(_data.Penetration));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,9 +57,9 @@ public class Radiator : IBehavior, IAlwaysUpdatedBehavior, IInitializableBehavio
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
PumpedHeat = Context.Evaluate(_data.PumpedHeat, Item);
|
||||
WasteHeat = Context.Evaluate(_data.WasteHeat, Item);
|
||||
EnergyUsage = Context.Evaluate(_data.EnergyUsage, Item);
|
||||
PumpedHeat = Item.Evaluate(_data.PumpedHeat);
|
||||
WasteHeat = Item.Evaluate(_data.WasteHeat);
|
||||
EnergyUsage = Item.Evaluate(_data.EnergyUsage);
|
||||
|
||||
var itemTemperature = Item.Temperature;
|
||||
var tempRatio = max(Temperature / itemTemperature, 1);
|
||||
|
|
@ -84,7 +84,7 @@ public class Radiator : IBehavior, IAlwaysUpdatedBehavior, IInitializableBehavio
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
Emissivity = Context.Evaluate(_data.Emissivity, Item);
|
||||
Emissivity = Item.Evaluate(_data.Emissivity);
|
||||
var rad = pow(Temperature, Context.GameplaySettings.HeatRadiationExponent) * Context.GameplaySettings.HeatRadiationMultiplier * Emissivity;
|
||||
Temperature -= rad * delta;
|
||||
Entity.VisibilitySources[this] = rad;
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ public class Reactor : IBehavior, IOrderedBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
var charge = Context.Evaluate(_data.Charge, Item) * delta;
|
||||
var efficiency = Context.Evaluate(_data.Efficiency, Item);
|
||||
var charge = Item.Evaluate(_data.Charge) * delta;
|
||||
var efficiency = Item.Evaluate(_data.Efficiency);
|
||||
|
||||
// This behavior executes last, so any components drawing power have already done so
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ public class Reactor : IBehavior, IOrderedBehavior
|
|||
// We have an energy deficit, have to overload the reactor
|
||||
if (Draw > .01f)
|
||||
{
|
||||
var overloadEfficiency = Context.Evaluate(_data.OverloadEfficiency, Item);
|
||||
var overloadEfficiency = Item.Evaluate(_data.OverloadEfficiency);
|
||||
|
||||
// Generate heat using overload efficiency, usually much less efficient!
|
||||
heat += Draw / overloadEfficiency;
|
||||
|
|
@ -120,7 +120,7 @@ public class Reactor : IBehavior, IOrderedBehavior
|
|||
// We still have an energy surplus, try to throttle the reactor to reduce heat generation
|
||||
if (Draw < -.01f)
|
||||
{
|
||||
heat -= Draw / efficiency * (1 - 1 / Context.Evaluate(_data.ThrottlingFactor, Item));
|
||||
heat -= Draw / efficiency * (1 - 1 / Item.Evaluate(_data.ThrottlingFactor));
|
||||
Draw = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,8 +105,8 @@ public class ResourceScanner : IBehavior, IAlwaysUpdatedBehavior
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
Range = Context.Evaluate(_data.Range, Item);
|
||||
MinimumDensity = Context.Evaluate(_data.MinimumDensity, Item);
|
||||
ScanDuration = Context.Evaluate(_data.ScanDuration, Item);
|
||||
Range = Item.Evaluate(_data.Range);
|
||||
MinimumDensity = Item.Evaluate(_data.MinimumDensity);
|
||||
ScanDuration = Item.Evaluate(_data.ScanDuration);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,7 +59,7 @@ public class Sensor : IBehavior
|
|||
var next = saturate(
|
||||
previous +
|
||||
entity.Visibility *
|
||||
Context.Evaluate(_data.Sensitivity, Item) *
|
||||
Item.Evaluate(_data.Sensitivity) *
|
||||
_data.SensitivityCurve.Evaluate(angle / PI) *
|
||||
delta / dist);
|
||||
next *= 1 - Context.GameplaySettings.TargetInfoDecay * delta;
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ public class Shield : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Efficiency = Context.Evaluate(_data.Efficiency, Item);
|
||||
EnergyUsage = Context.Evaluate(_data.EnergyUsage, Item);
|
||||
Efficiency = Item.Evaluate(_data.Efficiency);
|
||||
EnergyUsage = Item.Evaluate(_data.EnergyUsage);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public class StatModifier : IBehavior, IInitializableBehavior, IDisposableBehavi
|
|||
foreach (var stat in _stats)
|
||||
(_data.Type == StatModifierType.Constant
|
||||
? stat.GetConstantModifiers(Entity)
|
||||
: stat.GetScaleModifiers(Entity))[this] = Context.Evaluate(_data.Modifier, Item);
|
||||
: stat.GetScaleModifiers(Entity))[this] = Item.Evaluate(_data.Modifier);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,16 +61,16 @@ public class Thruster : IAnalogBehavior
|
|||
var itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
||||
var toCenter = hullCenter - itemCenter;
|
||||
Torque = -dot(normalize(toCenter), float2(1, 0).Rotate(item.EquippableItem.Rotation));
|
||||
Thrust = Context.Evaluate(_data.Thrust, Item);
|
||||
Thrust = Item.Evaluate(_data.Thrust);
|
||||
}
|
||||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Thrust = Context.Evaluate(_data.Thrust, Item);
|
||||
Thrust = Item.Evaluate(_data.Thrust);
|
||||
Entity.Velocity -= Entity.Direction.Rotate(Item.EquippableItem.Rotation) * _input * Thrust / Entity.Mass * delta;
|
||||
Entity.Direction = mul(Entity.Direction, Unity.Mathematics.float2x2.Rotate(_input * Torque * Thrust * Context.GameplaySettings.TorqueMultiplier / Entity.Mass * delta));
|
||||
Item.AddHeat(_input * Context.Evaluate(_data.Heat, Item) * delta);
|
||||
var vis = _input * Context.Evaluate(_data.Visibility, Item);
|
||||
Item.AddHeat(_input * Item.Evaluate(_data.Heat) * delta);
|
||||
var vis = _input * Item.Evaluate(_data.Visibility);
|
||||
if(!Entity.VisibilitySources.ContainsKey(this) || vis > Entity.VisibilitySources[this])
|
||||
Entity.VisibilitySources[this] = vis;
|
||||
return _input > .01f;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class TurretController : IBehavior
|
|||
if (b is Weapon weapon)
|
||||
{
|
||||
_weapons.Add(weapon);
|
||||
var vel = Context.Evaluate(weapon.WeaponData.Velocity, item);
|
||||
var vel = weapon.Item.Evaluate(weapon.WeaponData.Velocity);
|
||||
if (vel > .1f)
|
||||
{
|
||||
_predictShots = true;
|
||||
|
|
@ -95,7 +95,7 @@ public class TurretController : IBehavior
|
|||
var fire = dot(
|
||||
EquippedEntity.HardpointTransforms[EquippedEntity.Hardpoints[x.Item.Position.x, x.Item.Position.y]].direction,
|
||||
EquippedEntity.LookDirection) > .99f;
|
||||
if (Context.Evaluate(data.Range, x.Item) > dist && fire)
|
||||
if (x.Item.Evaluate(data.Range) > dist && fire)
|
||||
{
|
||||
x.Activate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class VelocityLimit : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Limit = Context.Evaluate(_data.TopSpeed, Item);
|
||||
Limit = Item.Evaluate(_data.TopSpeed);
|
||||
if (length(Entity.Velocity) > Limit)
|
||||
Entity.Velocity = normalize(Entity.Velocity) * Limit;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class Visibility : IBehavior, IAlwaysUpdatedBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
Entity.VisibilitySources[this] = Context.Evaluate(_data.Visibility, Item);
|
||||
Entity.VisibilitySources[this] = Item.Evaluate(_data.Visibility);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ public class Visibility : IBehavior, IAlwaysUpdatedBehavior
|
|||
// TODO: Time independent decay?
|
||||
if(Entity.VisibilitySources.ContainsKey(this))
|
||||
{
|
||||
Entity.VisibilitySources[this] *= Context.Evaluate(_data.VisibilityDecay, Item);
|
||||
Entity.VisibilitySources[this] *= Item.Evaluate(_data.VisibilityDecay);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -91,7 +91,6 @@ public abstract class Weapon : IActivatedBehavior
|
|||
public float Visibility { get; protected set; }
|
||||
public float Spread { get; protected set; }
|
||||
public float Velocity { get; protected set; }
|
||||
public float Wear { get; protected set; }
|
||||
|
||||
protected bool _firing;
|
||||
|
||||
|
|
@ -114,20 +113,16 @@ public abstract class Weapon : IActivatedBehavior
|
|||
|
||||
protected virtual void UpdateStats()
|
||||
{
|
||||
Damage = Context.Evaluate(_data.Damage, Item);
|
||||
Penetration = Context.Evaluate(_data.Penetration, Item);
|
||||
DamageSpread = Context.Evaluate(_data.DamageSpread, Item);
|
||||
MinRange = Context.Evaluate(_data.MinRange, Item);
|
||||
Range = Context.Evaluate(_data.Range, Item);
|
||||
Energy = Context.Evaluate(_data.Energy, Item);
|
||||
Heat = Context.Evaluate(_data.Heat, Item);
|
||||
Visibility = Context.Evaluate(_data.Visibility, Item);
|
||||
Spread = Context.Evaluate(_data.Spread, Item);
|
||||
Velocity = Context.Evaluate(_data.Velocity, Item);
|
||||
Wear = (1 - pow(_itemData.Performance(Item.Temperature),
|
||||
(1 - pow(Item.EquippableItem.Quality, Context.GameplaySettings.QualityWearExponent)) *
|
||||
Context.GameplaySettings.ThermalWearExponent)
|
||||
) * _itemData.Durability;
|
||||
Damage = Item.Evaluate(_data.Damage);
|
||||
Penetration = Item.Evaluate(_data.Penetration);
|
||||
DamageSpread = Item.Evaluate(_data.DamageSpread);
|
||||
MinRange = Item.Evaluate(_data.MinRange);
|
||||
Range = Item.Evaluate(_data.Range);
|
||||
Energy = Item.Evaluate(_data.Energy);
|
||||
Heat = Item.Evaluate(_data.Heat);
|
||||
Visibility = Item.Evaluate(_data.Visibility);
|
||||
Spread = Item.Evaluate(_data.Spread);
|
||||
Velocity = Item.Evaluate(_data.Velocity);
|
||||
}
|
||||
|
||||
public virtual bool Execute(float delta)
|
||||
|
|
|
|||
|
|
@ -42,12 +42,9 @@ public class Wear : IBehavior
|
|||
|
||||
public bool Execute(float delta)
|
||||
{
|
||||
var wear = (1 - pow(_itemData.Performance(Item.Temperature),
|
||||
(1 - pow(Item.EquippableItem.Quality, Context.GameplaySettings.QualityWearExponent)) *
|
||||
Context.GameplaySettings.ThermalWearExponent)
|
||||
) * _itemData.Durability / _itemData.ThermalResilience;
|
||||
if (_data.PerSecond) wear *= delta;
|
||||
Item.EquippableItem.Durability -= wear;
|
||||
if (_data.PerSecond)
|
||||
Item.EquippableItem.Durability -= Item.Wear * delta;
|
||||
else Item.EquippableItem.Durability -= Item.Wear;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue