Delete runtime behavior config bridge
This commit is contained in:
parent
6479f6fcfa
commit
18a4ead6f8
13 changed files with 243 additions and 705 deletions
|
|
@ -4,20 +4,11 @@ using System.Collections.Generic;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable]
|
||||
public class AutoWeaponConfig : InstantWeaponConfig
|
||||
{
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new AutoWeapon(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoWeapon : InstantWeapon
|
||||
{
|
||||
|
||||
public AutoWeapon(InstantWeaponConfig data, EquippedItem item) : base(data, item) { }
|
||||
public AutoWeapon(InstantWeaponConfig data, ConsumableItemEffect item) : base(data, item) { }
|
||||
public AutoWeapon(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item) { }
|
||||
public AutoWeapon(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item) { }
|
||||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -45,24 +45,6 @@ public abstract class Behavior
|
|||
}
|
||||
}
|
||||
|
||||
protected Behavior(RuntimeBehaviorConfig config, EquippedItem item)
|
||||
{
|
||||
_performanceStats = CapturePerformanceStats(config);
|
||||
Kind = config?.Kind ?? "";
|
||||
Group = config?.Group ?? 0;
|
||||
Item = item;
|
||||
ItemManager = Item.ItemManager;
|
||||
}
|
||||
|
||||
protected Behavior(RuntimeBehaviorConfig config, ConsumableItemEffect consumable)
|
||||
{
|
||||
_performanceStats = CapturePerformanceStats(config);
|
||||
Kind = config?.Kind ?? "";
|
||||
Group = config?.Group ?? 0;
|
||||
Consumable = consumable;
|
||||
ItemManager = consumable.Entity.ItemManager;
|
||||
}
|
||||
|
||||
protected Behavior(RuntimeBehaviorDefinition definition, EquippedItem item)
|
||||
{
|
||||
_performanceStats = new Dictionary<string, PerformanceStat>(StringComparer.Ordinal);
|
||||
|
|
@ -103,19 +85,6 @@ public abstract class Behavior
|
|||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, PerformanceStat> CapturePerformanceStats(RuntimeBehaviorConfig config)
|
||||
{
|
||||
return config == null
|
||||
? new Dictionary<string, PerformanceStat>(StringComparer.Ordinal)
|
||||
: config
|
||||
.GetType()
|
||||
.GetFields()
|
||||
.Where(field => field.FieldType == typeof(PerformanceStat))
|
||||
.Select(field => (field.Name, Stat: field.GetValue(config) as PerformanceStat))
|
||||
.Where(entry => entry.Stat != null)
|
||||
.ToDictionary(entry => entry.Name, entry => entry.Stat, StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
protected void AddHeat(float heat) => Item?.AddHeat(heat); // TODO: Heat for Consumables
|
||||
|
||||
protected void CauseDamage(float damage)
|
||||
|
|
@ -229,6 +198,11 @@ public sealed class RuntimeBehaviorDefinition
|
|||
return _fields.TryGetValue(key, out var value) ? (float)value.NumberValue : fallback;
|
||||
}
|
||||
|
||||
public int Int(int key, int fallback = 0)
|
||||
{
|
||||
return _fields.TryGetValue(key, out var value) ? checked((int)value.NumberValue) : fallback;
|
||||
}
|
||||
|
||||
public uint UInt(int key, uint fallback = 0)
|
||||
{
|
||||
return _fields.TryGetValue(key, out var value) ? checked((uint)value.NumberValue) : fallback;
|
||||
|
|
@ -272,6 +246,13 @@ public sealed class RuntimeBehaviorDefinition
|
|||
};
|
||||
}
|
||||
|
||||
public float4[] Float4Array(int key, float4[] fallback)
|
||||
{
|
||||
return _fields.TryGetValue(key, out var value)
|
||||
? value.Children.Select(ToFloat4).ToArray()
|
||||
: fallback;
|
||||
}
|
||||
|
||||
public StatReference StatReference(int key, StatReference fallback)
|
||||
{
|
||||
if (!_fields.TryGetValue(key, out var value))
|
||||
|
|
@ -334,20 +315,3 @@ public sealed class RuntimeBehaviorDefinition
|
|||
return value.Children.Count > index ? value.Children[index].StringValue ?? "" : "";
|
||||
}
|
||||
}
|
||||
|
||||
[Inspectable]
|
||||
public abstract class RuntimeBehaviorConfig
|
||||
{
|
||||
public string Kind { get; set; } = "";
|
||||
|
||||
[Inspectable]
|
||||
public int Group;
|
||||
|
||||
public abstract Behavior CreateInstance(EquippedItem item);
|
||||
public abstract Behavior CreateInstance(ConsumableItemEffect consumable);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString().FormatTypeName();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,56 +4,6 @@ using System.Collections.Generic;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable]
|
||||
public class ChargedWeaponConfig : InstantWeaponConfig
|
||||
{
|
||||
[Inspectable]
|
||||
public PerformanceStat ChargeTime = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat ChargeEnergy = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat ChargeHeat = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public bool CanFireEarly;
|
||||
|
||||
[Inspectable]
|
||||
public float FailureCharge;
|
||||
|
||||
[Inspectable]
|
||||
public float FailureDamage = 1;
|
||||
|
||||
[Inspectable]
|
||||
public float ChargeFiringDamageMultiplier = 1;
|
||||
|
||||
[Inspectable]
|
||||
public float ChargeFiringSpreadMultiplier = 1;
|
||||
|
||||
[Inspectable]
|
||||
public float ChargeFiringBurstCountMultiplier = 1;
|
||||
|
||||
[Inspectable]
|
||||
public float ChargeFiringVisibilityMultiplier = 1;
|
||||
|
||||
[Inspectable]
|
||||
public float ChargeFiringVelocityMultiplier = 1;
|
||||
|
||||
[Inspectable]
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public class ChargedWeapon : InstantWeapon
|
||||
{
|
||||
private readonly PerformanceStat _chargeTime;
|
||||
|
|
@ -109,36 +59,45 @@ public class ChargedWeapon : InstantWeapon
|
|||
public bool Charging => _charging;
|
||||
public bool Charged => _charged;
|
||||
|
||||
public ChargedWeapon(ChargedWeaponConfig data, EquippedItem item) : base(data, item)
|
||||
public ChargedWeapon(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
{
|
||||
_chargeTime = data.ChargeTime;
|
||||
_chargeEnergy = data.ChargeEnergy;
|
||||
_chargeHeat = data.ChargeHeat;
|
||||
_canFireEarly = data.CanFireEarly;
|
||||
_failureCharge = data.FailureCharge;
|
||||
_failureDamage = data.FailureDamage;
|
||||
_chargeFiringDamageMultiplier = data.ChargeFiringDamageMultiplier;
|
||||
_chargeFiringSpreadMultiplier = data.ChargeFiringSpreadMultiplier;
|
||||
_chargeFiringBurstCountMultiplier = data.ChargeFiringBurstCountMultiplier;
|
||||
_chargeFiringVisibilityMultiplier = data.ChargeFiringVisibilityMultiplier;
|
||||
_chargeFiringVelocityMultiplier = data.ChargeFiringVelocityMultiplier;
|
||||
_chargeFiringHeatMultiplier = data.ChargeFiringHeatMultiplier;
|
||||
_chargeTime = definition.PerformanceStat(21, new PerformanceStat());
|
||||
_chargeEnergy = definition.PerformanceStat(22, new PerformanceStat());
|
||||
_chargeHeat = definition.PerformanceStat(23, new PerformanceStat());
|
||||
_canFireEarly = definition.Bool(24);
|
||||
_failureCharge = definition.Float(25);
|
||||
_failureDamage = definition.Float(26, 1);
|
||||
_chargeFiringDamageMultiplier = definition.Float(27, 1);
|
||||
_chargeFiringSpreadMultiplier = definition.Float(28, 1);
|
||||
_chargeFiringBurstCountMultiplier = definition.Float(29, 1);
|
||||
_chargeFiringVisibilityMultiplier = definition.Float(30, 1);
|
||||
_chargeFiringVelocityMultiplier = definition.Float(31, 1);
|
||||
_chargeFiringHeatMultiplier = definition.Float(32, 1);
|
||||
RegisterChargedWeaponStats();
|
||||
}
|
||||
|
||||
public ChargedWeapon(ChargedWeaponConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
public ChargedWeapon(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
{
|
||||
_chargeTime = data.ChargeTime;
|
||||
_chargeEnergy = data.ChargeEnergy;
|
||||
_chargeHeat = data.ChargeHeat;
|
||||
_canFireEarly = data.CanFireEarly;
|
||||
_failureCharge = data.FailureCharge;
|
||||
_failureDamage = data.FailureDamage;
|
||||
_chargeFiringDamageMultiplier = data.ChargeFiringDamageMultiplier;
|
||||
_chargeFiringSpreadMultiplier = data.ChargeFiringSpreadMultiplier;
|
||||
_chargeFiringBurstCountMultiplier = data.ChargeFiringBurstCountMultiplier;
|
||||
_chargeFiringVisibilityMultiplier = data.ChargeFiringVisibilityMultiplier;
|
||||
_chargeFiringVelocityMultiplier = data.ChargeFiringVelocityMultiplier;
|
||||
_chargeFiringHeatMultiplier = data.ChargeFiringHeatMultiplier;
|
||||
_chargeTime = definition.PerformanceStat(21, new PerformanceStat());
|
||||
_chargeEnergy = definition.PerformanceStat(22, new PerformanceStat());
|
||||
_chargeHeat = definition.PerformanceStat(23, new PerformanceStat());
|
||||
_canFireEarly = definition.Bool(24);
|
||||
_failureCharge = definition.Float(25);
|
||||
_failureDamage = definition.Float(26, 1);
|
||||
_chargeFiringDamageMultiplier = definition.Float(27, 1);
|
||||
_chargeFiringSpreadMultiplier = definition.Float(28, 1);
|
||||
_chargeFiringBurstCountMultiplier = definition.Float(29, 1);
|
||||
_chargeFiringVisibilityMultiplier = definition.Float(30, 1);
|
||||
_chargeFiringVelocityMultiplier = definition.Float(31, 1);
|
||||
_chargeFiringHeatMultiplier = definition.Float(32, 1);
|
||||
RegisterChargedWeaponStats();
|
||||
}
|
||||
|
||||
private void RegisterChargedWeaponStats()
|
||||
{
|
||||
RegisterPerformanceStat(nameof(ChargeTime), _chargeTime);
|
||||
RegisterPerformanceStat(nameof(ChargeEnergy), _chargeEnergy);
|
||||
RegisterPerformanceStat(nameof(ChargeHeat), _chargeHeat);
|
||||
}
|
||||
|
||||
protected override void UpdateStats()
|
||||
|
|
|
|||
|
|
@ -6,23 +6,6 @@ using System;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable]
|
||||
public class ConstantWeaponConfig : WeaponConfig
|
||||
{
|
||||
[InspectablePrefab]
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
||||
{
|
||||
private readonly float _ammoIntervalDuration;
|
||||
|
|
@ -63,14 +46,14 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
OnStopFiring = null;
|
||||
}
|
||||
|
||||
public ConstantWeapon(ConstantWeaponConfig data, EquippedItem item) : base(data, item)
|
||||
public ConstantWeapon(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
{
|
||||
_ammoIntervalDuration = data.AmmoInterval;
|
||||
_ammoIntervalDuration = definition.Float(17, 1);
|
||||
}
|
||||
|
||||
public ConstantWeapon(ConstantWeaponConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
public ConstantWeapon(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
{
|
||||
_ammoIntervalDuration = data.AmmoInterval;
|
||||
_ammoIntervalDuration = definition.Float(17, 1);
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
|
|
|
|||
|
|
@ -4,32 +4,6 @@ using System.Collections.Generic;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable]
|
||||
public class InstantWeaponConfig : WeaponConfig
|
||||
{
|
||||
[Inspectable]
|
||||
public PerformanceStat Count = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat BurstTime = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Cooldown = new PerformanceStat();
|
||||
|
||||
[InspectablePrefab]
|
||||
public bool SingleAmmoBurst;
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new InstantWeapon(this, item);
|
||||
}
|
||||
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new InstantWeapon(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
||||
{
|
||||
private readonly PerformanceStat _count;
|
||||
|
|
@ -82,22 +56,31 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
|
|||
OnFire = null;
|
||||
}
|
||||
|
||||
public InstantWeapon(InstantWeaponConfig data, EquippedItem item) : base(data, item)
|
||||
public InstantWeapon(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
{
|
||||
_count = data.Count;
|
||||
_burstTime = data.BurstTime;
|
||||
_cooldownDuration = data.Cooldown;
|
||||
_singleAmmoBurst = data.SingleAmmoBurst;
|
||||
_ammo = data.MagazineSize;
|
||||
_count = definition.PerformanceStat(17, new PerformanceStat());
|
||||
_burstTime = definition.PerformanceStat(18, new PerformanceStat());
|
||||
_cooldownDuration = definition.PerformanceStat(19, new PerformanceStat());
|
||||
_singleAmmoBurst = definition.Bool(20);
|
||||
_ammo = MagazineSize;
|
||||
RegisterInstantWeaponStats();
|
||||
}
|
||||
|
||||
public InstantWeapon(InstantWeaponConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
public InstantWeapon(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
{
|
||||
_count = data.Count;
|
||||
_burstTime = data.BurstTime;
|
||||
_cooldownDuration = data.Cooldown;
|
||||
_singleAmmoBurst = data.SingleAmmoBurst;
|
||||
_ammo = data.MagazineSize;
|
||||
_count = definition.PerformanceStat(17, new PerformanceStat());
|
||||
_burstTime = definition.PerformanceStat(18, new PerformanceStat());
|
||||
_cooldownDuration = definition.PerformanceStat(19, new PerformanceStat());
|
||||
_singleAmmoBurst = definition.Bool(20);
|
||||
_ammo = MagazineSize;
|
||||
RegisterInstantWeaponStats();
|
||||
}
|
||||
|
||||
private void RegisterInstantWeaponStats()
|
||||
{
|
||||
RegisterPerformanceStat("Count", _count);
|
||||
RegisterPerformanceStat(nameof(BurstTime), _burstTime);
|
||||
RegisterPerformanceStat(nameof(Cooldown), _cooldownDuration);
|
||||
}
|
||||
|
||||
protected void Trigger()
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
/* 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 Unity.Mathematics;
|
||||
|
||||
[Inspectable]
|
||||
public class LauncherConfig : LockWeaponConfig
|
||||
{
|
||||
[InspectableAnimationCurve]
|
||||
public float4[] GuidanceCurve;
|
||||
|
||||
[InspectableAnimationCurve]
|
||||
public float4[] ThrustCurve;
|
||||
|
||||
[InspectableAnimationCurve]
|
||||
public float4[] LiftCurve;
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Thrust = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public float DodgeFrequency;
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat MissileVelocity = new PerformanceStat();
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new LockWeapon(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
[Inspectable]
|
||||
public class GuidedWeaponConfig : InstantWeaponConfig
|
||||
{
|
||||
[InspectableAnimationCurve]
|
||||
public float4[] GuidanceCurve;
|
||||
|
||||
[InspectableAnimationCurve]
|
||||
public float4[] ThrustCurve;
|
||||
|
||||
[InspectableAnimationCurve]
|
||||
public float4[] LiftCurve;
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Thrust = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public float DodgeFrequency;
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat MissileVelocity = new PerformanceStat();
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new InstantWeapon(this, item);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5fd0ce9fd7384ba5a40c2ba41ece74eb
|
||||
timeCreated: 1584292825
|
||||
|
|
@ -4,34 +4,6 @@ using System.Collections.Generic;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable]
|
||||
public class LockWeaponConfig : InstantWeaponConfig
|
||||
{
|
||||
[Inspectable]
|
||||
public PerformanceStat LockSpeed = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat SensorImpact = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat LockAngle = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat DirectionImpact = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Decay = new PerformanceStat();
|
||||
|
||||
public override Behavior CreateInstance(EquippedItem item)
|
||||
{
|
||||
return new LockWeapon(this, item);
|
||||
}
|
||||
public override Behavior CreateInstance(ConsumableItemEffect item)
|
||||
{
|
||||
return new LockWeapon(this, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class LockWeapon : InstantWeapon
|
||||
{
|
||||
private readonly PerformanceStat _lockSpeed;
|
||||
|
|
@ -66,21 +38,32 @@ public class LockWeapon : InstantWeapon
|
|||
|
||||
public Entity LockTarget => _target;
|
||||
|
||||
public LockWeapon(LockWeaponConfig data, EquippedItem item) : base(data, item)
|
||||
public LockWeapon(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
{
|
||||
_lockSpeed = data.LockSpeed;
|
||||
_sensorImpact = data.SensorImpact;
|
||||
_lockAngle = data.LockAngle;
|
||||
_directionImpact = data.DirectionImpact;
|
||||
_decay = data.Decay;
|
||||
_lockSpeed = definition.PerformanceStat(21, new PerformanceStat());
|
||||
_sensorImpact = definition.PerformanceStat(22, new PerformanceStat());
|
||||
_lockAngle = definition.PerformanceStat(23, new PerformanceStat());
|
||||
_directionImpact = definition.PerformanceStat(24, new PerformanceStat());
|
||||
_decay = definition.PerformanceStat(25, new PerformanceStat());
|
||||
RegisterLockWeaponStats();
|
||||
}
|
||||
public LockWeapon(LockWeaponConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
public LockWeapon(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
{
|
||||
_lockSpeed = data.LockSpeed;
|
||||
_sensorImpact = data.SensorImpact;
|
||||
_lockAngle = data.LockAngle;
|
||||
_directionImpact = data.DirectionImpact;
|
||||
_decay = data.Decay;
|
||||
_lockSpeed = definition.PerformanceStat(21, new PerformanceStat());
|
||||
_sensorImpact = definition.PerformanceStat(22, new PerformanceStat());
|
||||
_lockAngle = definition.PerformanceStat(23, new PerformanceStat());
|
||||
_directionImpact = definition.PerformanceStat(24, new PerformanceStat());
|
||||
_decay = definition.PerformanceStat(25, new PerformanceStat());
|
||||
RegisterLockWeaponStats();
|
||||
}
|
||||
|
||||
private void RegisterLockWeaponStats()
|
||||
{
|
||||
RegisterPerformanceStat(nameof(LockSpeed), _lockSpeed);
|
||||
RegisterPerformanceStat(nameof(SensorImpact), _sensorImpact);
|
||||
RegisterPerformanceStat(nameof(LockAngle), _lockAngle);
|
||||
RegisterPerformanceStat(nameof(DirectionImpact), _directionImpact);
|
||||
RegisterPerformanceStat(nameof(Decay), _decay);
|
||||
}
|
||||
|
||||
public override bool Execute(float dt)
|
||||
|
|
|
|||
|
|
@ -7,56 +7,6 @@ using System.Linq;
|
|||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Inspectable]
|
||||
public abstract class WeaponConfig : RuntimeBehaviorConfig
|
||||
{
|
||||
[Inspectable]
|
||||
public DamageType DamageType;
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Damage = new PerformanceStat();
|
||||
|
||||
[InspectableRangedFloat(0,1)]
|
||||
public PerformanceStat Penetration = new PerformanceStat();
|
||||
|
||||
[InspectableRangedFloat(0,1)]
|
||||
public PerformanceStat DamageSpread = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat MinRange = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Range = new PerformanceStat();
|
||||
|
||||
[InspectableAnimationCurve]
|
||||
public BezierCurve DamageCurve;
|
||||
|
||||
[InspectablePrefab]
|
||||
public string EffectPrefab;
|
||||
|
||||
[InspectablePrefab]
|
||||
public PerformanceStat Energy = new PerformanceStat();
|
||||
|
||||
[InspectablePrefab]
|
||||
public PerformanceStat Heat = new PerformanceStat();
|
||||
|
||||
[InspectablePrefab]
|
||||
public PerformanceStat Visibility = new PerformanceStat();
|
||||
public string AmmoItemKey;
|
||||
|
||||
[InspectablePrefab]
|
||||
public int MagazineSize;
|
||||
|
||||
[InspectablePrefab]
|
||||
public float ReloadTime = 1;
|
||||
|
||||
[InspectablePrefab]
|
||||
public PerformanceStat Spread = new PerformanceStat();
|
||||
|
||||
[Inspectable]
|
||||
public PerformanceStat Velocity = new PerformanceStat();
|
||||
}
|
||||
|
||||
public abstract class Weapon : Behavior, IActivatedBehavior
|
||||
{
|
||||
private readonly PerformanceStat _damage;
|
||||
|
|
@ -107,70 +57,89 @@ public abstract class Weapon : Behavior, IActivatedBehavior
|
|||
get => _firing;
|
||||
}
|
||||
|
||||
public Weapon(WeaponConfig data, EquippedItem item) : base(data, item)
|
||||
public Weapon(RuntimeBehaviorDefinition definition, EquippedItem item) : base(definition, item)
|
||||
{
|
||||
_damage = data.Damage;
|
||||
_penetration = data.Penetration;
|
||||
_damageSpread = data.DamageSpread;
|
||||
_minRange = data.MinRange;
|
||||
_range = data.Range;
|
||||
_energy = data.Energy;
|
||||
_heat = data.Heat;
|
||||
_visibility = data.Visibility;
|
||||
_spread = data.Spread;
|
||||
_velocity = data.Velocity;
|
||||
DamageType = data.DamageType;
|
||||
DamageCurve = data.DamageCurve;
|
||||
EffectPrefab = data.EffectPrefab ?? "";
|
||||
AmmoItemKey = data.AmmoItemKey;
|
||||
MagazineSize = data.MagazineSize;
|
||||
ReloadTime = data.ReloadTime;
|
||||
InitializeGuidedProjectileProfile(data);
|
||||
_damage = definition.PerformanceStat(2, new PerformanceStat());
|
||||
_penetration = definition.PerformanceStat(3, new PerformanceStat());
|
||||
_damageSpread = definition.PerformanceStat(4, new PerformanceStat());
|
||||
_minRange = definition.PerformanceStat(5, new PerformanceStat());
|
||||
_range = definition.PerformanceStat(6, new PerformanceStat());
|
||||
_energy = definition.PerformanceStat(9, new PerformanceStat());
|
||||
_heat = definition.PerformanceStat(10, new PerformanceStat());
|
||||
_visibility = definition.PerformanceStat(11, new PerformanceStat());
|
||||
_spread = definition.PerformanceStat(15, new PerformanceStat());
|
||||
_velocity = definition.PerformanceStat(16, new PerformanceStat());
|
||||
DamageType = definition.Enum(1, default(DamageType));
|
||||
DamageCurve = definition.BezierCurve(7, null);
|
||||
EffectPrefab = definition.String(8);
|
||||
AmmoItemKey = definition.ItemKey(12);
|
||||
MagazineSize = definition.Int(13);
|
||||
ReloadTime = definition.Float(14, 1);
|
||||
RegisterWeaponStats();
|
||||
InitializeGuidedProjectileProfile(definition);
|
||||
}
|
||||
|
||||
public Weapon(WeaponConfig data, ConsumableItemEffect item) : base(data, item)
|
||||
public Weapon(RuntimeBehaviorDefinition definition, ConsumableItemEffect item) : base(definition, item)
|
||||
{
|
||||
_damage = data.Damage;
|
||||
_penetration = data.Penetration;
|
||||
_damageSpread = data.DamageSpread;
|
||||
_minRange = data.MinRange;
|
||||
_range = data.Range;
|
||||
_energy = data.Energy;
|
||||
_heat = data.Heat;
|
||||
_visibility = data.Visibility;
|
||||
_spread = data.Spread;
|
||||
_velocity = data.Velocity;
|
||||
DamageType = data.DamageType;
|
||||
DamageCurve = data.DamageCurve;
|
||||
EffectPrefab = data.EffectPrefab ?? "";
|
||||
AmmoItemKey = data.AmmoItemKey;
|
||||
MagazineSize = data.MagazineSize;
|
||||
ReloadTime = data.ReloadTime;
|
||||
InitializeGuidedProjectileProfile(data);
|
||||
_damage = definition.PerformanceStat(2, new PerformanceStat());
|
||||
_penetration = definition.PerformanceStat(3, new PerformanceStat());
|
||||
_damageSpread = definition.PerformanceStat(4, new PerformanceStat());
|
||||
_minRange = definition.PerformanceStat(5, new PerformanceStat());
|
||||
_range = definition.PerformanceStat(6, new PerformanceStat());
|
||||
_energy = definition.PerformanceStat(9, new PerformanceStat());
|
||||
_heat = definition.PerformanceStat(10, new PerformanceStat());
|
||||
_visibility = definition.PerformanceStat(11, new PerformanceStat());
|
||||
_spread = definition.PerformanceStat(15, new PerformanceStat());
|
||||
_velocity = definition.PerformanceStat(16, new PerformanceStat());
|
||||
DamageType = definition.Enum(1, default(DamageType));
|
||||
DamageCurve = definition.BezierCurve(7, null);
|
||||
EffectPrefab = definition.String(8);
|
||||
AmmoItemKey = definition.ItemKey(12);
|
||||
MagazineSize = definition.Int(13);
|
||||
ReloadTime = definition.Float(14, 1);
|
||||
RegisterWeaponStats();
|
||||
InitializeGuidedProjectileProfile(definition);
|
||||
}
|
||||
|
||||
private void InitializeGuidedProjectileProfile(WeaponConfig data)
|
||||
private void RegisterWeaponStats()
|
||||
{
|
||||
if (data is LauncherConfig launcher)
|
||||
RegisterPerformanceStat(nameof(Damage), _damage);
|
||||
RegisterPerformanceStat(nameof(Penetration), _penetration);
|
||||
RegisterPerformanceStat(nameof(DamageSpread), _damageSpread);
|
||||
RegisterPerformanceStat(nameof(MinRange), _minRange);
|
||||
RegisterPerformanceStat(nameof(Range), _range);
|
||||
RegisterPerformanceStat(nameof(Energy), _energy);
|
||||
RegisterPerformanceStat(nameof(Heat), _heat);
|
||||
RegisterPerformanceStat(nameof(Visibility), _visibility);
|
||||
RegisterPerformanceStat(nameof(Spread), _spread);
|
||||
RegisterPerformanceStat(nameof(Velocity), _velocity);
|
||||
}
|
||||
|
||||
private void InitializeGuidedProjectileProfile(RuntimeBehaviorDefinition definition)
|
||||
{
|
||||
if (string.Equals(definition.Kind, "Launcher"))
|
||||
{
|
||||
GuidedProjectileTargeting = GuidedProjectileTargetMode.TargetEntity;
|
||||
GuidedProjectileGuidanceCurve = launcher.GuidanceCurve;
|
||||
GuidedProjectileLiftCurve = launcher.LiftCurve;
|
||||
GuidedProjectileThrustCurve = launcher.ThrustCurve;
|
||||
GuidedProjectileDodgeFrequency = launcher.DodgeFrequency;
|
||||
_guidedProjectileThrust = launcher.Thrust;
|
||||
_guidedProjectileVelocity = launcher.MissileVelocity;
|
||||
GuidedProjectileGuidanceCurve = definition.Float4Array(26, null);
|
||||
GuidedProjectileThrustCurve = definition.Float4Array(27, null);
|
||||
GuidedProjectileLiftCurve = definition.Float4Array(28, null);
|
||||
_guidedProjectileThrust = definition.PerformanceStat(29, new PerformanceStat());
|
||||
GuidedProjectileDodgeFrequency = definition.Float(30);
|
||||
_guidedProjectileVelocity = definition.PerformanceStat(31, new PerformanceStat());
|
||||
}
|
||||
else if (data is GuidedWeaponConfig guidance)
|
||||
else if (string.Equals(definition.Kind, "GuidedWeapon"))
|
||||
{
|
||||
GuidedProjectileTargeting = GuidedProjectileTargetMode.LookDirection;
|
||||
GuidedProjectileGuidanceCurve = guidance.GuidanceCurve;
|
||||
GuidedProjectileLiftCurve = guidance.LiftCurve;
|
||||
GuidedProjectileThrustCurve = guidance.ThrustCurve;
|
||||
GuidedProjectileDodgeFrequency = guidance.DodgeFrequency;
|
||||
_guidedProjectileThrust = guidance.Thrust;
|
||||
_guidedProjectileVelocity = guidance.MissileVelocity;
|
||||
GuidedProjectileGuidanceCurve = definition.Float4Array(21, null);
|
||||
GuidedProjectileThrustCurve = definition.Float4Array(22, null);
|
||||
GuidedProjectileLiftCurve = definition.Float4Array(23, null);
|
||||
_guidedProjectileThrust = definition.PerformanceStat(24, new PerformanceStat());
|
||||
GuidedProjectileDodgeFrequency = definition.Float(25);
|
||||
_guidedProjectileVelocity = definition.PerformanceStat(26, new PerformanceStat());
|
||||
}
|
||||
|
||||
RegisterPerformanceStat("Thrust", _guidedProjectileThrust);
|
||||
RegisterPerformanceStat("MissileVelocity", _guidedProjectileVelocity);
|
||||
}
|
||||
|
||||
protected virtual void UpdateStats()
|
||||
|
|
|
|||
Loading…
Reference in a new issue