HandComponents now have a default hand, fixes crash
This commit is contained in:
@@ -59,7 +59,7 @@ namespace Content.Client.GameObjects
|
|||||||
|
|
||||||
public IEntity GetEntity(string index)
|
public IEntity GetEntity(string index)
|
||||||
{
|
{
|
||||||
if (_hands.TryGetValue(index, out var entity))
|
if (!string.IsNullOrEmpty(index) && _hands.TryGetValue(index, out var entity))
|
||||||
{
|
{
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@@ -166,6 +166,8 @@ namespace Content.Client.GameObjects
|
|||||||
{
|
{
|
||||||
_hands.Add(slot, null);
|
_hands.Add(slot, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serializer.DataField(this, x => ActiveIndex, "defaultHand", _hands.Keys.LastOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleMessage(ComponentMessage message, IComponent component)
|
public override void HandleMessage(ComponentMessage message, IComponent component)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Server.Interfaces.GameObjects;
|
using Content.Server.Interfaces.GameObjects;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
@@ -68,6 +69,8 @@ namespace Content.Server.GameObjects
|
|||||||
AddHand(handsname);
|
AddHand(handsname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
serializer.DataField(ref activeIndex, "defaultHand", orderedHands.LastOrDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<ItemComponent> GetAllHeldItems()
|
public IEnumerable<ItemComponent> GetAllHeldItems()
|
||||||
|
|||||||
Reference in New Issue
Block a user