Add inhands support for startingGear (#1166)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -476,9 +476,10 @@ namespace Content.Server.GameTicking
|
||||
{
|
||||
GridCoordinates coordinates = lateJoin ? GetLateJoinSpawnPoint() : GetJobSpawnPoint(job.Prototype.ID);
|
||||
var entity = _entityManager.SpawnEntity(PlayerPrototypeName, coordinates);
|
||||
var startingGear = _prototypeManager.Index<StartingGearPrototype>(job.StartingGear);
|
||||
if (entity.TryGetComponent(out InventoryComponent inventory))
|
||||
{
|
||||
var gear = _prototypeManager.Index<StartingGearPrototype>(job.StartingGear).Equipment;
|
||||
var gear = startingGear.Equipment;
|
||||
|
||||
foreach (var (slot, equipmentStr) in gear)
|
||||
{
|
||||
@@ -487,6 +488,16 @@ namespace Content.Server.GameTicking
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out HandsComponent handsComponent))
|
||||
{
|
||||
var inhand = startingGear.Inhand;
|
||||
foreach (var (hand, prototype) in inhand)
|
||||
{
|
||||
var inhandEntity = _entityManager.SpawnEntity(prototype, entity.Transform.GridPosition);
|
||||
handsComponent.PutInHand(inhandEntity.GetComponent<ItemComponent>(), hand);
|
||||
}
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,12 @@ namespace Content.Shared.Jobs
|
||||
private string _id;
|
||||
private Dictionary<Slots, string> _equipment;
|
||||
|
||||
public IReadOnlyDictionary<string, string> Inhand => _inHand;
|
||||
/// <summary>
|
||||
/// hand index, item prototype
|
||||
/// </summary>
|
||||
private Dictionary<string, string> _inHand;
|
||||
|
||||
[ViewVariables] public string ID => _id;
|
||||
|
||||
[ViewVariables] public IReadOnlyDictionary<Slots, string> Equipment => _equipment;
|
||||
@@ -24,6 +30,7 @@ namespace Content.Shared.Jobs
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _inHand, "inhand", new Dictionary<string, string>(0));
|
||||
|
||||
var equipment = serializer.ReadDataField<Dictionary<string, string>>("equipment");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user