Limit maximum capacity of fillable cluster grenades (#34281)
* Limit maximum capacity of fillable cluster grenades * Swap GrenadeCount method for component property
This commit is contained in:
@@ -27,7 +27,7 @@ public sealed partial class ScatteringGrenadeComponent : Component
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// If we have a pre-fill how many more can we spawn.
|
/// If we have a pre-fill how many more can we spawn.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AutoNetworkedField]
|
[ViewVariables(VVAccess.ReadOnly), AutoNetworkedField]
|
||||||
public int UnspawnedCount;
|
public int UnspawnedCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,6 +36,12 @@ public sealed partial class ScatteringGrenadeComponent : Component
|
|||||||
[DataField]
|
[DataField]
|
||||||
public int Capacity = 3;
|
public int Capacity = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of grenades currently contained in the cluster (both spawned and unspawned)
|
||||||
|
/// </summary>
|
||||||
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
|
public int Count => UnspawnedCount + Container.ContainedEntities.Count;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decides if contained entities trigger after getting launched
|
/// Decides if contained entities trigger after getting launched
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -49,6 +49,10 @@ public abstract class SharedScatteringGrenadeSystem : EntitySystem
|
|||||||
if (entity.Comp.Whitelist == null)
|
if (entity.Comp.Whitelist == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Make sure there's room for another grenade to be added
|
||||||
|
if (entity.Comp.Count >= entity.Comp.Capacity)
|
||||||
|
return;
|
||||||
|
|
||||||
if (args.Handled || !_whitelistSystem.IsValid(entity.Comp.Whitelist, args.Used))
|
if (args.Handled || !_whitelistSystem.IsValid(entity.Comp.Whitelist, args.Used))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -65,6 +69,6 @@ public abstract class SharedScatteringGrenadeSystem : EntitySystem
|
|||||||
if (!TryComp<AppearanceComponent>(entity, out var appearanceComponent))
|
if (!TryComp<AppearanceComponent>(entity, out var appearanceComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_appearance.SetData(entity, ClusterGrenadeVisuals.GrenadesCounter, entity.Comp.UnspawnedCount + entity.Comp.Container.ContainedEntities.Count, appearanceComponent);
|
_appearance.SetData(entity, ClusterGrenadeVisuals.GrenadesCounter, entity.Comp.Count, appearanceComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user