Purge Newtonsoft state annotations

This commit is contained in:
Meta Vens 2026-06-13 04:56:50 +01:00
commit b0d2aa1156
92 changed files with 891 additions and 1684 deletions

View file

@ -3,57 +3,56 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
[Inspectable, MessagePackObject, EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
public class AetherDriveData : BehaviorData
{
[Inspectable, JsonProperty("diameters"), Key(1)]
[Inspectable, Key(1)]
public float3 RotorDiameter;
[Inspectable, JsonProperty("masses"), Key(2)]
[Inspectable, Key(2)]
public float3 RotorMass;
[Inspectable, JsonProperty("rpm"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat MaximumRpm;
[Inspectable, JsonProperty("couplingLambdas"), Key(4)]
[Inspectable, Key(4)]
public float3 CouplingLambda;
[Inspectable, JsonProperty("lambdaMultiplier"), Key(5)]
[Inspectable, Key(5)]
public PerformanceStat LambdaMultiplier;
[Inspectable, JsonProperty("couplingEfficiency"), Key(6), RuntimeInspectable]
[Inspectable, Key(6), RuntimeInspectable]
public PerformanceStat CouplingEfficiency;
[Inspectable, JsonProperty("torque"), Key(7), RuntimeInspectable]
[Inspectable, Key(7), RuntimeInspectable]
public PerformanceStat Torque;
[Inspectable, JsonProperty("torqueProfile"), Key(8), RuntimeInspectable]
[Inspectable, Key(8), RuntimeInspectable]
public BezierCurve TorqueProfile;
[Inspectable, JsonProperty("draw"), Key(9), RuntimeInspectable]
[Inspectable, Key(9), RuntimeInspectable]
public PerformanceStat EnergyDraw;
[Inspectable, JsonProperty("passiveCoupling"), Key(10), RuntimeInspectable]
[Inspectable, Key(10), RuntimeInspectable]
public PerformanceStat PassiveCoupling;
[InspectableAudioParameter, JsonProperty("rpmAudio"), Key(11), RuntimeInspectable]
[InspectableAudioParameter, Key(11), RuntimeInspectable]
public uint RpmAudioParameter;
[InspectableAudioParameter, JsonProperty("torqueAudio"), Key(12), RuntimeInspectable]
[InspectableAudioParameter, Key(12), RuntimeInspectable]
public uint TorqueRatioAudioParameter;
[InspectablePrefab, JsonProperty("particles"), Key(13)]
[InspectablePrefab, Key(13)]
public string Particles;
public override Behavior CreateInstance(EquippedItem item)
{
return new AetherDrive(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new AetherDrive(this, item);
@ -91,10 +90,10 @@ public class AetherDrive : Behavior
public override bool Execute(float dt)
{
var rotorSpeed = Rpm * _data.RotorDiameter / 100;
var forward = normalize(Entity.Direction);
var right = forward.Rotate(ItemRotation.Clockwise);
var speed = float2(dot(Entity.Velocity, forward), dot(Entity.Velocity, right));
var couplingEfficiency = Evaluate(_data.CouplingEfficiency);
var efficiency = float3(saturate(1 - speed / max(rotorSpeed.xy, 1) * sign(_axis.xy)) * couplingEfficiency, 1);
@ -112,13 +111,13 @@ public class AetherDrive : Behavior
ThrustDirection = forward * (_axis.x * force.x / Entity.Mass) + right * (_axis.y * force.y / Entity.Mass);
Entity.Velocity += ThrustDirection;
Entity.Direction = mul(Entity.Direction,
Unity.Mathematics.float2x2.Rotate(force.z * _axis.z * ItemManager.GameplaySettings.AetherTorqueMultiplier / Entity.Mass));
if(float.IsNaN(Entity.Velocity.x))
ItemManager.Log("FUCK FUCK FUCK FUCK");
MaximumRpm = Evaluate(_data.MaximumRpm);
var torqueProfile = float3(
_data.TorqueProfile.Evaluate(Rpm.x / MaximumRpm),
@ -129,18 +128,18 @@ public class AetherDrive : Behavior
var actualRpmDelta = min(MaximumRpm - Rpm, potentialRpmDelta);
var torqueRatio = actualRpmDelta / potentialRpmDelta;
var draw = torqueRatio * Evaluate(_data.EnergyDraw) / 3;
Item.SetAudioParameter(SpecialAudioParameter.Intensity, max(max(abs(_axis.x), abs(_axis.y)), abs(_axis.z)));
Item.SetAudioParameter(_data.RpmAudioParameter, (Rpm.x + Rpm.y + Rpm.z) / 3 / MaximumRpm);
Item.SetAudioParameter(_data.TorqueRatioAudioParameter, max(max(torqueRatio.x, torqueRatio.y), torqueRatio.z));
if (Entity.TryConsumeEnergy((draw.x + draw.y + draw.z)*dt))
{
Rpm += actualRpmDelta;
return true;
}
return false;
}
}

View file

@ -2,11 +2,10 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class AutoWeaponData : InstantWeaponData
{
public override Behavior CreateInstance(EquippedItem item)
@ -17,7 +16,7 @@ public class AutoWeaponData : InstantWeaponData
public class AutoWeapon : InstantWeapon
{
public AutoWeapon(InstantWeaponData data, EquippedItem item) : base(data, item) { }
public AutoWeapon(InstantWeaponData data, ConsumableItemEffect item) : base(data, item) { }

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
@ -6,9 +6,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
@ -51,14 +49,14 @@ public abstract class Behavior
Item = item;
ItemManager = Item.ItemManager;
}
protected Behavior(BehaviorData data, ConsumableItemEffect consumable)
{
Data = data;
Consumable = consumable;
ItemManager = consumable.Entity.ItemManager;
}
public float Evaluate(PerformanceStat stat) => Item?.Evaluate(stat) ?? Consumable.Evaluate(stat);
protected void AddHeat(float heat) => Item?.AddHeat(heat); // TODO: Heat for Consumables
@ -83,7 +81,7 @@ public abstract class Behavior
CauseDamage(Item.Wear * multiplier);
}
}
public virtual bool Execute(float dt)
{
return true;
@ -142,19 +140,17 @@ public interface IPopulationAssignment
int AssignedPopulation { get; set; }
}
[MessagePackObject,
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<PersistentBehaviorData>))]
[MessagePackObject]
public abstract class PersistentBehaviorData
{
}
[Inspectable,
[Inspectable,
Union(0, typeof(GuidedWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ReactorData)),
Union(3, typeof(RadiatorData)),
Union(4, typeof(StatModifierData)),
Union(2, typeof(ReactorData)),
Union(3, typeof(RadiatorData)),
Union(4, typeof(StatModifierData)),
Union(5, typeof(SensorData)),
Union(6, typeof(ReflectorData)),
Union(7, typeof(ShieldData)),
@ -187,13 +183,12 @@ public abstract class PersistentBehaviorData
Union(35, typeof(InstantWeaponData)),
Union(36, typeof(ConstantWeaponData)),
Union(37, typeof(ChargedWeaponData)),
Union(38, typeof(AutoWeaponData)),
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
Union(38, typeof(AutoWeaponData))]
public abstract class BehaviorData
{
[Inspectable, JsonProperty("group"), Key(0)]
[Inspectable, Key(0)]
public int Group;
public abstract Behavior CreateInstance(EquippedItem item);
public abstract Behavior CreateInstance(ConsumableItemEffect consumable);

View file

@ -4,24 +4,23 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class CapacitorData : BehaviorData
{
[Inspectable, JsonProperty("capacity"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Capacity = new PerformanceStat();
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Capacitor(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Capacitor(this, item);

View file

@ -2,54 +2,53 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ChargedWeaponData : InstantWeaponData
{
[Inspectable, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
[Inspectable, Key(21), RuntimeInspectable]
public PerformanceStat ChargeTime = new PerformanceStat();
[Inspectable, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
[Inspectable, Key(22), RuntimeInspectable]
public PerformanceStat ChargeEnergy = new PerformanceStat();
[Inspectable, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
[Inspectable, Key(23), RuntimeInspectable]
public PerformanceStat ChargeHeat = new PerformanceStat();
[Inspectable, JsonProperty("canFireEarly"), Key(24)]
[Inspectable, Key(24)]
public bool CanFireEarly;
[Inspectable, JsonProperty("failureCharge"), Key(25)]
[Inspectable, Key(25)]
public float FailureCharge;
[Inspectable, JsonProperty("failureDamage"), Key(26)]
[Inspectable, Key(26)]
public float FailureDamage = 1;
[Inspectable, JsonProperty("chargeDamage"), Key(27)]
[Inspectable, Key(27)]
public float ChargeFiringDamageMultiplier = 1;
[Inspectable, JsonProperty("chargeSpread"), Key(28)]
[Inspectable, Key(28)]
public float ChargeFiringSpreadMultiplier = 1;
[Inspectable, JsonProperty("chargeBurstCount"), Key(29)]
[Inspectable, Key(29)]
public float ChargeFiringBurstCountMultiplier = 1;
[Inspectable, JsonProperty("chargeVisibility"), Key(30)]
[Inspectable, Key(30)]
public float ChargeFiringVisibilityMultiplier = 1;
[Inspectable, JsonProperty("chargeVelocity"), Key(31)]
[Inspectable, Key(31)]
public float ChargeFiringVelocityMultiplier = 1;
[Inspectable, JsonProperty("chargeHeatMul"), Key(32)]
[Inspectable, Key(32)]
public float ChargeFiringHeatMultiplier = 1;
public override Behavior CreateInstance(EquippedItem item)
{
return new ChargedWeapon(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ChargedWeapon(this, item);
@ -63,11 +62,11 @@ public class ChargedWeapon : InstantWeapon
private bool _charged;
private float _charge;
private float _progress;
public float ChargeTime { get; protected set; }
public float ChargeEnergy { get; protected set; }
public float ChargeHeat { get; protected set; }
public override float DamagePerSecond => Damage * _data.ChargeFiringDamageMultiplier / (Cooldown + ChargeTime);
public override float RangeDamagePerSecond(float range)
{
@ -97,12 +96,12 @@ public class ChargedWeapon : InstantWeapon
{
get => _charge;
}
public ChargedWeapon(ChargedWeaponData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public ChargedWeapon(ChargedWeaponData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;

View file

@ -4,11 +4,10 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class CockpitData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)
@ -24,12 +23,12 @@ public class CockpitData : BehaviorData
public class Cockpit : Behavior
{
private CockpitData _data;
public Cockpit(CockpitData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public Cockpit(CockpitData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;

View file

@ -4,21 +4,20 @@
using System;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class ConstantWeaponData : WeaponData
{
[InspectablePrefab, JsonProperty("ammoInterval"), Key(17)]
[InspectablePrefab, Key(17)]
public float AmmoInterval = 1;
public override Behavior CreateInstance(EquippedItem item)
{
return new ConstantWeapon(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ConstantWeapon(this, item);
@ -32,17 +31,17 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
private float _ammoInterval;
private float _reload;
private bool _reloading;
public override int Ammo
{
get => _ammo;
}
public float Progress
{
get { return saturate(_reload); }
}
public override float DamagePerSecond => Damage;
public override float RangeDamagePerSecond(float range)
{
@ -53,7 +52,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
public event Action OnReloadComplete;
public event Action OnStartFiring;
public event Action OnStopFiring;
public void ResetEvents()
{
OnReloadBegin = null;
@ -95,7 +94,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
}
return false;
}
_ammoInterval -= dt / _data.AmmoInterval;
if (_ammoInterval < 0)
{
@ -109,7 +108,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
var item = cargo.ItemsOfType[_data.AmmoType][0];
if (item is SimpleCommodity simpleCommodity)
cargo.Remove(simpleCommodity, 1);
if(_data.MagazineSize > 1)
{
_reloading = true;

View file

@ -1,25 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(-10), RuntimeInspectable]
public class CooldownData : BehaviorData
{
[Inspectable, JsonProperty("cooldown"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Cooldown(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Cooldown(this, item);

View file

@ -1,26 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(-20), RuntimeInspectable]
public class EnergyDrawData : BehaviorData
{
[Inspectable, JsonProperty("draw"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat EnergyDraw = new PerformanceStat();
[Inspectable, JsonProperty("perSecond"), Key(2)]
[Inspectable, Key(2)]
public bool PerSecond;
public override Behavior CreateInstance(EquippedItem item)
{
return new EnergyDraw(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new EnergyDraw(this, item);

View file

@ -1,26 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
[Inspectable, MessagePackObject, Order(10)]
public class HeatData : BehaviorData
{
[Inspectable, JsonProperty("heat"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[Inspectable, JsonProperty("perSecond"), Key(2)]
[Inspectable, Key(2)]
public bool PerSecond;
public override Behavior CreateInstance(EquippedItem item)
{
return new Heat(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Heat(this, item);

View file

@ -4,11 +4,10 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class HeatStorageData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -2,23 +2,22 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class InstantWeaponData : WeaponData
{
[Inspectable, JsonProperty("count"), Key(17)]
[Inspectable, Key(17)]
public PerformanceStat Count = new PerformanceStat();
[Inspectable, JsonProperty("burstTime"), Key(18)]
[Inspectable, Key(18)]
public PerformanceStat BurstTime = new PerformanceStat();
[Inspectable, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
[Inspectable, Key(19), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
[InspectablePrefab, JsonProperty("ammoInterval"), Key(20)]
[InspectablePrefab, Key(20)]
public bool SingleAmmoBurst;
public override Behavior CreateInstance(EquippedItem item)
@ -93,7 +92,7 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
// If 1 ammo is consumed per burst, perform ammo and energy consumption here
// UseAmmo returns false when triggering reload; cancel firing if that is the case
if(_data.SingleAmmoBurst && (!Entity.TryConsumeEnergy(Energy) || !UseAmmo())) return;
_burstRemaining = (int) BurstCount;
_burstInterval = BurstTime / _burstRemaining;
_burstTimer = 0;
@ -116,13 +115,13 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
private bool UseAmmo()
{
if (_data.MagazineSize <= 1) return true;
if (_ammo > 0)
{
_ammo--;
return true;
}
var hasAmmo = true;
if (_data.AmmoType != Guid.Empty)
{
@ -177,7 +176,7 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
_burstRemaining = 0;
return false;
}
_burstRemaining--;
_burstTimer -= _burstInterval;
OnFire?.Invoke();

View file

@ -1,23 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-5), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(-5), RuntimeInspectable]
public class ItemUsageData : BehaviorData
{
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("item"), Key(1), RuntimeInspectable]
[InspectableDatabaseLink(typeof(SimpleCommodityData)), Key(1), RuntimeInspectable]
public Guid Item;
public override Behavior CreateInstance(EquippedItem item)
{
return new ItemUsage(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ItemUsage(this, item);
@ -48,7 +46,7 @@ public class ItemUsage : Behavior
cargo.Remove(simpleCommodity, 1);
if (item is CraftedItemInstance craftedItemInstance)
cargo.Remove(craftedItemInstance);
return true;
}
}

View file

@ -3,28 +3,27 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class LauncherData : LockWeaponData
{
[InspectableAnimationCurve, JsonProperty("guidance"), Key(26)]
[InspectableAnimationCurve, Key(26)]
public float4[] GuidanceCurve;
[InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(27)]
[InspectableAnimationCurve, Key(27)]
public float4[] ThrustCurve;
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(28)]
[InspectableAnimationCurve, Key(28)]
public float4[] LiftCurve;
[Inspectable, JsonProperty("thrust"), Key(29)]
[Inspectable, Key(29)]
public PerformanceStat Thrust = new PerformanceStat();
[Inspectable, JsonProperty("frequency"), Key(30)]
[Inspectable, Key(30)]
public float DodgeFrequency;
[Inspectable, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
[Inspectable, Key(31), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
@ -33,25 +32,25 @@ public class LauncherData : LockWeaponData
}
}
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class GuidedWeaponData : InstantWeaponData
{
[InspectableAnimationCurve, JsonProperty("guidance"), Key(21)]
[InspectableAnimationCurve, Key(21)]
public float4[] GuidanceCurve;
[InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(22)]
[InspectableAnimationCurve, Key(22)]
public float4[] ThrustCurve;
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(23)]
[InspectableAnimationCurve, Key(23)]
public float4[] LiftCurve;
[Inspectable, JsonProperty("thrust"), Key(24)]
[Inspectable, Key(24)]
public PerformanceStat Thrust = new PerformanceStat();
[Inspectable, JsonProperty("frequency"), Key(25)]
[Inspectable, Key(25)]
public float DodgeFrequency;
[Inspectable, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
[Inspectable, Key(26), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)

View file

@ -2,28 +2,27 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class LockWeaponData : InstantWeaponData
{
[Inspectable, JsonProperty("speed"), Key(21), RuntimeInspectable]
[Inspectable, Key(21), RuntimeInspectable]
public PerformanceStat LockSpeed = new PerformanceStat();
[Inspectable, JsonProperty("sensorImpact"), Key(22)]
[Inspectable, Key(22)]
public PerformanceStat SensorImpact = new PerformanceStat();
[Inspectable, JsonProperty("threshold"), Key(23), RuntimeInspectable]
[Inspectable, Key(23), RuntimeInspectable]
public PerformanceStat LockAngle = new PerformanceStat();
[Inspectable, JsonProperty("directionImpact"), Key(24)]
[Inspectable, Key(24)]
public PerformanceStat DirectionImpact = new PerformanceStat();
[Inspectable, JsonProperty("decay"), Key(25)]
[Inspectable, Key(25)]
public PerformanceStat Decay = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new LockWeapon(this, item);
@ -59,7 +58,7 @@ public class LockWeapon : InstantWeapon
{
get => saturate(_lock);
}
public LockWeapon(LockWeaponData data, EquippedItem item) : base(data, item)
{
_data = data;

View file

@ -1,29 +1,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
[Inspectable, MessagePackObject, Order(10)]
public class MiningToolData : BehaviorData
{
[Inspectable, JsonProperty("dps"), Key(1)]
[Inspectable, Key(1)]
public PerformanceStat DamagePerSecond = new PerformanceStat();
[Inspectable, JsonProperty("efficiency"), Key(2)]
[Inspectable, Key(2)]
public PerformanceStat Efficiency = new PerformanceStat();
[Inspectable, JsonProperty("penetration"), Key(3)]
[Inspectable, Key(3)]
public PerformanceStat Penetration = new PerformanceStat();
[Inspectable, JsonProperty("range"), Key(4)]
[Inspectable, Key(4)]
public PerformanceStat Range = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new MiningTool(this, item);
@ -38,7 +37,7 @@ public class MiningTool : Behavior
{
public Guid AsteroidBelt;
public int Asteroid;
private MiningToolData _data;
public float Range { get; private set; }
@ -56,8 +55,8 @@ public class MiningTool : Behavior
{
Range = Evaluate(_data.Range);
var belt = Entity.Zone.AsteroidBelts[AsteroidBelt];
if (AsteroidBelt != Guid.Empty &&
Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) &&
if (AsteroidBelt != Guid.Empty &&
Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) &&
length(Entity.Position.xz - belt.Transforms[Asteroid].xy) - belt.Transforms[Asteroid].w < Range)
{
Entity.Zone.MineAsteroid(

View file

@ -3,36 +3,35 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class RadiatorData : BehaviorData
{
[Inspectable, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Emissivity = new PerformanceStat();
[Inspectable, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat PumpedHeat = new PerformanceStat();
[InspectableTemperature, JsonProperty("temperatureFloor"), Key(3), RuntimeInspectable]
[InspectableTemperature, Key(3), RuntimeInspectable]
public float TemperatureFloor;
[Inspectable, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
[Inspectable, Key(4), RuntimeInspectable]
public PerformanceStat WasteHeat = new PerformanceStat();
[Inspectable, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
[Inspectable, Key(5), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
[Inspectable, JsonProperty("thermalMass"), Key(6), RuntimeInspectable]
[Inspectable, Key(6), RuntimeInspectable]
public PerformanceStat ThermalMass = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Radiator(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Radiator(this, item);
@ -42,12 +41,12 @@ public class RadiatorData : BehaviorData
public class Radiator : Behavior, IAlwaysUpdatedBehavior, IInitializableBehavior
{
public float RadiatorTemperature { get; private set; }
public float Emissivity { get; private set; }
public float PumpedHeat { get; private set; }
public float WasteHeat { get; private set; }
public float EnergyUsage { get; private set; }
private RadiatorData _data;
public Radiator(RadiatorData data, EquippedItem item) : base(data, item)
@ -67,19 +66,19 @@ public class Radiator : Behavior, IAlwaysUpdatedBehavior, IInitializableBehavior
var itemTemperature = Temperature;
var tempRatio = max(RadiatorTemperature / itemTemperature, 1);
// Temperature ratio would cause more waste heat than pump capacity, stop executing
if (tempRatio > PumpedHeat / WasteHeat) return true;
if (!Entity.TryConsumeEnergy(EnergyUsage * tempRatio * dt)) return false;
var pumpedHeat = PumpedHeat * max(itemTemperature - _data.TemperatureFloor, 0);
// Radiator temperature is below temperature floor, stop executing
if (pumpedHeat < 0.01f) return true;
var wasteHeat = WasteHeat * tempRatio;
AddHeat((wasteHeat - pumpedHeat) * dt);
RadiatorTemperature += pumpedHeat / Evaluate(_data.ThermalMass) * dt;

View file

@ -6,31 +6,30 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ReactorData : BehaviorData
{
[Inspectable, JsonProperty("charge"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Charge = new PerformanceStat();
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
[Inspectable, JsonProperty("overload"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat OverloadEfficiency = new PerformanceStat();
[Inspectable, JsonProperty("underload"), Key(4), RuntimeInspectable]
[Inspectable, Key(4), RuntimeInspectable]
public PerformanceStat ThrottlingFactor = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Reactor(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Reactor(this, item);
@ -42,7 +41,7 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
private ReactorData _data;
public float Draw { get; private set; }
public float CurrentLoadRatio { get; private set; }
public int Order => 100;
@ -91,7 +90,7 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
// Subtract the baseline charge from draw
Draw -= charge;
// Generate heat using baseline efficiency
var heat = charge / efficiency;
@ -100,10 +99,10 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
{
CurrentLoadRatio = (Draw + charge) / max(charge, .01f);
var overloadEfficiency = Evaluate(_data.OverloadEfficiency);
// Generate heat using overload efficiency, usually much less efficient!
heat += Draw / overloadEfficiency;
// Overload power will always neutralize the energy deficit
Draw = 0;
}
@ -139,9 +138,9 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
{
CurrentLoadRatio = 1;
}
Item.SetAudioParameter(SpecialAudioParameter.Intensity, max(.25f, 1 - 1 / CurrentLoadRatio));
AddHeat(heat);
return true;
}

View file

@ -3,24 +3,23 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ReflectorData : BehaviorData
{
[Inspectable, JsonProperty("crossSection"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat CrossSection = new PerformanceStat();
// [InspectableAnimationCurve, JsonProperty("visibility"), Key(1)]
// [InspectableAnimationCurve, Key(1)]
// public float4[] VisibilityCurve;
public override Behavior CreateInstance(EquippedItem item)
{
return new Reflector(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Reflector(this, item);
@ -44,7 +43,7 @@ public class Reflector : Behavior
public override bool Execute(float dt)
{
Entity.VisibilitySources[this] = Evaluate(_data.CrossSection) * Entity.Zone.GetLight(Entity.Position.xz);
return true;
}
}

View file

@ -1,31 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ResourceScannerData : BehaviorData
{
[Inspectable, JsonProperty("range"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Range = new PerformanceStat();
[Inspectable, JsonProperty("minDensity"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat MinimumDensity = new PerformanceStat();
[Inspectable, JsonProperty("scanDuration"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat ScanDuration = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new ResourceScanner(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ResourceScanner(this, item);
@ -35,7 +34,7 @@ public class ResourceScannerData : BehaviorData
public class ResourceScanner : Behavior, IAlwaysUpdatedBehavior
{
public int Asteroid = -1;
private ResourceScannerData _data;
private float _scanTime;
private Guid _scanTarget;

View file

@ -5,45 +5,44 @@
using System;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class SensorData : BehaviorData
{
[Inspectable, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat Sensitivity = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("sensCurve"), Key(4), RuntimeInspectable]
[InspectableAnimationCurve, Key(4), RuntimeInspectable]
public BezierCurve SensitivityCurve;
[Inspectable, JsonProperty("pingBoost"), Key(5), RuntimeInspectable]
[Inspectable, Key(5), RuntimeInspectable]
public PerformanceStat PingBoost;
[Inspectable, JsonProperty("pingEnergy"), Key(6), RuntimeInspectable]
[Inspectable, Key(6), RuntimeInspectable]
public PerformanceStat PingEnergy;
[Inspectable, JsonProperty("pingVisibility"), Key(7), RuntimeInspectable]
[Inspectable, Key(7), RuntimeInspectable]
public PerformanceStat PingVisibility;
[Inspectable, JsonProperty("pingRange"), Key(8), RuntimeInspectable]
[Inspectable, Key(8), RuntimeInspectable]
public PerformanceStat PingRange;
[Inspectable, JsonProperty("pingCooldown"), Key(9), RuntimeInspectable]
[Inspectable, Key(9), RuntimeInspectable]
public PerformanceStat PingCooldown;
[Inspectable, JsonProperty("pingDuration"), Key(10)]
[Inspectable, Key(10)]
public float PingDuration = 2;
[Inspectable, JsonProperty("pingRadiusExponent"), Key(11)]
[Inspectable, Key(11)]
public float PingRadiusExponent = .5f;
public override Behavior CreateInstance(EquippedItem item)
{
return new Sensor(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Sensor(this, item);
@ -63,7 +62,7 @@ public class Sensor : Behavior, IEventBehavior
{
get => saturate(_pingCooldown);
}
public float PingRadius
{
get => _pingRadius;
@ -118,13 +117,13 @@ public class Sensor : Behavior, IEventBehavior
}
_pingCooldown -= dt / Evaluate(_data.PingCooldown);
// TODO: Handle Active Detection / Visibility From Reflected Radiance
var forward = Direction.xz;
foreach (var entity in Entity.Zone.Entities)
{
if (entity == Entity) continue;
var diff = entity.Position.xz - Entity.Position.xz;
var angle = acos(dot(forward, normalize(diff)));
var dist = length(diff);

View file

@ -3,19 +3,18 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ShieldData : BehaviorData
{
[Inspectable, JsonProperty("efficiency"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
[Inspectable, JsonProperty("energy"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Shield(this, item);

View file

@ -1,27 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class StatModifierData : BehaviorData
{
[Inspectable, JsonProperty("stat"), Key(1)]
[Inspectable, Key(1)]
public StatReference Stat = new StatReference();
[Inspectable, JsonProperty("modifier"), Key(2)]
[Inspectable, Key(2)]
public PerformanceStat Modifier = new PerformanceStat();
[Inspectable, JsonProperty("type"), Key(3)]
[Inspectable, Key(3)]
public StatModifierType Type;
[InspectableType(typeof(BehaviorData)), JsonProperty("requireBehavior"), Key(4)]
[InspectableType(typeof(BehaviorData)), Key(4)]
public Type RequireBehavior;
public override Behavior CreateInstance(EquippedItem item)
{
return new StatModifier(this, item);
@ -39,7 +37,7 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa
private StatModifierData _data;
private PerformanceStat[] _stats;
private static Type[] _statObjects;
private bool _applied;
@ -130,12 +128,12 @@ public enum StatModifierType
Multiplier
}
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class StatReference
{
[InspectableType(typeof(BehaviorData)), JsonProperty("behavior"), Key(1)]
[InspectableType(typeof(BehaviorData)), Key(1)]
public string Target;
[Inspectable, JsonProperty("stat"), Key(2)]
[Inspectable, Key(2)]
public string Stat;
}

View file

@ -1,13 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
[Inspectable, MessagePackObject, Order(-25)]
public class SwitchData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -1,24 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
[Inspectable, MessagePackObject, Order(-22)]
public class ThermotoggleData : BehaviorData
{
[InspectableTemperature, JsonProperty("targetTemp"), Key(1)]
[InspectableTemperature, Key(1)]
public float TargetTemperature;
[Inspectable, JsonProperty("highPass"), Key(2)]
[Inspectable, Key(2)]
public bool HighPass;
[Inspectable, JsonProperty("adjustable"), Key(3)]
[Inspectable, Key(3)]
public bool Adjustable;
public override Behavior CreateInstance(EquippedItem item)
{
return new Thermotoggle(this, item);

View file

@ -3,33 +3,32 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
[Inspectable, MessagePackObject, EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
public class ThrusterData : BehaviorData
{
[Inspectable, JsonProperty("thrust"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Thrust = new PerformanceStat();
[Inspectable, JsonProperty("visibility"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[Inspectable, JsonProperty("heat"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[Inspectable, JsonProperty("energy"), Key(4), RuntimeInspectable]
[Inspectable, Key(4), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
[InspectablePrefab, JsonProperty("Particles"), Key(5)]
[InspectablePrefab, Key(5)]
public string ParticlesPrefab;
public override Behavior CreateInstance(EquippedItem item)
{
return new Thruster(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Thruster(this, item);
@ -48,7 +47,7 @@ public class Thruster : Behavior, IAnalogBehavior
}
private ThrusterData _data;
private float _input;
public Thruster(ThrusterData data, EquippedItem item) : base(data, item)

View file

@ -1,13 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20)]
[Inspectable, MessagePackObject, Order(-20)]
public class TriggerData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -1,17 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float3 = Unity.Mathematics.float3;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[MessagePackObject, RuntimeInspectable]
public class TurretControllerData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -3,16 +3,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[MessagePackObject, RuntimeInspectable]
public class VelocityConversionData : BehaviorData
{
[Inspectable, JsonProperty("lambda"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Lambda = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new VelocityConversion(this, item);

View file

@ -3,16 +3,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class VelocityLimitData : BehaviorData
{
[Inspectable, JsonProperty("topSpeed"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat TopSpeed = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new VelocityLimit(this, item);

View file

@ -1,21 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class VisibilityData : BehaviorData
{
[Inspectable, JsonProperty("visibility"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[Inspectable, JsonProperty("visibilityDecay"), Key(2)]
[Inspectable, Key(2)]
public PerformanceStat VisibilityDecay = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Visibility(this, item);

View file

@ -6,64 +6,63 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable,
[Inspectable,
Union(0, typeof(InstantWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ConstantWeaponData)),
Union(3, typeof(ChargedWeaponData)),
Union(2, typeof(ConstantWeaponData)),
Union(3, typeof(ChargedWeaponData)),
RuntimeInspectable]
public abstract class WeaponData : BehaviorData
{
[Inspectable, JsonProperty("damageType"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public DamageType DamageType;
[Inspectable, JsonProperty("damage"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Damage = new PerformanceStat();
[InspectableRangedFloat(0,1), JsonProperty("penetration"), Key(3), RuntimeInspectable]
[InspectableRangedFloat(0,1), Key(3), RuntimeInspectable]
public PerformanceStat Penetration = new PerformanceStat();
[InspectableRangedFloat(0,1), JsonProperty("damageSpread"), Key(4)]
[InspectableRangedFloat(0,1), Key(4)]
public PerformanceStat DamageSpread = new PerformanceStat();
[Inspectable, JsonProperty("minRange"), Key(5)]
[Inspectable, Key(5)]
public PerformanceStat MinRange = new PerformanceStat();
[Inspectable, JsonProperty("range"), Key(6)]
[Inspectable, Key(6)]
public PerformanceStat Range = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("damageCurve"), Key(7)]
[InspectableAnimationCurve, Key(7)]
public BezierCurve DamageCurve;
[InspectablePrefab, JsonProperty("effect"), Key(8)]
[InspectablePrefab, Key(8)]
public string EffectPrefab;
[InspectablePrefab, JsonProperty("energy"), Key(9), RuntimeInspectable]
[InspectablePrefab, Key(9), RuntimeInspectable]
public PerformanceStat Energy = new PerformanceStat();
[InspectablePrefab, JsonProperty("heat"), Key(10), RuntimeInspectable]
[InspectablePrefab, Key(10), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[InspectablePrefab, JsonProperty("visibility"), Key(11), RuntimeInspectable]
[InspectablePrefab, Key(11), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("ammo"), Key(12), RuntimeInspectable]
[InspectableDatabaseLink(typeof(SimpleCommodityData)), Key(12), RuntimeInspectable]
public Guid AmmoType;
[InspectablePrefab, JsonProperty("magSize"), Key(13)]
[InspectablePrefab, Key(13)]
public int MagazineSize;
[InspectablePrefab, JsonProperty("reloadTime"), Key(14)]
[InspectablePrefab, Key(14)]
public float ReloadTime = 1;
[InspectablePrefab, JsonProperty("spread"), Key(15)]
[InspectablePrefab, Key(15)]
public PerformanceStat Spread = new PerformanceStat();
[Inspectable, JsonProperty("velocity"), Key(16)]
[Inspectable, Key(16)]
public PerformanceStat Velocity = new PerformanceStat();
}
@ -75,7 +74,7 @@ public abstract class Weapon : Behavior, IActivatedBehavior
public abstract float RangeDamagePerSecond(float range);
public abstract int Ammo { get; }
public WeaponData WeaponData => _data;
public float Damage { get; protected set; }
public float Penetration { get; protected set; }
public float DamageSpread { get; protected set; }
@ -93,12 +92,12 @@ public abstract class Weapon : Behavior, IActivatedBehavior
{
get => _firing;
}
public Weapon(WeaponData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public Weapon(WeaponData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;

View file

@ -4,16 +4,15 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(1000), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(1000), RuntimeInspectable]
public class WearData : BehaviorData
{
[InspectableTemperature, JsonProperty("perSecond"), Key(1)]
[InspectableTemperature, Key(1)]
public bool PerSecond = true;
public override Behavior CreateInstance(EquippedItem item)
{
return new Wear(this, item);