Feature/1754 kill player on body parts missing (#2014)
* Moved the uplink creation code to the PresetSuspicion.Start method to ensure uplink created when we give the traitor role Moved the starting TC balance to cvars * Added isVital flag for body parts Automatically killing creature if last vital body part removed Marked head as vital part
This commit is contained in:
@@ -152,6 +152,13 @@ namespace Content.Server.Body
|
||||
[ViewVariables]
|
||||
public IReadOnlyCollection<IMechanism> Mechanisms => _mechanisms;
|
||||
|
||||
/// <summary>
|
||||
/// Represents if body part is vital for creature.
|
||||
/// If the last vital body part is removed creature dies
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool IsVital { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// This method is called by
|
||||
/// <see cref="IBodyManagerComponent.PreMetabolism"/> before
|
||||
@@ -451,6 +458,7 @@ namespace Content.Server.Body
|
||||
RSIPath = data.RSIPath;
|
||||
RSIState = data.RSIState;
|
||||
MaxDurability = data.Durability;
|
||||
IsVital = data.IsVital;
|
||||
|
||||
if (!prototypeManager.TryIndex(data.DamageContainerPresetId,
|
||||
out DamageContainerPrototype damageContainerData))
|
||||
|
||||
@@ -82,6 +82,11 @@ namespace Content.Server.Body
|
||||
// TODO: SpriteComponent rework
|
||||
public Color? RSIColor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If body part is vital
|
||||
/// </summary>
|
||||
public bool IsVital { get; }
|
||||
|
||||
bool HasProperty<T>() where T : BodyPartProperty;
|
||||
|
||||
bool HasProperty(Type type);
|
||||
|
||||
@@ -279,16 +279,11 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
|
||||
if (speedSum <= 0.001f || _activeLegs.Count <= 0)
|
||||
{
|
||||
// Case: no way of moving. Fall down.
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner);
|
||||
playerMover.BaseWalkSpeed = 0.8f;
|
||||
playerMover.BaseSprintSpeed = 2.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Case: have at least one leg. Set move speed.
|
||||
EntitySystem.Get<StandingStateSystem>().Standing(Owner);
|
||||
|
||||
// Extra legs stack diminishingly.
|
||||
// Final speed = speed sum/(leg count-log4(leg count))
|
||||
playerMover.BaseWalkSpeed =
|
||||
@@ -568,28 +563,10 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
{
|
||||
DebugTools.AssertNotNull(part);
|
||||
|
||||
if (!_parts.ContainsValue(part))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var slotName = _parts.FirstOrDefault(x => x.Value == part).Key;
|
||||
if (string.IsNullOrEmpty(slotName)) return;
|
||||
DisconnectBodyPart(slotName, dropEntity);
|
||||
|
||||
var slotName = Parts.FirstOrDefault(x => x.Value == part).Key;
|
||||
RemoveBodyPart(slotName, dropEntity);
|
||||
|
||||
// Call disconnect on all limbs that were hanging off this limb
|
||||
if (TryGetBodyPartConnections(slotName, out List<string> connections))
|
||||
{
|
||||
// TODO: Optimize
|
||||
foreach (var connectionName in connections)
|
||||
{
|
||||
if (TryGetBodyPart(connectionName, out var result) && !ConnectedToCenterPart(result))
|
||||
{
|
||||
DisconnectBodyPart(connectionName, dropEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnBodyChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -757,6 +734,21 @@ namespace Content.Server.GameObjects.Components.Body
|
||||
SendNetworkMessage(mechanismMessage);
|
||||
}
|
||||
|
||||
if (CurrentDamageState == DamageState.Dead) return true;
|
||||
|
||||
// creadth: fall down if no legs
|
||||
if (part.PartType == BodyPartType.Leg && Parts.Count(x => x.Value.PartType == BodyPartType.Leg) == 0)
|
||||
{
|
||||
EntitySystem.Get<StandingStateSystem>().Down(Owner);
|
||||
}
|
||||
|
||||
// creadth: immediately kill entity if last vital part removed
|
||||
if (part.IsVital && Parts.Count(x => x.Value.PartType == part.PartType) == 0)
|
||||
{
|
||||
CurrentDamageState = DamageState.Dead;
|
||||
ForceHealthChangedEvent();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace Content.Shared.Body.Part
|
||||
private string _rsiState;
|
||||
private int _size;
|
||||
private string _surgeryDataName;
|
||||
private bool _isVital;
|
||||
|
||||
|
||||
[ViewVariables] public string Name => _name;
|
||||
|
||||
@@ -66,6 +68,8 @@ namespace Content.Shared.Body.Part
|
||||
|
||||
[ViewVariables] public string ID => _id;
|
||||
|
||||
[ViewVariables] public bool IsVital => _isVital;
|
||||
|
||||
public virtual void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
@@ -86,6 +90,7 @@ namespace Content.Shared.Body.Part
|
||||
serializer.DataField(ref _resistanceSetId, "resistances", string.Empty);
|
||||
serializer.DataField(ref _properties, "properties", new List<IExposeData>());
|
||||
serializer.DataField(ref _mechanisms, "mechanisms", new List<string>());
|
||||
serializer.DataField(ref _isVital, "isVital", false);
|
||||
|
||||
foreach (var property in _properties)
|
||||
{
|
||||
|
||||
@@ -366,6 +366,8 @@ namespace Content.Shared.GameObjects.Components.Damage
|
||||
protected virtual void EnterState(DamageState state) { }
|
||||
|
||||
protected virtual void OnHealthChanged(HealthChangedEventArgs e)
|
||||
{
|
||||
if (CurrentDamageState != DamageState.Dead)
|
||||
{
|
||||
if (DeadThreshold != -1 && TotalDamage > DeadThreshold)
|
||||
{
|
||||
@@ -379,6 +381,7 @@ namespace Content.Shared.GameObjects.Components.Damage
|
||||
{
|
||||
CurrentDamageState = DamageState.Alive;
|
||||
}
|
||||
}
|
||||
|
||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, e);
|
||||
HealthChangedEvent?.Invoke(e);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
damageContainer: biologicalDamageContainer
|
||||
resistances: defaultResistances
|
||||
surgeryDataType: Content.Server.Body.Surgery.BiologicalSurgeryData
|
||||
isVital: true
|
||||
mechanisms:
|
||||
- mechanism.Brain.BasicHuman
|
||||
- mechanism.Eyes.BasicHuman
|
||||
|
||||
@@ -112,8 +112,6 @@
|
||||
sprite: Mobs/Customization/human_hair.rsi
|
||||
- map: ["enum.Slots.MASK"]
|
||||
- map: ["enum.Slots.HEAD"]
|
||||
- map: ["hand-left"]
|
||||
- map: ["hand-right"]
|
||||
- type: Icon
|
||||
sprite: Mobs/Species/Human/parts.rsi
|
||||
state: full
|
||||
|
||||
Reference in New Issue
Block a user