Add "count" to stack comp's type handler. (#11917)
This commit is contained in:
committed by
GitHub
parent
321d39e225
commit
f83f16df16
@@ -15,7 +15,6 @@ namespace Content.Shared.Stacks
|
|||||||
/// Current stack count.
|
/// Current stack count.
|
||||||
/// Do NOT set this directly, use the <see cref="SharedStackSystem.SetCount"/> method instead.
|
/// Do NOT set this directly, use the <see cref="SharedStackSystem.SetCount"/> method instead.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
[DataField("count")]
|
[DataField("count")]
|
||||||
public int Count { get; set; } = 30;
|
public int Count { get; set; } = 30;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ namespace Content.Shared.Stacks
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadOnly)]
|
[ViewVariables(VVAccess.ReadOnly)]
|
||||||
[DataField("max")]
|
[DataField("max")]
|
||||||
public int MaxCount { get; set; } = 30;
|
public int MaxCount { get; set; } = 30;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set to true to not reduce the count when used.
|
/// Set to true to not reduce the count when used.
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace Content.Shared.Stacks
|
|||||||
[Dependency] protected readonly SharedHandsSystem HandsSystem = default!;
|
[Dependency] protected readonly SharedHandsSystem HandsSystem = default!;
|
||||||
[Dependency] protected readonly SharedTransformSystem Xform = default!;
|
[Dependency] protected readonly SharedTransformSystem Xform = default!;
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
|
[Dependency] private readonly IViewVariablesManager _vvm = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -28,6 +29,9 @@ namespace Content.Shared.Stacks
|
|||||||
SubscribeLocalEvent<SharedStackComponent, ComponentStartup>(OnStackStarted);
|
SubscribeLocalEvent<SharedStackComponent, ComponentStartup>(OnStackStarted);
|
||||||
SubscribeLocalEvent<SharedStackComponent, ExaminedEvent>(OnStackExamined);
|
SubscribeLocalEvent<SharedStackComponent, ExaminedEvent>(OnStackExamined);
|
||||||
SubscribeLocalEvent<SharedStackComponent, InteractUsingEvent>(OnStackInteractUsing);
|
SubscribeLocalEvent<SharedStackComponent, InteractUsingEvent>(OnStackInteractUsing);
|
||||||
|
|
||||||
|
_vvm.GetTypeHandler<SharedStackComponent>()
|
||||||
|
.AddPath(nameof(SharedStackComponent.Count), (_, comp) => comp.Count, SetCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStackInteractUsing(EntityUid uid, SharedStackComponent stack, InteractUsingEvent args)
|
private void OnStackInteractUsing(EntityUid uid, SharedStackComponent stack, InteractUsingEvent args)
|
||||||
|
|||||||
Reference in New Issue
Block a user