Local AI Testing & Interactive Tech Tab
Refactored game loop to allow full local testing Added AI controller abstractions Added ability to save database to local copy for offline testing Tech Tab is now interactive, has properties panel
This commit is contained in:
parent
43d5ebdd35
commit
af88788e4f
50 changed files with 5799 additions and 712 deletions
8
Assets/Scripts/ServerShared/Agents.meta
Normal file
8
Assets/Scripts/ServerShared/Agents.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 623ef3419b4e3a74c8f0350f7d9070f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
7
Assets/Scripts/ServerShared/Agents/AgentBehavior.cs
Normal file
7
Assets/Scripts/ServerShared/Agents/AgentBehavior.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public abstract class AgentBehavior
|
||||
{
|
||||
public abstract void Update(float delta);
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Agents/AgentBehavior.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/AgentBehavior.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 87f587a591f7ba14f96f34108ca4e611
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
43
Assets/Scripts/ServerShared/Agents/AgentController.cs
Normal file
43
Assets/Scripts/ServerShared/Agents/AgentController.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
|
||||
public class AgentController
|
||||
{
|
||||
public Entity Entity { get; }
|
||||
public EntityAgent EntityAgent { get; }
|
||||
public GameContext Context { get; }
|
||||
public ZoneData Zone { get; set; }
|
||||
|
||||
private Locomotion _locomotion;
|
||||
private Random _random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue));
|
||||
|
||||
public AgentController(GameContext context, ZoneData zone, Entity entity)
|
||||
{
|
||||
Entity = entity;
|
||||
Zone = zone;
|
||||
Context = context;
|
||||
EntityAgent = new EntityAgent(context, zone, entity);
|
||||
_locomotion = new Locomotion(entity);
|
||||
EntityAgent.CurrentBehavior = _locomotion;
|
||||
RandomTarget();
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
EntityAgent.Update(delta);
|
||||
var distance = length(_locomotion.Objective.Position - Entity.Position);
|
||||
Context.Log($"Agent Distance: {distance}");
|
||||
if(distance < 20)
|
||||
RandomTarget();
|
||||
}
|
||||
|
||||
private void RandomTarget()
|
||||
{
|
||||
var entities = Context.ZoneEntities(Zone).ToArray();
|
||||
_locomotion.Objective = entities[_random.NextInt(entities.Length)];
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Agents/AgentController.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/AgentController.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ee1e3350676acb044bd87c1d76c535a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Assets/Scripts/ServerShared/Agents/EntityAgent.cs
Normal file
23
Assets/Scripts/ServerShared/Agents/EntityAgent.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class EntityAgent
|
||||
{
|
||||
public AgentBehavior CurrentBehavior;
|
||||
|
||||
public Entity Entity { get; }
|
||||
public GameContext Context { get; }
|
||||
public ZoneData Zone { get; set; }
|
||||
|
||||
public EntityAgent(GameContext context, ZoneData zone, Entity entity)
|
||||
{
|
||||
Entity = entity;
|
||||
Zone = zone;
|
||||
Context = context;
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
CurrentBehavior.Update(delta);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Agents/EntityAgent.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Agents/EntityAgent.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fdefbc1e15541d8448061e9d97e44648
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Assets/Scripts/ServerShared/Agents/Locomotion.cs
Normal file
37
Assets/Scripts/ServerShared/Agents/Locomotion.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class Locomotion : AgentBehavior
|
||||
{
|
||||
public Entity Objective;
|
||||
private Entity _entity;
|
||||
private IAnalogBehavior _thrust;
|
||||
private IAnalogBehavior _turning;
|
||||
private const float Sensitivity = 1;
|
||||
|
||||
public Locomotion(Entity entity)
|
||||
{
|
||||
_entity = entity;
|
||||
_thrust = entity.Axes.Keys.FirstOrDefault(x => x is Thruster);
|
||||
_turning = entity.Axes.Keys.FirstOrDefault(x => x is Turning);
|
||||
}
|
||||
|
||||
public override void Update(float delta)
|
||||
{
|
||||
if (Objective != null && _thrust != null && _turning != null)
|
||||
{
|
||||
float2 diff = Objective.Position - _entity.Position;
|
||||
var directionAngle = atan2(diff.y, diff.x) / PI;
|
||||
var currentAngle = atan2(_entity.Direction.y, _entity.Direction.x) / PI;
|
||||
var d1 = directionAngle - currentAngle;
|
||||
var d2 = directionAngle - 2 - currentAngle;
|
||||
var d3 = directionAngle + 2 - currentAngle;
|
||||
var angleDiff = abs(d1) < abs(d2) ? abs(d1) < abs(d3) ? d1 : d3 : abs(d2) < abs(d3) ? d2 : d3;
|
||||
_entity.Axes[_turning] = clamp(-angleDiff * Sensitivity, -1, 1);
|
||||
_entity.Axes[_thrust] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,13 +9,10 @@ public class ThrusterData : IBehaviorData
|
|||
[InspectableField, JsonProperty("thrust"), Key(0)]
|
||||
public PerformanceStat Thrust = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("torque"), Key(1)]
|
||||
public PerformanceStat Torque = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("visibility"), Key(2)]
|
||||
[InspectableField, JsonProperty("visibility"), Key(1)]
|
||||
public PerformanceStat Visibility = new PerformanceStat();
|
||||
|
||||
[InspectableField, JsonProperty("heat"), Key(3)]
|
||||
[InspectableField, JsonProperty("heat"), Key(2)]
|
||||
public PerformanceStat Heat = new PerformanceStat();
|
||||
|
||||
public IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
|
|
@ -55,7 +52,7 @@ public class Thruster : IAnalogBehavior
|
|||
|
||||
public void Update(float delta)
|
||||
{
|
||||
((Ship) Entity).Velocity += _thrust * Context.Evaluate(_data.Thrust, Item, Entity) * delta;
|
||||
Entity.Velocity += Entity.Direction * _thrust * Context.Evaluate(_data.Thrust, Item, Entity) / Entity.Mass * delta;
|
||||
Entity.AddHeat(_thrust * Context.Evaluate(_data.Heat, Item, Entity) * delta);
|
||||
Entity.VisibilitySources[this] = _thrust * Context.Evaluate(_data.Visibility, Item, Entity);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,15 +11,12 @@ public class DatabaseCache
|
|||
public event Action<DatabaseEntry> OnDataUpdateLocal;
|
||||
public event Action<DatabaseEntry> OnDataDeleteLocal;
|
||||
public event Action<DatabaseEntry> OnDataUpdateRemote;
|
||||
|
||||
|
||||
public Action<string> Logger = Console.WriteLine;
|
||||
|
||||
private readonly Dictionary<Guid, DatabaseEntry> _entries = new Dictionary<Guid, DatabaseEntry>();
|
||||
|
||||
private readonly Dictionary<Type, Dictionary<Guid, DatabaseEntry>> _types = new Dictionary<Type, Dictionary<Guid, DatabaseEntry>>();
|
||||
|
||||
private DirectoryInfo _dir;
|
||||
|
||||
public IEnumerable<DatabaseEntry> AllEntries => _entries.Values;
|
||||
|
||||
|
|
@ -90,4 +87,19 @@ public class DatabaseCache
|
|||
if (!remote)
|
||||
OnDataDeleteLocal?.Invoke(entry);
|
||||
}
|
||||
|
||||
public void Load(string path)
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
var bytes = File.ReadAllBytes(Path.Combine(path, "AetherDB.msgpack"));
|
||||
var entries = MessagePackSerializer.Deserialize<DatabaseEntry[]>(bytes);
|
||||
AddAll(entries);
|
||||
}
|
||||
|
||||
public void Save(string path)
|
||||
{
|
||||
RegisterResolver.Register();
|
||||
var entries = AllEntries.ToArray();
|
||||
File.WriteAllBytes(Path.Combine(path, "AetherDB.msgpack"), MessagePackSerializer.Serialize(entries));
|
||||
}
|
||||
}
|
||||
|
|
@ -22,17 +22,20 @@ public interface INamedEntry
|
|||
Union(1, typeof(CompoundCommodityData)),
|
||||
Union(2, typeof(GearData)),
|
||||
Union(3, typeof(HullData)),
|
||||
Union(6, typeof(SimpleCommodity)),
|
||||
Union(7, typeof(CompoundCommodity)),
|
||||
Union(8, typeof(Gear)),
|
||||
Union(4, typeof(SimpleCommodity)),
|
||||
Union(5, typeof(CompoundCommodity)),
|
||||
Union(6, typeof(Gear)),
|
||||
Union(7, typeof(BlueprintData)),
|
||||
Union(8, typeof(GalaxyMapLayerData)),
|
||||
Union(9, typeof(GlobalData)),
|
||||
Union(10, typeof(ZoneData)),
|
||||
Union(11, typeof(Player)),
|
||||
Union(12, typeof(Corporation)),
|
||||
Union(13, typeof(Ship)),
|
||||
Union(13, typeof(ShipData)),
|
||||
Union(14, typeof(StationData)),
|
||||
Union(15, typeof(OrbitData)),
|
||||
Union(16, typeof(PlanetData)),
|
||||
// Union(17, typeof(ShipData)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
||||
//[Union(21, typeof(ContractData))]
|
||||
//[Union(22, typeof(Station))]
|
||||
|
|
@ -70,4 +73,10 @@ public class Corporation : DatabaseEntry, INamedEntry
|
|||
get => Name;
|
||||
set => Name = value;
|
||||
}
|
||||
}
|
||||
|
||||
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class ShipData : DatabaseEntry
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -13,31 +13,36 @@ public class Entity
|
|||
public float Temperature;
|
||||
public float Energy;
|
||||
public float2 Position;
|
||||
public float2 Direction;
|
||||
public float2 Direction = float2(0,1);
|
||||
public float2 Velocity;
|
||||
public Dictionary<Guid, List<IActivatedBehavior>> Bindings;
|
||||
public Dictionary<IAnalogBehavior, float> Axes;
|
||||
|
||||
protected readonly GameContext Context;
|
||||
protected readonly List<IBehavior> Behaviors;
|
||||
protected readonly Dictionary<Guid, List<IActivatedBehavior>> Bindings;
|
||||
protected readonly Dictionary<IAnalogBehavior, float> Axes;
|
||||
protected readonly List<Gear> Items;
|
||||
protected readonly List<ItemInstance> Cargo;
|
||||
|
||||
protected Gear Hull;
|
||||
|
||||
public float Mass { get; private set; }
|
||||
public float SpecificHeat { get; private set; }
|
||||
public float Visibility => VisibilitySources.Values.Sum();
|
||||
|
||||
public Entity(GameContext context, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo)
|
||||
public Entity(GameContext context, Gear hull, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo)
|
||||
{
|
||||
Context = context;
|
||||
|
||||
Items = items.ToList();
|
||||
Cargo = cargo.ToList();
|
||||
Hull = hull;
|
||||
|
||||
Mass = Items.Sum(i => i.Mass) +
|
||||
Mass = hull?.Mass ?? 0 +
|
||||
Items.Sum(i => i.Mass) +
|
||||
Cargo.Sum(ii => ii.Mass);
|
||||
|
||||
SpecificHeat = Items.Sum(i => i.HeatCapacity) +
|
||||
SpecificHeat = (hull?.HeatCapacity ?? 0) +
|
||||
Items.Sum(i => i.HeatCapacity) +
|
||||
Cargo.Sum(ii => ii.HeatCapacity);
|
||||
|
||||
Behaviors = Items
|
||||
|
|
|
|||
|
|
@ -67,8 +67,8 @@ public static class Extensions
|
|||
}
|
||||
|
||||
private static Random? _random;
|
||||
private static Random Random => (Random) (_random ?? (_random = new Random(1337)));
|
||||
public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
|
||||
private static Random Random => (Random) (_random ?? (_random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue))));
|
||||
// public static T RandomElement<T>(this IEnumerable<T> enumerable) => enumerable.ElementAt(Random.NextInt(0, enumerable.Count()));
|
||||
public static float NextUnbounded(this Random random) => 1 / (1 - random.NextFloat()) - 1;
|
||||
public static float NextUnbounded(this Random random, float bias, float power) => 1 / (1 - pow(random.NextFloat(), 1 - pow(clamp(bias,0,.99f), 1 / power))) - 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,10 @@ using static Unity.Mathematics.math;
|
|||
|
||||
public class GameContext
|
||||
{
|
||||
public List<AgentController> Agents = new List<AgentController>();
|
||||
public Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>> ZoneContents = new Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>>();
|
||||
public Dictionary<string, GalaxyMapLayerData> MapLayers = new Dictionary<string, GalaxyMapLayerData>();
|
||||
|
||||
private Action<string> _logger;
|
||||
|
||||
private Dictionary<BlueprintStatEffect, PerformanceStat> AffectedStats =
|
||||
|
|
@ -13,8 +17,9 @@ public class GameContext
|
|||
|
||||
private double _time;
|
||||
private float _deltaTime;
|
||||
private GlobalData _globalData;
|
||||
|
||||
public GlobalData GlobalData => Cache.GetAll<GlobalData>().FirstOrDefault();
|
||||
public GlobalData GlobalData => _globalData ?? (_globalData = Cache.GetAll<GlobalData>().FirstOrDefault());
|
||||
public DatabaseCache Cache { get; }
|
||||
|
||||
public double Time
|
||||
|
|
@ -27,20 +32,18 @@ public class GameContext
|
|||
}
|
||||
}
|
||||
|
||||
private Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>> ZoneContents = new Dictionary<ZoneData, Dictionary<DatabaseEntry, Entity>>();
|
||||
|
||||
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
|
||||
|
||||
public GameContext(DatabaseCache cache, Action<string> logger)
|
||||
{
|
||||
Cache = cache;
|
||||
_logger = logger;
|
||||
var globalData = Cache.GetAll<GlobalData>().FirstOrDefault();
|
||||
if (globalData == null)
|
||||
{
|
||||
globalData = new GlobalData();
|
||||
Cache.Add(globalData);
|
||||
}
|
||||
// var globalData = Cache.GetAll<GlobalData>().FirstOrDefault();
|
||||
// if (globalData == null)
|
||||
// {
|
||||
// globalData = new GlobalData();
|
||||
// Cache.Add(globalData);
|
||||
// }
|
||||
}
|
||||
|
||||
public void Log(string s)
|
||||
|
|
@ -48,6 +51,11 @@ public class GameContext
|
|||
_logger(s);
|
||||
}
|
||||
|
||||
public IEnumerable<Entity> ZoneEntities(ZoneData zone)
|
||||
{
|
||||
return ZoneContents[zone].Values;
|
||||
}
|
||||
|
||||
public Dictionary<DatabaseEntry, Entity> InitializeZone(Guid zoneID)
|
||||
{
|
||||
var contents = new Dictionary<DatabaseEntry, Entity>();
|
||||
|
|
@ -56,13 +64,13 @@ public class GameContext
|
|||
|
||||
var planetsData = zoneData.Planets.Select(id => Cache.Get<PlanetData>(id)).ToArray();
|
||||
var planetEntities = planetsData.ToDictionary(p => p,
|
||||
p => new OrbitalEntity(this, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), p.Belt ? Cache.Get<OrbitData>(p.Orbit).Parent : p.Orbit));
|
||||
p => new OrbitalEntity(this, null, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), p.Belt ? Cache.Get<OrbitData>(p.Orbit).Parent : p.Orbit));
|
||||
foreach(var kvp in planetEntities)
|
||||
contents.Add(kvp.Key, kvp.Value);
|
||||
|
||||
var stationsData = zoneData.Stations.Select(id => Cache.Get<StationData>(id));
|
||||
var stationEntities = stationsData.ToDictionary(s => s,
|
||||
s => new OrbitalEntity(this, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), s.Parent));
|
||||
s => new OrbitalEntity(this, null, Enumerable.Empty<Gear>(), Enumerable.Empty<ItemInstance>(), s.Parent));
|
||||
foreach(var kvp in stationEntities)
|
||||
contents.Add(kvp.Key, kvp.Value);
|
||||
|
||||
|
|
@ -73,6 +81,10 @@ public class GameContext
|
|||
|
||||
public void Update()
|
||||
{
|
||||
foreach (var agent in Agents)
|
||||
{
|
||||
agent.Update(_deltaTime);
|
||||
}
|
||||
OrbitalEntity.ClearOrbits();
|
||||
foreach (var kvp in ZoneContents)
|
||||
{
|
||||
|
|
@ -293,7 +305,8 @@ public class GameContext
|
|||
Data = data,
|
||||
ID = Guid.NewGuid(),
|
||||
Ingredients = ingredients,
|
||||
Quality = quality
|
||||
Quality = quality,
|
||||
Blueprint = blueprint
|
||||
};
|
||||
newGear.Durability = Evaluate(equippableItemData.Durability, newGear);
|
||||
return newGear;
|
||||
|
|
@ -305,7 +318,8 @@ public class GameContext
|
|||
Data = data,
|
||||
ID = Guid.NewGuid(),
|
||||
Ingredients = ingredients,
|
||||
Quality = quality
|
||||
Quality = quality,
|
||||
Blueprint = blueprint
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -12,8 +12,11 @@ using Unity.Mathematics;
|
|||
// TODO: USE THIS EVERYWHERE
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[Union(0, typeof(SimpleCommodity)), Union(1, typeof(CompoundCommodity)), Union(2, typeof(Gear)),
|
||||
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemInstance>))]
|
||||
[Union(0, typeof(SimpleCommodity)),
|
||||
Union(1, typeof(CompoundCommodity)),
|
||||
Union(2, typeof(Gear)),
|
||||
JsonObject(MemberSerialization.OptIn),
|
||||
JsonConverter(typeof(JsonKnownTypesConverter<ItemInstance>))]
|
||||
public abstract class ItemInstance : DatabaseEntry
|
||||
{
|
||||
[JsonProperty("data"), Key(1)] public Guid Data;
|
||||
|
|
@ -22,7 +25,9 @@ public abstract class ItemInstance : DatabaseEntry
|
|||
public float HeatCapacity => Context.GetHeatCapacity(this);
|
||||
}
|
||||
|
||||
[Union(0, typeof(CompoundCommodity)), Union(1, typeof(Gear)), JsonObject(MemberSerialization.OptIn),
|
||||
[Union(0, typeof(CompoundCommodity)),
|
||||
Union(1, typeof(Gear)),
|
||||
JsonObject(MemberSerialization.OptIn),
|
||||
JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemInstance>))]
|
||||
public abstract class CraftedItemInstance : ItemInstance
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Locomotion
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,7 @@ public class OrbitalEntity : Entity
|
|||
private Guid _orbitData;
|
||||
private static Dictionary<Guid, float2> _orbitPositions = new Dictionary<Guid, float2>();
|
||||
|
||||
public OrbitalEntity(GameContext context, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo, Guid orbit) : base(context, items, cargo)
|
||||
public OrbitalEntity(GameContext context, Gear hull, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo, Guid orbit) : base(context, hull, items, cargo)
|
||||
{
|
||||
_orbitData = orbit;
|
||||
}
|
||||
|
|
|
|||
24
Assets/Scripts/ServerShared/RegisterResolver.cs
Normal file
24
Assets/Scripts/ServerShared/RegisterResolver.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using MessagePack.Resolvers;
|
||||
|
||||
public static class RegisterResolver
|
||||
{
|
||||
private static bool registered = false;
|
||||
public static void Register()
|
||||
{
|
||||
if (registered) return;
|
||||
|
||||
// Set extensions to default resolver.
|
||||
var resolver = CompositeResolver.Create(
|
||||
MathResolver.Instance,
|
||||
NativeGuidResolver.Instance,
|
||||
StandardResolver.Instance
|
||||
);
|
||||
var options = MessagePackSerializerOptions.Standard.WithResolver(resolver);
|
||||
MessagePackSerializer.DefaultOptions = options;
|
||||
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/RegisterResolver.cs.meta
Normal file
11
Assets/Scripts/ServerShared/RegisterResolver.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: cc638a5fae4350643871d45495a49643
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -21,9 +21,7 @@ public class Ship : Entity
|
|||
// [IgnoreMember] public Dictionary<Targetable, float> Contacts = new Dictionary<Targetable, float>();
|
||||
// [IgnoreMember] public Targetable Target;
|
||||
|
||||
private HullData _hullData;
|
||||
|
||||
public Ship(GameContext context, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo) : base(context, items, cargo)
|
||||
public Ship(GameContext context, Gear hull, IEnumerable<Gear> items, IEnumerable<ItemInstance> cargo) : base(context, hull, items, cargo)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +111,7 @@ public class Ship : Entity
|
|||
|
||||
public override void Update(float delta)
|
||||
{
|
||||
Position += Velocity * delta;
|
||||
base.Update(delta);
|
||||
// foreach (var kvp in Contacts.ToArray())
|
||||
// if (kvp.Key == null || Time.time - kvp.Value > GlobalData.Instance.TargetPersistenceDuration)
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@ using System.Globalization;
|
|||
using System.Linq;
|
||||
using MessagePack;
|
||||
using Unity.Mathematics;
|
||||
//using UnityEngine;
|
||||
// TODO: USE THIS EVERYWHERE
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
|
||||
|
|
@ -67,7 +65,7 @@ public class ZoneGenerator
|
|||
// Cache resource densities
|
||||
var resourceMaps = mapLayers.ToDictionary(m => m.ID, m => m.Evaluate(zone.Position, global));
|
||||
|
||||
var random = new Random();
|
||||
var random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue));
|
||||
|
||||
planetsData = planets.Where(p=>!p.Empty).Select(planet =>
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue