Asteroids & Refactoring
We have proper belts that hug the Grid, reactive properties for planet instance data, and more!
This commit is contained in:
parent
a981a46170
commit
1f90d3639a
42 changed files with 614 additions and 597 deletions
|
|
@ -40,7 +40,7 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
|
|||
protected Func<float2> TargetPosition;
|
||||
protected Func<float2> TargetVelocity;
|
||||
protected bool MatchVelocity;
|
||||
protected List<SimplifiedZoneData> Path;
|
||||
protected List<ZoneDefinition> Path;
|
||||
protected Guid Task;
|
||||
protected bool Moving;
|
||||
protected bool Waiting;
|
||||
|
|
@ -116,7 +116,7 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
|
|||
if (Moving)
|
||||
{
|
||||
if(_entity.Parent!=Guid.Empty)
|
||||
_context.RemoveParent(_entity);
|
||||
_entity.RemoveParent();
|
||||
|
||||
var targetPosition = TargetPosition();
|
||||
var distance = length(targetPosition - _entity.Position);
|
||||
|
|
@ -179,12 +179,12 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
|
|||
var homeEntity = _context.Cache.Get<Entity>(HomeEntity);
|
||||
if (Zone == homeEntity.Zone) MoveTo(homeEntity, true, () =>
|
||||
{
|
||||
_context.SetParent(_entity, homeEntity);
|
||||
_entity.SetParent(homeEntity);
|
||||
onFinish?.Invoke();
|
||||
});
|
||||
else MoveTo(homeEntity.Zone.Data.ID, () => MoveTo(homeEntity, true, () =>
|
||||
{
|
||||
_context.SetParent(_entity, homeEntity);
|
||||
_entity.SetParent(homeEntity);
|
||||
onFinish?.Invoke();
|
||||
}));
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
|
|||
path.RemoveAt(0);
|
||||
if (path.Count > 0)
|
||||
{
|
||||
MoveTo(Zone.WormholePosition(Path[0].ZoneID), false, OnNextZone);
|
||||
MoveTo(Zone.WormholePosition(Path[0]), false, OnNextZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class HaulingController : ControllerBase, IBehavior, IPersistentBehavior
|
|||
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
|
||||
var target = Zone.Entities[haulingTask.Origin] as OrbitalEntity;
|
||||
|
||||
_context.SetParent(_entity, target);
|
||||
_entity.SetParent(target);
|
||||
var itemData = _context.Cache.Get<ItemData>(haulingTask.ItemType);
|
||||
int quantity = min((int) ((_entity.Capacity - _entity.OccupiedCapacity) / itemData.Size), haulingTask.Quantity - _itemsDelivered);
|
||||
if (itemData is SimpleCommodityData)
|
||||
|
|
@ -116,7 +116,7 @@ public class HaulingController : ControllerBase, IBehavior, IPersistentBehavior
|
|||
var haulingTask = _context.Cache.Get<HaulingTask>(Task);
|
||||
var target = Zone.Entities[haulingTask.Target] as OrbitalEntity;
|
||||
|
||||
_context.SetParent(_entity, target);
|
||||
_entity.SetParent(target);
|
||||
|
||||
var itemData = _context.Cache.Get<ItemData>(haulingTask.ItemType);
|
||||
if (itemData is SimpleCommodityData)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public class TowingController : ControllerBase, IBehavior, IPersistentBehavior
|
|||
var towingTask = _context.Cache.Get<StationTowing>(Task);
|
||||
var target = Zone.Entities[towingTask.Station] as OrbitalEntity;
|
||||
|
||||
_context.SetParent(target, _entity);
|
||||
target.SetParent(_entity);
|
||||
|
||||
_entity.SetMessage("Entering delivery phase.");
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ public class TowingController : ControllerBase, IBehavior, IPersistentBehavior
|
|||
var towingTask = _context.Cache.Get<StationTowing>(Task);
|
||||
var target = Zone.Entities[towingTask.Station] as OrbitalEntity;
|
||||
|
||||
_context.RemoveParent(target);
|
||||
target.RemoveParent();
|
||||
|
||||
_entity.SetMessage("Target delivered. Returning Home.");
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class WanderController : ControllerBase, IBehavior
|
|||
var randomEntity = entities[_context.Random.NextInt(entities.Length)];
|
||||
MoveTo(randomEntity, true, () =>
|
||||
{
|
||||
_context.SetParent(_entity, randomEntity);
|
||||
_entity.SetParent(randomEntity);
|
||||
_dockTime = _context.Random.NextFloat(_data.RandomDockTime);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue