Child Inventory Drag & Drop
Added child selection and child inventory panel to colony tab, and implemented drag and drop functionality between parent and child inventories
This commit is contained in:
parent
5766fe8eba
commit
7b3c0cad64
16 changed files with 1101 additions and 333 deletions
|
|
@ -3,13 +3,13 @@ using System.Linq;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22), RuntimeInspectable]
|
||||
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
|
||||
public class ThermotoggleData : BehaviorData
|
||||
{
|
||||
[TemperatureInspectable, JsonProperty("targetTemp"), Key(1), RuntimeInspectable]
|
||||
[TemperatureInspectable, JsonProperty("targetTemp"), Key(1)]
|
||||
public float TargetTemperature;
|
||||
|
||||
[InspectableField, JsonProperty("perSecond"), Key(2)]
|
||||
[InspectableField, JsonProperty("highPass"), Key(2)]
|
||||
public bool HighPass;
|
||||
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
[IgnoreMember] public float ThermalMass { get; private set; }
|
||||
[IgnoreMember] public float Visibility => VisibilitySources.Values.Sum();
|
||||
|
||||
public class InventoryEvent : IDynamicProperties
|
||||
public class ChangeEvent : IChangeSource
|
||||
{
|
||||
public event Action OnChanged;
|
||||
|
||||
|
|
@ -93,9 +93,12 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
}
|
||||
}
|
||||
private bool _cargoChanged;
|
||||
public InventoryEvent CargoEvent = new InventoryEvent();
|
||||
public ChangeEvent CargoEvent = new ChangeEvent();
|
||||
|
||||
private bool _gearChanged;
|
||||
public InventoryEvent GearEvent = new InventoryEvent();
|
||||
public ChangeEvent GearEvent = new ChangeEvent();
|
||||
|
||||
public ChangeEvent ChildEvent = new ChangeEvent();
|
||||
|
||||
public float Capacity
|
||||
{
|
||||
|
|
@ -196,16 +199,24 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
PopulationAssignments.Add(populationAssignment);
|
||||
}
|
||||
|
||||
public void Equip(Gear gear, Hardpoint hardpoint)
|
||||
public void Unequip(Hardpoint hardpoint)
|
||||
{
|
||||
// Hardpoint is occupied, remove existing item from gear list
|
||||
if (hardpoint.Gear != null)
|
||||
{
|
||||
Gear.Remove(hardpoint.Gear.ID);
|
||||
Cargo.Add(hardpoint.Gear.ID);
|
||||
hardpoint.Gear = null;
|
||||
_cargoChanged = true;
|
||||
_gearChanged = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Equip(Gear gear, Hardpoint hardpoint)
|
||||
{
|
||||
// Hardpoint is occupied, remove existing item from gear list
|
||||
if (hardpoint.Gear != null) Unequip(hardpoint);
|
||||
if (Cargo.Contains(gear.ID)) Cargo.Remove(gear.ID);
|
||||
|
||||
hardpoint.Gear = gear;
|
||||
HydrateHardpoint(hardpoint);
|
||||
_gearChanged = true;
|
||||
|
|
@ -307,6 +318,7 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
Data = item.Data,
|
||||
Quantity = quantity
|
||||
};
|
||||
Context.Cache.Add(newSimpleCommodity);
|
||||
item.Quantity -= quantity;
|
||||
item = newSimpleCommodity;
|
||||
}
|
||||
|
|
@ -324,6 +336,7 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
Mass += entity.Mass;
|
||||
ThermalMass += entity.ThermalMass;
|
||||
Children.Add(entity.ID);
|
||||
ChildEvent.Change();
|
||||
}
|
||||
|
||||
public void RemoveChild(Entity entity)
|
||||
|
|
@ -331,6 +344,7 @@ public abstract class Entity : DatabaseEntry, IMessagePackSerializationCallbackR
|
|||
Mass -= entity.Mass;
|
||||
ThermalMass -= entity.ThermalMass;
|
||||
Children.Remove(entity.ID);
|
||||
ChildEvent.Change();
|
||||
}
|
||||
|
||||
public Guid Build(BlueprintData blueprint, float quality, string name, bool direct = false)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
|
||||
|
||||
public interface IDynamicProperties
|
||||
public interface IChangeSource
|
||||
{
|
||||
event Action OnChanged;
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ public class SimpleCommodity : ItemInstance
|
|||
}
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
public class Gear : CraftedItemInstance, IDynamicProperties
|
||||
public class Gear : CraftedItemInstance, IChangeSource
|
||||
{
|
||||
[JsonProperty("durability"), Key(7)] public float Durability;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue