Created control module abstraction, vastly simplifying current and future control module code
Created context menu option for creating towing tasks
This commit is contained in:
hyperion51 2020-05-27 02:23:25 +01:00
commit 139c593ccd
21 changed files with 685 additions and 291 deletions

View file

@ -1,64 +0,0 @@
// 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 Guid Entity { get; }
// public EntityAgent EntityAgent { get; }
// public GameContext Context { get; }
// public Guid Zone { get; set; }
//
// private Locomotion _locomotion;
// private VelocityMatch _velocityMatch;
// private Random _random = new Random((uint) (DateTime.Now.Ticks%uint.MaxValue));
// private Guid _targetOrbit;
//
// public AgentController(GameContext context, Guid zone, Guid entity)
// {
// Entity = entity;
// Zone = zone;
// Context = context;
// EntityAgent = new EntityAgent(context, entity, zone, Guid.Empty);
// _locomotion = new Locomotion(context, entity);
// _velocityMatch = new VelocityMatch(context, entity);
// _velocityMatch.OnMatch += () =>
// {
// EntityAgent.CurrentBehavior = _locomotion;
// RandomTarget();
// };
// EntityAgent.CurrentBehavior = _locomotion;
// RandomTarget();
// }
//
// public void Update(float delta)
// {
// EntityAgent.Update(delta);
// // Context.Log(
// // $"Agent Mode: {EntityAgent.CurrentBehavior.GetType()} " +
// // $"Agent Distance: {distance} " +
// // $"Turnaround Distance: {_stoppingDistance + _turnaroundDistance} " +
// // $"Objective: {_objective.Key.ID.ToString().Substring(0, 8)}");
// var entity = Context.Cache.Get<Entity>(Entity);
//
// if (EntityAgent.CurrentBehavior == _locomotion)
// {
// var orbitData = Context.Cache.Get<OrbitData>(_targetOrbit);
// _velocityMatch.TargetOrbit = _targetOrbit;
// var matchDistanceTime = _velocityMatch.MatchDistanceTime;
// _locomotion.Objective = Context.GetOrbitPosition(_targetOrbit) + Context.GetOrbitVelocity(_targetOrbit) * matchDistanceTime.y;
// var distance = length(_locomotion.Objective - entity.Position);
// if (distance < matchDistanceTime.x)
// EntityAgent.CurrentBehavior = _velocityMatch;
// }
// }
//
// private void RandomTarget()
// {
// var entities = Context.ZonePlanets[Zone];
// _targetOrbit = Context.Cache.Get<PlanetData>(entities[_random.NextInt(entities.Length)]).Orbit;
// }
// }

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ee1e3350676acb044bd87c1d76c535a4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,29 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<Entity>))]
public class EntityAgent
{
[IgnoreMember] public AgentBehavior CurrentBehavior;
[IgnoreMember] public Guid Entity;
[IgnoreMember] public GameContext Context;
[JsonProperty("homeZone"), Key(0)] public Guid HomeZone;
[JsonProperty("homeColony"), Key(0)] public Guid HomeColony;
public EntityAgent(GameContext context, Guid entity, Guid homeZone, Guid homeColony)
{
Entity = entity;
HomeZone = homeZone;
Context = context;
}
public void Update(float delta)
{
CurrentBehavior?.Update(delta);
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fdefbc1e15541d8448061e9d97e44648
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -20,11 +20,11 @@ public class StationTowing : AgentTask
[JsonProperty("orbitDistance"), Key(6)]
public float OrbitDistance;
public StationTowing(Guid zone, Guid station, Guid orbitParent, float orbitDistance)
{
Zone = zone;
Station = station;
OrbitParent = orbitParent;
OrbitDistance = orbitDistance;
}
// public StationTowing(Guid zone, Guid station, Guid orbitParent, float orbitDistance)
// {
// Zone = zone;
// Station = station;
// OrbitParent = orbitParent;
// OrbitDistance = orbitDistance;
// }
}