Various Fixes
Newly created drones now register their origin colony correctly Hauling behavior fixed for multiple items Buttons can't be dragged unless explicitly enabled Inspecting a colony with lots of compound commodities no longer sets your computer on fire
This commit is contained in:
parent
cbebc78af1
commit
1e2b474fc1
11 changed files with 133 additions and 47 deletions
|
|
@ -28,7 +28,7 @@ public abstract class ControllerData : BehaviorData
|
|||
|
||||
public abstract class ControllerBase : IBehavior, IController, IInitializableBehavior
|
||||
{
|
||||
public Guid HomeEntity;
|
||||
protected Guid HomeEntity => (_entity as Ship)?.HomeEntity ?? Guid.Empty;
|
||||
public bool Available => _spaceworthy && Task == Guid.Empty;
|
||||
public abstract TaskType TaskType { get; }
|
||||
public Guid Zone => _entity.Zone;
|
||||
|
|
@ -59,15 +59,24 @@ public abstract class ControllerBase : IBehavior, IController, IInitializableBeh
|
|||
_context = context;
|
||||
_controllerData = data;
|
||||
_entity = entity;
|
||||
entity.GearEvent.OnChanged += () => _spaceworthy = entity.GetBehavior<Thruster>() != null && entity.GetBehavior<Reactor>() != null;
|
||||
entity.GearEvent.OnChanged += () =>
|
||||
{
|
||||
_spaceworthy = entity.GetBehavior<Thruster>() != null && entity.GetBehavior<Reactor>() != null;
|
||||
if(_spaceworthy)
|
||||
CreateBehaviors();
|
||||
};
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
|
||||
public void CreateBehaviors()
|
||||
{
|
||||
Locomotion = new Locomotion(_context, _entity, _controllerData);
|
||||
VelocityMatch = new VelocityMatch(_context, _entity, _controllerData);
|
||||
Aim = new Aim(_context, _entity, _controllerData);
|
||||
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
CreateBehaviors();
|
||||
_context.CorporationControllers[_entity.Corporation].Add(this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,8 @@ public class HaulingController : ControllerBase, IBehavior, IPersistentBehavior
|
|||
{
|
||||
var itemMatches = target.Cargo
|
||||
.Select(id => _context.Cache.Get<CraftedItemInstance>(id))
|
||||
.Where(ii => ii != null && ii.Data == haulingTask.ItemType);
|
||||
.Where(ii => ii != null && ii.Data == haulingTask.ItemType)
|
||||
.ToArray();
|
||||
if(!itemMatches.Any())
|
||||
FinishTask();
|
||||
foreach (var match in itemMatches)
|
||||
|
|
|
|||
|
|
@ -68,9 +68,27 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
public Dictionary<Guid, double> IncompleteCargo = new Dictionary<Guid, double>();
|
||||
|
||||
[JsonProperty("active"), Key(18)]
|
||||
public bool Active { get; set; }
|
||||
private bool _active;
|
||||
public bool Active
|
||||
{
|
||||
get => _active;
|
||||
set
|
||||
{
|
||||
_active = value;
|
||||
if (_active)
|
||||
{
|
||||
foreach (var hardpoint in Hardpoints)
|
||||
if(hardpoint.Gear!=null)
|
||||
foreach (var behavior in hardpoint.Behaviors)
|
||||
{
|
||||
if(behavior is IInitializableBehavior initializableBehavior)
|
||||
initializableBehavior.Initialize();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//public List<IncompleteItem> IncompleteCargo = new List<IncompleteItem>();
|
||||
|
||||
|
||||
[IgnoreMember] public Guid Zone;
|
||||
[IgnoreMember] public List<Hardpoint> Hardpoints;
|
||||
[IgnoreMember] public readonly Dictionary<object, float> VisibilitySources = new Dictionary<object, float>();
|
||||
|
|
@ -168,15 +186,16 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
Cargo.Add(remaining);
|
||||
}
|
||||
|
||||
foreach (var hardpoint in Hardpoints)
|
||||
if(hardpoint.Gear!=null)
|
||||
foreach (var behavior in hardpoint.Behaviors)
|
||||
{
|
||||
if(behavior is IPopulationAssignment populationAssignment)
|
||||
PopulationAssignments.Add(populationAssignment);
|
||||
if(behavior is IInitializableBehavior initializableBehavior)
|
||||
initializableBehavior.Initialize();
|
||||
}
|
||||
if (_active)
|
||||
{
|
||||
foreach (var hardpoint in Hardpoints)
|
||||
if(hardpoint.Gear!=null)
|
||||
foreach (var behavior in hardpoint.Behaviors)
|
||||
{
|
||||
if(behavior is IInitializableBehavior initializableBehavior)
|
||||
initializableBehavior.Initialize();
|
||||
}
|
||||
}
|
||||
|
||||
RecalculateMass();
|
||||
}
|
||||
|
|
@ -206,6 +225,11 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
})
|
||||
.ToArray();
|
||||
|
||||
foreach (var behavior in hardpoint.Behaviors)
|
||||
{
|
||||
if(behavior is IPopulationAssignment populationAssignment)
|
||||
PopulationAssignments.Add(populationAssignment);
|
||||
}
|
||||
}
|
||||
|
||||
public void Unequip(Hardpoint hardpoint)
|
||||
|
|
|
|||
|
|
@ -710,7 +710,7 @@ public class GameContext
|
|||
if (hullData.HullType == HullType.Ship)
|
||||
{
|
||||
var entity = CreateShip(hull.ID, gear.Select(g => g.ID),
|
||||
cargo.Select(c => c.ID).Concat(simpleCargo.Select(c => c.ID)), zone, corporation, loadoutData.Name);
|
||||
cargo.Select(c => c.ID).Concat(simpleCargo.Select(c => c.ID)), zone, corporation, Guid.Empty, loadoutData.Name);
|
||||
entity.Active = true;
|
||||
return entity;
|
||||
}
|
||||
|
|
@ -752,12 +752,13 @@ public class GameContext
|
|||
return null;
|
||||
}
|
||||
|
||||
public Ship CreateShip(Guid hull, IEnumerable<Guid> gear, IEnumerable<Guid> cargo, Guid zone, Guid corporation, string typeName)
|
||||
public Ship CreateShip(Guid hull, IEnumerable<Guid> gear, IEnumerable<Guid> cargo, Guid zone, Guid corporation, Guid homeEntity, string typeName)
|
||||
{
|
||||
|
||||
var ship = new Ship(this, hull, gear, cargo, zone, corporation)
|
||||
{
|
||||
Name = $"{typeName} {Random.NextInt(1,255):X}"
|
||||
Name = $"{typeName} {Random.NextInt(1,255):X}",
|
||||
HomeEntity = homeEntity
|
||||
};
|
||||
Cache.Add(ship);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
|
|
@ -16,6 +17,8 @@ public class Ship : Entity
|
|||
|
||||
// [IgnoreMember] public Dictionary<Targetable, float> Contacts = new Dictionary<Targetable, float>();
|
||||
// [IgnoreMember] public Targetable Target;
|
||||
[JsonProperty("homeEntity"), Key(19)]
|
||||
public Guid HomeEntity;
|
||||
|
||||
public Ship(GameContext context, Guid hull, IEnumerable<Guid> gear, IEnumerable<Guid> cargo, Guid zone, Guid corporation) : base(context, hull, gear, cargo, zone, corporation)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue