New Inventory System + Overhaul
Removed universal GameContext references Refactored GameContext: It's now only responsible for item management. As such it's now called ItemManager GlobalData is gone, relevant settings are distributed amongst specialized settings classes Entities are no longer database entries, references to them are now direct - Zone is reponsible for storing them in ZonePacks Controller subtypes are now generic classes, class argument is task type Inventory is now a 2D grid instead of a list Entity temperature is now a 2D grid instead of a number Item sizes are now arbitrary shapes instead of a number Hardpoints are now arbitrary shapes instead Equipped items have their own temperatures Map view now displays sunlight colors Integrated Allegorithmic Substance Plugin Imported Djinni ship and assigned Substance materials Removed Node Editor framework (might come back later but needs work to integrate with behavior system)
This commit is contained in:
parent
53a91351b7
commit
f643f6cc8a
330 changed files with 24242 additions and 2830 deletions
|
|
@ -10,82 +10,70 @@ using static Unity.Mathematics.math;
|
|||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), Order(-100)]
|
||||
public class TowingControllerData : ControllerData
|
||||
{
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
|
||||
{
|
||||
return new TowingController(context, this, entity, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class TowingController : ControllerBase, IBehavior, IPersistentBehavior
|
||||
public class TowingController : ControllerBase<StationTowing>, IBehavior, IPersistentBehavior
|
||||
{
|
||||
public override TaskType TaskType => TaskType.Tow;
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
private TowingControllerData _data;
|
||||
private GameContext _context;
|
||||
private Entity _entity;
|
||||
private Gear _item;
|
||||
private EquippedItem Item { get; }
|
||||
private bool _taskStarted;
|
||||
|
||||
public TowingController(GameContext context, TowingControllerData data, Entity entity, Gear item) : base(context, data, entity)
|
||||
public TowingController(ItemManager itemManager, TowingControllerData data, Entity entity, EquippedItem item) : base(itemManager, data, entity)
|
||||
{
|
||||
_context = context;
|
||||
_data = data;
|
||||
_entity = entity;
|
||||
_item = item;
|
||||
Item = item;
|
||||
}
|
||||
|
||||
public new bool Update(float delta)
|
||||
{
|
||||
var towingTask = _context.Cache.Get<StationTowing>(Task);
|
||||
if (towingTask != null)
|
||||
if (Task != null)
|
||||
{
|
||||
if (!_taskStarted)
|
||||
{
|
||||
MoveTo(towingTask.Zone, OnZoneArrival);
|
||||
MoveTo(Task.Station, true, OnPickup);
|
||||
_taskStarted = true;
|
||||
}
|
||||
}
|
||||
return base.Update(delta);
|
||||
}
|
||||
|
||||
void OnZoneArrival()
|
||||
{
|
||||
var towingTask = _context.Cache.Get<StationTowing>(Task);
|
||||
|
||||
_entity.SetMessage("Entering pickup phase.");
|
||||
|
||||
MoveTo(_context.Cache.Get<Entity>(towingTask.Station), true, OnPickup);
|
||||
}
|
||||
// void OnZoneArrival()
|
||||
// {
|
||||
// var towingTask = _context.ItemData.Get<StationTowing>(Task);
|
||||
//
|
||||
// _entity.SetMessage("Entering pickup phase.");
|
||||
//
|
||||
// MoveTo(_context.ItemData.Get<Entity>(towingTask.Station), true, OnPickup);
|
||||
// }
|
||||
|
||||
void OnPickup()
|
||||
{
|
||||
var towingTask = _context.Cache.Get<StationTowing>(Task);
|
||||
var target = Zone.Entities[towingTask.Station] as OrbitalEntity;
|
||||
Task.Station.SetParent(Entity);
|
||||
|
||||
target.SetParent(_entity);
|
||||
|
||||
_entity.SetMessage("Entering delivery phase.");
|
||||
Entity.SetMessage("Entering delivery phase.");
|
||||
|
||||
MoveTo(() =>
|
||||
{
|
||||
var orbitParent = Zone.GetOrbitPosition(towingTask.OrbitParent);
|
||||
var parentToUs = _entity.Position - orbitParent;
|
||||
return orbitParent + normalize(parentToUs) * towingTask.OrbitDistance;
|
||||
}, () => Zone.GetOrbitVelocity(towingTask.OrbitParent), OnDelivery);
|
||||
var orbitParent = Zone.GetOrbitPosition(Task.OrbitParent);
|
||||
var parentToUs = Entity.Position - orbitParent;
|
||||
return orbitParent + normalize(parentToUs) * Task.OrbitDistance;
|
||||
}, () => Zone.GetOrbitVelocity(Task.OrbitParent), OnDelivery);
|
||||
}
|
||||
|
||||
void OnDelivery()
|
||||
{
|
||||
var towingTask = _context.Cache.Get<StationTowing>(Task);
|
||||
var target = Zone.Entities[towingTask.Station] as OrbitalEntity;
|
||||
Task.Station.RemoveParent();
|
||||
|
||||
target.RemoveParent();
|
||||
|
||||
_entity.SetMessage("Target delivered. Returning Home.");
|
||||
Entity.SetMessage("Target delivered. Returning Home.");
|
||||
|
||||
var orbit = Zone.CreateOrbit(towingTask.OrbitParent, _entity.Position);
|
||||
target.OrbitData = orbit.ID;
|
||||
var orbit = Zone.CreateOrbit(Task.OrbitParent, Entity.Position);
|
||||
Task.Station.OrbitData = orbit.ID;
|
||||
|
||||
FinishTask();
|
||||
_taskStarted = false;
|
||||
|
|
@ -109,5 +97,5 @@ public class TowingController : ControllerBase, IBehavior, IPersistentBehavior
|
|||
public class TowingControllerPersistence : PersistentBehaviorData
|
||||
{
|
||||
[JsonProperty("task"), Key(0)]
|
||||
public Guid Task;
|
||||
public StationTowing Task;
|
||||
}
|
||||
Loading…
Reference in a new issue