diff --git a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
index 79a806f0c..5b2a4268c 100644
--- a/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
+++ b/.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
@@ -1450,6 +1450,10 @@
+
+
+
+
@@ -1460,6 +1464,8 @@
+
+
diff --git a/Assets/Materials/UI/Map Gravity Lines.mat b/Assets/Materials/UI/Map Gravity Lines.mat
index efe66ec91..34a64cbf9 100644
--- a/Assets/Materials/UI/Map Gravity Lines.mat
+++ b/Assets/Materials/UI/Map Gravity Lines.mat
@@ -86,7 +86,7 @@ Material:
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- - _Scale: 5.181433
+ - _Scale: 2.7104213
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
diff --git a/Assets/Scenes/ARPG.unity b/Assets/Scenes/ARPG.unity
index 031eb043c..94f21ab9c 100644
--- a/Assets/Scenes/ARPG.unity
+++ b/Assets/Scenes/ARPG.unity
@@ -4567,6 +4567,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 78aa0b8ec7594a7438f13757228e3500, type: 3}
m_Name:
m_EditorClassIdentifier:
+ ConfirmationDialog: {fileID: 0}
Flip: 1
Settings: {fileID: 11400000, guid: cd2344e2001a37544aab0960c164d4ff, type: 2}
GameManager: {fileID: 1009503729}
@@ -28397,6 +28398,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 78aa0b8ec7594a7438f13757228e3500, type: 3}
m_Name:
m_EditorClassIdentifier:
+ ConfirmationDialog: {fileID: 0}
Flip: 0
Settings: {fileID: 11400000, guid: cd2344e2001a37544aab0960c164d4ff, type: 2}
GameManager: {fileID: 1009503729}
diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs
index b953f36c3..6bcf740fd 100644
--- a/Assets/Scripts/Gameplay/ActionGameManager.cs
+++ b/Assets/Scripts/Gameplay/ActionGameManager.cs
@@ -17,6 +17,7 @@ using UnityEngine.InputSystem;
using UnityEngine.UI;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
+using Random = UnityEngine.Random;
public class ActionGameManager : MonoBehaviour
{
@@ -48,20 +49,21 @@ public class ActionGameManager : MonoBehaviour
// private CinemachineComposer _composer;
private DirectoryInfo _filePath;
- private DirectoryInfo _presetPath;
+ private DirectoryInfo _loadoutPath;
private bool _editMode;
private float _time;
private AetheriaInput _input;
private int _zoomLevelIndex;
- public List Loadouts { get; set; } = new List();
// private ShipInput _shipInput;
+ private List _shipAgents = new List();
private IDisposable _shipTargetSubscription;
private float2 _shipYawPitch;
private float3 _viewDirection;
private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups;
private (LockWeapon targetLock, PlaceUIElementWorldspace indicator, Rotate spin)[] _lockingIndicators;
- public List PlayerShips { get; } = new List();
+
+ public List PlayerEntities { get; } = new List();
public EquippedDockingBay DockingBay { get; private set; }
public Entity DockedEntity { get; private set; }
@@ -69,6 +71,7 @@ public class ActionGameManager : MonoBehaviour
public DatabaseCache ItemData { get; private set; }
public ItemManager ItemManager { get; private set; }
public Zone Zone { get; private set; }
+ public List Loadouts { get; } = new List();
private readonly (float2 direction, string name)[] _directions = {
(float2(0, 1), "Front"),
@@ -79,7 +82,7 @@ public class ActionGameManager : MonoBehaviour
public void SaveLoadout(EntityPack pack)
{
- File.WriteAllBytes(Path.Combine(_presetPath.FullName, $"{pack.Name}.preset"), MessagePackSerializer.Serialize(pack));
+ File.WriteAllBytes(Path.Combine(_loadoutPath.FullName, $"{pack.Name}.preset"), MessagePackSerializer.Serialize(pack));
}
void Start()
@@ -90,12 +93,12 @@ public class ActionGameManager : MonoBehaviour
ConsoleController.MessageReceiver = this;
_filePath = new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData");
- _presetPath = _filePath.CreateSubdirectory("Presets");
+ _loadoutPath = _filePath.CreateSubdirectory("Loadouts");
ItemData = new DatabaseCache();
ItemData.Load(_filePath.FullName);
ItemManager = new ItemManager(ItemData, Settings.GameplaySettings, Debug.Log);
- Loadouts.AddRange(_presetPath.EnumerateFiles("*.preset")
+ Loadouts.AddRange(_loadoutPath.EnumerateFiles("*.preset")
.Select(fi => MessagePackSerializer.Deserialize(File.ReadAllBytes(fi.FullName))));
var zoneFile = Path.Combine(_filePath.FullName, "Home.zone");
@@ -112,6 +115,7 @@ public class ActionGameManager : MonoBehaviour
);
Zone = new Zone(Settings.PlanetSettings, zonePack);
+ Zone.Log = s => Debug.Log($"Zone: {s}");
SectorRenderer.ItemManager = ItemManager;
SectorRenderer.LoadZone(Zone);
@@ -353,38 +357,34 @@ public class ActionGameManager : MonoBehaviour
var dockingBay = ItemManager.CreateInstance(dockingBayData, 1, 1) as EquippableItem;
station.TryEquip(dockingBay);
station.Active = true;
-
- var reactorData = ItemData.GetAll().First(x => x.HardpointType == HardpointType.Reactor && x.Shape.Height == 2);
- var radiatorData = ItemData.GetAll().First(x => x.Name == "Long Radiator");
- var autocannonData = ItemData.GetAll().First(x => x.Name == "Autocannon");
- var ammoData = ItemData.GetAll().First(x => x.Name == "Autocannon Ammo");
- var turretType = ItemData.GetAll().First(x=>x.HullType==HullType.Turret);
- var controlModuleData = ItemData.GetAll().First(x => x.Name == "Murder Module");
- var cargo1Data = ItemData.GetAll().First(x => x.Name == "Cargo Bay 1x1");
+ var turretLoadout = Loadouts.First(x => x.Name == "Turret");
- for(int i=0; i<5; i++)
+ for(int i=0; i<3; i++)
{
- var turretParent = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(5+i);
- var turretParentOrbit = turretParent.Orbit.Data.ID;
- var turretParentPos = Zone.GetOrbitPosition(turretParentOrbit);
- var turretPos = turretParentPos + ItemManager.Random.NextFloat2Direction() * turretParent.GravityWellRadius.Value * .25f;
- var turretOrbit = Zone.CreateOrbit(turretParentOrbit, turretPos);
- var turret = new OrbitalEntity(ItemManager, Zone, ItemManager.CreateInstance(turretType, 0, 1) as EquippableItem, turretOrbit.ID);
- turret.TryEquip(ItemManager.CreateInstance(reactorData, .5f, 1) as EquippableItem);
- turret.TryEquip(ItemManager.CreateInstance(radiatorData, .5f, 1) as EquippableItem);
- turret.TryEquip(ItemManager.CreateInstance(radiatorData, .5f, 1) as EquippableItem);
- turret.TryEquip(ItemManager.CreateInstance(controlModuleData, .5f, 1) as EquippableItem);
- turret.TryEquip(ItemManager.CreateInstance(autocannonData, .5f, 1) as EquippableItem);
- turret.TryEquip(ItemManager.CreateInstance(autocannonData, .5f, 1) as EquippableItem);
- turret.TryEquip(ItemManager.CreateInstance(cargo1Data, .5f, 1) as EquippableItem);
- turret.CargoBays.First().TryStore(ItemManager.CreateInstance(ammoData, 400));
- foreach (var v in turretType.Shape.Coordinates)
- turret.HullConductivity[v.x, v.y] = bool2(true);
- turret.Active = true;
- Zone.Entities.Add(turret);
+ var planet = Zone.PlanetInstances.Values.OrderByDescending(p => p.BodyData.Mass.Value).ElementAt(4+i);
+ var planetOrbit = planet.Orbit.Data.ID;
+ var planetPos = Zone.GetOrbitPosition(planetOrbit);
+ for (int j = 0; j < 2; j++)
+ {
+ var pos = planetPos + ItemManager.Random.NextFloat2Direction() * planet.GravityWellRadius.Value * (.1f + .1f * j);
+ var orbit = Zone.CreateOrbit(planetOrbit, pos);
+ var turret = EntityPack.Unpack(ItemManager, Zone, turretLoadout, orbit.ID, true);
+ turret.Active = true;
+ Zone.Entities.Add(turret);
+ }
}
+ var enemyShipLoadout = Loadouts.First(x => ((HullData) ItemManager.GetData(x.Hull)).HullType == HullType.Ship);
+ var enemyShip = EntityPack.Unpack(ItemManager, Zone, enemyShipLoadout, true);
+ enemyShip.Active = true;
+ Zone.Entities.Add(enemyShip);
+ var agent = new Agent(enemyShip);
+ var task = new PatrolOrbitsTask();
+ task.Circuit = Zone.Orbits.OrderBy(_ => Random.value).Take(4).Select(x => x.Key).ToArray();
+ agent.Task = task;
+ _shipAgents.Add(agent);
+
DockedEntity = station;
DockingBay = station.DockingBays.First();
DockCamera.enabled = true;
@@ -544,25 +544,20 @@ public class ActionGameManager : MonoBehaviour
{
foreach (var bay in CurrentShip.Parent.DockingBays)
{
- if (PlayerShips.Contains(bay.DockedShip)) yield return bay;
+ if (PlayerEntities.Contains(bay.DockedShip)) yield return bay;
}
}
}
- public IEnumerable AvailableShips()
+ public IEnumerable AvailableEntities()
{
- if (CurrentShip != null)
- {
- if (CurrentShip.Parent != null)
+ if(DockedEntity != null)
+ foreach (var entity in PlayerEntities)
{
- foreach (var ship in PlayerShips)
- {
- if (CurrentShip.Parent.Children.Contains(ship)) yield return ship;
- }
+ if (DockedEntity.Children.Contains(entity)) yield return entity;
}
- else
- yield return CurrentShip;
- }
+ else if (CurrentShip != null)
+ yield return CurrentShip;
}
void Update()
@@ -580,6 +575,8 @@ public class ActionGameManager : MonoBehaviour
CurrentShip.MovementDirection = _input.Player.Move.ReadValue();
}
}
+ foreach(var agent in _shipAgents)
+ agent.Update(Time.deltaTime);
Zone.Update(_time, Time.deltaTime);
SectorRenderer.Time = _time;
}
diff --git a/Assets/Scripts/ServerShared/AetheriaMath.cs b/Assets/Scripts/ServerShared/AetheriaMath.cs
index b4bd10db0..cf4ef5071 100644
--- a/Assets/Scripts/ServerShared/AetheriaMath.cs
+++ b/Assets/Scripts/ServerShared/AetheriaMath.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using Unity.Mathematics;
using static Unity.Mathematics.math;
-public class AetheriaMath
+public static class AetheriaMath
{
//first-order intercept using absolute target position
public static float3 FirstOrderIntercept
diff --git a/Assets/Scripts/ServerShared/Agents/AgentBehavior.cs b/Assets/Scripts/ServerShared/Agents/AgentBehavior.cs
index c278a3de2..e1bac9549 100644
--- a/Assets/Scripts/ServerShared/Agents/AgentBehavior.cs
+++ b/Assets/Scripts/ServerShared/Agents/AgentBehavior.cs
@@ -2,10 +2,15 @@
* 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.Collections;
using System.Collections.Generic;
+using System.Linq;
+using RethinkDb.Driver.Ast;
+using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
+using float2 = Unity.Mathematics.float2;
public abstract class AgentBehavior
{
@@ -32,3 +37,167 @@ public abstract class AgentBehavior
ControllerData = controllerData;
}
}
+
+public class Agent
+{
+ private BaseState _rootState;
+ private BaseState _currentState;
+ private Dictionary> _stateTransitions = new Dictionary>();
+
+ public AgentTask Task { get; set; }
+ public Ship Ship { get; }
+ public ItemManager ItemManager { get; }
+ public GameplaySettings Settings { get; }
+
+ public Agent(Ship ship)
+ {
+ Ship = ship;
+ ItemManager = Ship.ItemManager;
+ Settings = Ship.ItemManager.GameplaySettings;
+
+ _rootState = _currentState = new BaseState(this);
+
+ var patrolState = new PatrolOrbitsState(this);
+ AddTransition(_rootState, patrolState,
+ () => Task is PatrolOrbitsTask,
+ () => patrolState.Task = Task as PatrolOrbitsTask);
+ var patrolMoveState = new MoveToOrbitState(this);
+ AddTransition(patrolState, patrolMoveState,
+ () => true,
+ () => patrolMoveState.Orbit = patrolState.CurrentTarget);
+ AddTransition(patrolMoveState, patrolState,
+ () => patrolMoveState.Distance < 10,
+ () => patrolState.NextTarget());
+ }
+
+ public void AddTransition(BaseState source, BaseState targetState, Func condition, Action onTransition = null)
+ {
+ if(!_stateTransitions.ContainsKey(source))
+ _stateTransitions[source] = new List();
+ _stateTransitions[source].Add(new StateTransition(targetState, condition, onTransition));
+ }
+
+ public void Transition(BaseState targetState, Action onTransition = null)
+ {
+ _currentState.OnExitState();
+ _currentState = targetState;
+ onTransition?.Invoke();
+ _currentState.OnEnterState();
+ }
+
+ public void Update(float delta)
+ {
+ _currentState.Update(delta);
+ foreach (var transition in _stateTransitions[_currentState])
+ if (transition.Condition())
+ {
+ Transition(transition.TargetState, transition.OnTransition);
+ break;
+ }
+ }
+
+ public class StateTransition
+ {
+ public StateTransition(BaseState targetState, Func condition, Action onTransition)
+ {
+ TargetState = targetState;
+ Condition = condition;
+ OnTransition = onTransition;
+ }
+
+ public BaseState TargetState { get; }
+ public Func Condition { get; }
+ public Action OnTransition { get; }
+ }
+}
+
+public class BaseState
+{
+ protected Agent _agent;
+
+ public BaseState(Agent agent)
+ {
+ _agent = agent;
+ }
+ public virtual void Update(float delta){}
+ public virtual void OnEnterState(){}
+ public virtual void OnExitState(){}
+}
+
+public abstract class MoveToState : BaseState
+{
+ private const float FORWARD_DELTA_THRESHOLD = 20;
+ private const float THRUST_DELTA_THRESHOLD = 1;
+ private VelocityLimit _velocityLimit;
+ protected abstract float2 TargetPosition { get; }
+ public float Distance { get; private set; }
+
+ protected MoveToState(Agent agent) : base(agent)
+ {
+ _velocityLimit = agent.Ship.GetBehavior();
+ }
+
+ public override void Update(float delta)
+ {
+ var diff = TargetPosition - _agent.Ship.Position.xz;
+ var dir = normalize(diff);
+ Distance = length(diff);
+
+ // We want to go top speed in the direction of our target
+ var topSpeed = _velocityLimit?.Limit ?? 100;
+ var desiredVelocity = dir * topSpeed;
+ var deltaV = desiredVelocity - _agent.Ship.Velocity;
+ var deltaVMag = length(deltaV);
+ var deltaVDirection = normalize(deltaV);
+ // If Delta V is above the threshold, direct the ship towards the delta and use only main thrusters
+ if (deltaVMag > FORWARD_DELTA_THRESHOLD)
+ {
+ _agent.Ship.LookDirection = float3(deltaVDirection.x, 0, deltaVDirection.y);
+ _agent.Ship.MovementDirection = float2(0, pow(dot(_agent.Ship.Direction, deltaVDirection), 2));
+ }
+ // If Delta V is low, direct the ship towards the target and use all thrusters
+ else if(deltaVMag > THRUST_DELTA_THRESHOLD)
+ {
+ var right = _agent.Ship.Direction.Rotate(ItemRotation.Clockwise);
+ _agent.Ship.LookDirection = float3(dir.x, 0, dir.y);
+ _agent.Ship.MovementDirection = float2(dot(right, deltaVDirection), dot(_agent.Ship.Direction, deltaVDirection));
+ }
+ else
+ {
+ _agent.Ship.LookDirection = float3(dir.x, 0, dir.y);
+ _agent.Ship.MovementDirection = float2.zero;
+ }
+ }
+}
+
+public class MoveToEntityState : MoveToState
+{
+ public Entity TargetEntity { get; set; }
+ protected override float2 TargetPosition => TargetEntity?.Position.xz ?? float2.zero;
+
+ public MoveToEntityState(Agent agent) : base(agent) { }
+}
+
+public class MoveToOrbitState : MoveToState
+{
+ public Guid Orbit { get; set; }
+ public MoveToOrbitState(Agent agent) : base(agent) { }
+
+ protected override float2 TargetPosition => _agent.Ship.Zone.GetOrbitPosition(Orbit);
+}
+
+public class PatrolOrbitsState : BaseState
+{
+ public PatrolOrbitsTask Task;
+ public Guid CurrentTarget
+ {
+ get => Task.Circuit[_currentTargetIndex];
+ }
+ private int _currentTargetIndex;
+ public void NextTarget()
+ {
+ _currentTargetIndex++;
+ _currentTargetIndex %= Task.Circuit.Length;
+ }
+ public PatrolOrbitsState(Agent agent) : base(agent) { }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/ServerShared/Agents/AgentTask.cs b/Assets/Scripts/ServerShared/Agents/AgentTask.cs
index 7ce487ce3..d8bc72a94 100644
--- a/Assets/Scripts/ServerShared/Agents/AgentTask.cs
+++ b/Assets/Scripts/ServerShared/Agents/AgentTask.cs
@@ -39,3 +39,9 @@ public enum TaskType
Attack,
Explore
}
+
+public class PatrolOrbitsTask : AgentTask
+{
+ public override TaskType Type => TaskType.Defend;
+ public Guid[] Circuit;
+}
diff --git a/Assets/Scripts/ServerShared/Agents/Locomotion.cs b/Assets/Scripts/ServerShared/Agents/Locomotion.cs
index 7387a0299..17dbf0a64 100644
--- a/Assets/Scripts/ServerShared/Agents/Locomotion.cs
+++ b/Assets/Scripts/ServerShared/Agents/Locomotion.cs
@@ -32,7 +32,7 @@ public class Locomotion : AgentBehavior
var diff = Objective - Entity.Position.xz;
// We want to go top speed in the direction of our target
- var topSpeed = _velocityLimit?.Limit ?? 1000;
+ var topSpeed = _velocityLimit?.Limit ?? 100;
float2 desiredVelocity = normalize(diff) * topSpeed;
var accelerationTime = length(desiredVelocity - Entity.Velocity) / (_thrust / Entity.Mass);
diff --git a/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs
index 9e5afee63..f755d6bc5 100644
--- a/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs
@@ -9,40 +9,40 @@ using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ChargedWeaponData : InstantWeaponData
{
- [InspectableField, JsonProperty("chargeTime"), Key(19), RuntimeInspectable]
+ [InspectableField, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
public PerformanceStat ChargeTime = new PerformanceStat();
- [InspectableField, JsonProperty("chargeEnergy"), Key(20), RuntimeInspectable]
+ [InspectableField, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
public PerformanceStat ChargeEnergy = new PerformanceStat();
- [InspectableField, JsonProperty("chargeHeat"), Key(21), RuntimeInspectable]
+ [InspectableField, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
public PerformanceStat ChargeHeat = new PerformanceStat();
- [InspectableField, JsonProperty("canFireEarly"), Key(22)]
+ [InspectableField, JsonProperty("canFireEarly"), Key(24)]
public bool CanFireEarly;
- [InspectableField, JsonProperty("failureCharge"), Key(23)]
+ [InspectableField, JsonProperty("failureCharge"), Key(25)]
public float FailureCharge;
- [InspectableField, JsonProperty("failureDamage"), Key(24)]
+ [InspectableField, JsonProperty("failureDamage"), Key(26)]
public float FailureDamage = 1;
- [InspectableField, JsonProperty("chargeDamage"), Key(25)]
+ [InspectableField, JsonProperty("chargeDamage"), Key(27)]
public float ChargeFiringDamageMultiplier = 1;
- [InspectableField, JsonProperty("chargeSpread"), Key(26)]
+ [InspectableField, JsonProperty("chargeSpread"), Key(28)]
public float ChargeFiringSpreadMultiplier = 1;
- [InspectableField, JsonProperty("chargeBurstCount"), Key(27)]
+ [InspectableField, JsonProperty("chargeBurstCount"), Key(29)]
public float ChargeFiringBurstCountMultiplier = 1;
- [InspectableField, JsonProperty("chargeVisibility"), Key(28)]
+ [InspectableField, JsonProperty("chargeVisibility"), Key(30)]
public float ChargeFiringVisibilityMultiplier = 1;
- [InspectableField, JsonProperty("chargeVelocity"), Key(29)]
+ [InspectableField, JsonProperty("chargeVelocity"), Key(31)]
public float ChargeFiringVelocityMultiplier = 1;
- [InspectableField, JsonProperty("chargeHeatMul"), Key(30)]
+ [InspectableField, JsonProperty("chargeHeatMul"), Key(32)]
public float ChargeFiringHeatMultiplier = 1;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
@@ -131,7 +131,7 @@ public class ChargedWeapon : InstantWeapon
public override void Activate()
{
- if(!_coolingDown)
+ if(!_charging && !_coolingDown)
{
OnStartCharging?.Invoke();
_charging = true;
diff --git a/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs
index c7e8f3325..5ce26c0c2 100644
--- a/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs
@@ -11,7 +11,7 @@ using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ConstantWeaponData : WeaponData
{
- [InspectablePrefab, JsonProperty("ammoInterval"), Key(15)]
+ [InspectablePrefab, JsonProperty("ammoInterval"), Key(17)]
public float AmmoInterval = 1;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
@@ -112,7 +112,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior
public override void Activate()
{
- if(!_reloading)
+ if(!_firing && !_reloading)
{
_firing = true;
OnStartFiring?.Invoke();
diff --git a/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs
index 1660e241b..079aa9dff 100644
--- a/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs
@@ -9,16 +9,16 @@ using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class InstantWeaponData : WeaponData
{
- [InspectableField, JsonProperty("count"), Key(15)]
+ [InspectableField, JsonProperty("count"), Key(17)]
public PerformanceStat Count = new PerformanceStat();
- [InspectableField, JsonProperty("burstTime"), Key(16)]
+ [InspectableField, JsonProperty("burstTime"), Key(18)]
public PerformanceStat BurstTime = new PerformanceStat();
- [InspectableField, JsonProperty("cooldown"), Key(17), RuntimeInspectable]
+ [InspectableField, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
- [InspectablePrefab, JsonProperty("ammoInterval"), Key(18)]
+ [InspectablePrefab, JsonProperty("ammoInterval"), Key(20)]
public bool SingleAmmoBurst;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
diff --git a/Assets/Scripts/ServerShared/Behaviors/Launcher.cs b/Assets/Scripts/ServerShared/Behaviors/Launcher.cs
index 6b67b03de..17cb72e19 100644
--- a/Assets/Scripts/ServerShared/Behaviors/Launcher.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/Launcher.cs
@@ -9,22 +9,22 @@ using Unity.Mathematics;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class LauncherData : LockWeaponData
{
- [InspectableAnimationCurve, JsonProperty("guidance"), Key(24)]
+ [InspectableAnimationCurve, JsonProperty("guidance"), Key(26)]
public float4[] GuidanceCurve;
- [InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(25)]
+ [InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(27)]
public float4[] ThrustCurve;
- [InspectableAnimationCurve, JsonProperty("liftCurve"), Key(26)]
+ [InspectableAnimationCurve, JsonProperty("liftCurve"), Key(28)]
public float4[] LiftCurve;
- [InspectableField, JsonProperty("thrust"), Key(27)]
+ [InspectableField, JsonProperty("thrust"), Key(29)]
public PerformanceStat Thrust = new PerformanceStat();
- [InspectableField, JsonProperty("frequency"), Key(28)]
+ [InspectableField, JsonProperty("frequency"), Key(30)]
public float DodgeFrequency;
- [InspectableField, JsonProperty("missileSpeed"), Key(29), RuntimeInspectable]
+ [InspectableField, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
@@ -36,22 +36,22 @@ public class LauncherData : LockWeaponData
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class GuidedWeaponData : InstantWeaponData
{
- [InspectableAnimationCurve, JsonProperty("guidance"), Key(24)]
+ [InspectableAnimationCurve, JsonProperty("guidance"), Key(21)]
public float4[] GuidanceCurve;
- [InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(25)]
+ [InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(22)]
public float4[] ThrustCurve;
- [InspectableAnimationCurve, JsonProperty("liftCurve"), Key(26)]
+ [InspectableAnimationCurve, JsonProperty("liftCurve"), Key(23)]
public float4[] LiftCurve;
- [InspectableField, JsonProperty("thrust"), Key(27)]
+ [InspectableField, JsonProperty("thrust"), Key(24)]
public PerformanceStat Thrust = new PerformanceStat();
- [InspectableField, JsonProperty("frequency"), Key(28)]
+ [InspectableField, JsonProperty("frequency"), Key(25)]
public float DodgeFrequency;
- [InspectableField, JsonProperty("missileSpeed"), Key(29), RuntimeInspectable]
+ [InspectableField, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
diff --git a/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs
index 46e07f7b1..ee9a864af 100644
--- a/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs
@@ -9,19 +9,19 @@ using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class LockWeaponData : InstantWeaponData
{
- [InspectableField, JsonProperty("speed"), Key(19), RuntimeInspectable]
+ [InspectableField, JsonProperty("speed"), Key(21), RuntimeInspectable]
public PerformanceStat LockSpeed = new PerformanceStat();
- [InspectableField, JsonProperty("sensorImpact"), Key(20)]
+ [InspectableField, JsonProperty("sensorImpact"), Key(22)]
public PerformanceStat SensorImpact = new PerformanceStat();
- [InspectableField, JsonProperty("threshold"), Key(21), RuntimeInspectable]
+ [InspectableField, JsonProperty("threshold"), Key(23), RuntimeInspectable]
public PerformanceStat LockAngle = new PerformanceStat();
- [InspectableField, JsonProperty("directionImpact"), Key(22)]
+ [InspectableField, JsonProperty("directionImpact"), Key(24)]
public PerformanceStat DirectionImpact = new PerformanceStat();
- [InspectableField, JsonProperty("decay"), Key(23)]
+ [InspectableField, JsonProperty("decay"), Key(25)]
public PerformanceStat Decay = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
diff --git a/Assets/Scripts/ServerShared/Behaviors/Sensor.cs b/Assets/Scripts/ServerShared/Behaviors/Sensor.cs
index 348d91f39..d4462594a 100644
--- a/Assets/Scripts/ServerShared/Behaviors/Sensor.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/Sensor.cs
@@ -4,12 +4,17 @@
using MessagePack;
using Newtonsoft.Json;
+using Unity.Mathematics;
+using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class SensorData : BehaviorData
{
[InspectableField, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
public PerformanceStat Sensitivity = new PerformanceStat();
+
+ [InspectableField, JsonProperty("sensitivityCurve"), Key(4), RuntimeInspectable]
+ public float4[] SensitivityCurve;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
{
@@ -38,6 +43,21 @@ public class Sensor : IBehavior
public bool Execute(float delta)
{
// TODO: Handle Active Detection / Visibility From Reflected Radiance
+ var hardpoint = Entity.Hardpoints[Item.Position.x, Item.Position.y];
+ var forward = Entity.HardpointTransforms.ContainsKey(hardpoint) ?
+ normalize(Entity.HardpointTransforms[hardpoint].direction.xz) :
+ Entity.Direction;
+ foreach (var entity in Entity.Zone.Entities)
+ {
+ var diff = entity.Position.xz - Entity.Position.xz;
+ var angle = acos(dot(forward, normalize(diff)));
+ var dist = length(diff);
+ Entity.EntityInfoGathered[entity] +=
+ entity.Visibility *
+ Context.Evaluate(_data.Sensitivity, Item.EquippableItem, Entity) *
+ _data.SensitivityCurve.Evaluate(angle / PI) *
+ delta / dist;
+ }
return true;
// var ship = Hardpoint.Ship.Ship.transform;
// var contacts =
diff --git a/Assets/Scripts/ServerShared/Behaviors/Weapon.cs b/Assets/Scripts/ServerShared/Behaviors/Weapon.cs
index 9a1bd8177..b6c699eeb 100644
--- a/Assets/Scripts/ServerShared/Behaviors/Weapon.cs
+++ b/Assets/Scripts/ServerShared/Behaviors/Weapon.cs
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
+using Unity.Mathematics;
[Union(0, typeof(InstantWeaponData)),
Union(1, typeof(LauncherData)),
@@ -27,34 +28,40 @@ public abstract class WeaponData : BehaviorData
[RangedFloatInspectable(0,1), JsonProperty("damageSpread"), Key(4)]
public PerformanceStat DamageSpread = new PerformanceStat();
- [InspectableField, JsonProperty("range"), Key(5), RuntimeInspectable]
+ [InspectableField, JsonProperty("minRange"), Key(5), RuntimeInspectable]
+ public PerformanceStat MinRange = new PerformanceStat();
+
+ [InspectableField, JsonProperty("range"), Key(6), RuntimeInspectable]
public PerformanceStat Range = new PerformanceStat();
+
+ [InspectableAnimationCurve, JsonProperty("damageRange"), Key(7), RuntimeInspectable]
+ public float4[] DamageCurve;
- [InspectablePrefab, JsonProperty("effect"), Key(6)]
+ [InspectablePrefab, JsonProperty("effect"), Key(8)]
public string EffectPrefab;
- [InspectablePrefab, JsonProperty("energy"), Key(7), RuntimeInspectable]
+ [InspectablePrefab, JsonProperty("energy"), Key(9), RuntimeInspectable]
public PerformanceStat Energy = new PerformanceStat();
- [InspectablePrefab, JsonProperty("heat"), Key(8), RuntimeInspectable]
+ [InspectablePrefab, JsonProperty("heat"), Key(10), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
- [InspectablePrefab, JsonProperty("visibility"), Key(9), RuntimeInspectable]
+ [InspectablePrefab, JsonProperty("visibility"), Key(11), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
- [InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("ammo"), Key(10), RuntimeInspectable]
+ [InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("ammo"), Key(12), RuntimeInspectable]
public Guid AmmoType;
- [InspectablePrefab, JsonProperty("magSize"), Key(11)]
+ [InspectablePrefab, JsonProperty("magSize"), Key(13)]
public int MagazineSize;
- [InspectablePrefab, JsonProperty("reloadTime"), Key(12)]
+ [InspectablePrefab, JsonProperty("reloadTime"), Key(14)]
public float ReloadTime = 1;
- [InspectablePrefab, JsonProperty("spread"), Key(13)]
+ [InspectablePrefab, JsonProperty("spread"), Key(15)]
public PerformanceStat Spread = new PerformanceStat();
- [InspectableField, JsonProperty("velocity"), Key(14)]
+ [InspectableField, JsonProperty("velocity"), Key(16)]
public PerformanceStat Velocity = new PerformanceStat();
}
@@ -73,6 +80,7 @@ public abstract class Weapon : IActivatedBehavior
public float Damage { get; protected set; }
public float Penetration { get; protected set; }
public float DamageSpread { get; protected set; }
+ public float MinRange { get; protected set; }
public float Range { get; protected set; }
public float Energy { get; protected set; }
public float Heat { get; protected set; }
@@ -103,6 +111,7 @@ public abstract class Weapon : IActivatedBehavior
Damage = Context.Evaluate(_data.Damage, Item.EquippableItem, Entity);
Penetration = Context.Evaluate(_data.Penetration, Item.EquippableItem, Entity);
DamageSpread = Context.Evaluate(_data.DamageSpread, Item.EquippableItem, Entity);
+ MinRange = Context.Evaluate(_data.MinRange, Item.EquippableItem, Entity);
Range = Context.Evaluate(_data.Range, Item.EquippableItem, Entity);
Energy = Context.Evaluate(_data.Energy, Item.EquippableItem, Entity);
Heat = Context.Evaluate(_data.Heat, Item.EquippableItem, Entity);
diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs
index 2b95cae11..0d767278d 100644
--- a/Assets/Scripts/ServerShared/Corporations.cs
+++ b/Assets/Scripts/ServerShared/Corporations.cs
@@ -48,18 +48,9 @@ public class MegaCorporation : DatabaseEntry, INamedEntry
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(4)]
public Dictionary Personality = new Dictionary();
-
- [InspectableDatabaseLink(typeof(LoadoutData)), JsonProperty("initialFleet"), Key(5)]
- public Dictionary InitialFleet = new Dictionary();
-
- [InspectableDatabaseLink(typeof(BlueprintData)), JsonProperty("initialTechs"), Key(6)]
- public List InitialTechnologies = new List();
- [JsonProperty("parent"), Key(7)]
- public Guid HomeZone;
-
- [InspectableField, JsonProperty("placement"), Key(8)]
- public MegaPlacementType PlacementType;
+ [InspectableField, JsonProperty("hostile"), Key(5)]
+ public bool PlayerHostile;
[IgnoreMember] public string EntryName
{
diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs
index 98bd34563..31175b19f 100644
--- a/Assets/Scripts/ServerShared/Entity.cs
+++ b/Assets/Scripts/ServerShared/Entity.cs
@@ -21,6 +21,7 @@ using int2 = Unity.Mathematics.int2;
public abstract class Entity
{
public Zone Zone;
+ public MegaCorporation Faction;
public EquippableItem Hull;
public float3 Position;
@@ -50,6 +51,7 @@ public abstract class Entity
public readonly Dictionary Messages = new Dictionary();
public readonly Dictionary