mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-16 21:17:39 +03:00
49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using Content.Client.Construction;
|
|
using Content.Shared.Construction.Prototypes;
|
|
using Content.Shared.RadialSelector;
|
|
using Content.Shared.ShortConstruction;
|
|
using Robust.Client.Placement;
|
|
using Robust.Shared.Enums;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.ShortConstruction;
|
|
|
|
public sealed class ShortConstructionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
|
[Dependency] private readonly IPlacementManager _placement = default!;
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
|
|
[Dependency] private readonly ConstructionSystem _construction = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<ShortConstructionComponent, RadialSelectorSelectedMessage>(OnItemRecieved);
|
|
}
|
|
|
|
private void OnItemRecieved(Entity<ShortConstructionComponent> ent, ref RadialSelectorSelectedMessage args)
|
|
{
|
|
if (!_proto.TryIndex(args.SelectedItem, out ConstructionPrototype? prototype) ||
|
|
!_gameTiming.IsFirstTimePredicted)
|
|
return;
|
|
|
|
if (prototype.Type == ConstructionType.Item)
|
|
{
|
|
_construction.TryStartItemConstruction(prototype.ID);
|
|
return;
|
|
}
|
|
|
|
var hijack = new ConstructionPlacementHijack(_construction, prototype);
|
|
|
|
_placement.BeginPlacing(new PlacementInformation
|
|
{
|
|
IsTile = false,
|
|
PlacementOption = prototype.PlacementMode
|
|
},
|
|
hijack);
|
|
}
|
|
}
|