mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-30 16:17:27 +00:00
* Initial port of goobstation factorio, missing disposals integration and faxing. Also ports impstations modification for robotic arms to have static power draw. Also adds automation slots to silos and advanced microwave. * Ports goobstation factorio fax automation, adds to the guidebook entry info about gas canisters. * Ported Goob Disposals. Removed part about taking mats out of storage silo cuz it ain't implemented yet. Seems to work. * Adds constructor circuitboard to research cuz I forgor
64 lines
1.9 KiB
C#
64 lines
1.9 KiB
C#
// SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
|
|
// SPDX-FileCopyrightText: 2025 deltanedas <@deltanedas:kde.org>
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
using Content.Shared._Goobstation.Factory;
|
|
using Content.Server.Construction;
|
|
using Content.Shared.Construction.Prototypes;
|
|
using Content.Shared.DoAfter;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Content.Server._Goobstation.Factory;
|
|
|
|
public sealed class ConstructorSystem : SharedConstructorSystem
|
|
{
|
|
[Dependency] private readonly ConstructionSystem _construction = default!;
|
|
[Dependency] private readonly StartableMachineSystem _machine = default!;
|
|
|
|
private EntityQuery<ActiveDoAfterComponent> _activeQuery;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_activeQuery = GetEntityQuery<ActiveDoAfterComponent>();
|
|
|
|
SubscribeLocalEvent<ConstructorComponent, MachineStartedEvent>(OnStarted);
|
|
}
|
|
|
|
private void OnStarted(Entity<ConstructorComponent> ent, ref MachineStartedEvent args)
|
|
{
|
|
// can't start if it's already building something
|
|
if (_activeQuery.HasComp(ent))
|
|
_machine.Failed(ent.Owner);
|
|
else
|
|
Construct(ent);
|
|
}
|
|
|
|
// async because construction shitcode
|
|
private async void Construct(Entity<ConstructorComponent> ent)
|
|
{
|
|
var uid = ent.Owner;
|
|
if (ent.Comp.Construction is not {} id)
|
|
{
|
|
_machine.Failed(uid);
|
|
return;
|
|
}
|
|
|
|
_machine.Started(uid);
|
|
|
|
var proto = Proto.Index(id);
|
|
var completed = proto.Type switch
|
|
{
|
|
ConstructionType.Structure => await _construction.TryStartStructureConstruction(uid, id, OutputPosition(ent), Angle.Zero),
|
|
ConstructionType.Item => await _construction.TryStartItemConstruction(id, uid)
|
|
};
|
|
|
|
if (completed)
|
|
_machine.Completed(uid);
|
|
else
|
|
_machine.Failed(uid);
|
|
}
|
|
}
|