APC construction updated, uses electronics (#10987)
* APC construction and deconstruction Construction action GivePrototype * APC needs screwing + sprites * apc framework, working construction recipe * Energy swords hot * APC changes * APC construction/deconstruction * removed comments * Revert "Energy swords hot" This reverts commit 75228483abb3cc6252118b319bc8949d5198362d. * Renamed function for clarity * Fixed the last step not showing in the construction menu * Some fixes * Update Content.Server/Power/EntitySystems/ApcSystem.cs Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> * Update Content.Server/Construction/Completions/GivePrototype.cs Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> * Update Resources/Prototypes/Entities/Structures/Power/apc.yml Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> * Update Resources/Prototypes/Entities/Structures/Power/apc.yml Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> * Update Content.Server/Power/Components/ApcElectronicsComponent.cs Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> * Update Content.Client/Power/APC/ApcVisualizer.cs Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: CommieFlowers <rasmus.cedergren@hotmail.com> Co-authored-by: Jacob Tong <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
44
Content.Server/Construction/Completions/GivePrototype.cs
Normal file
44
Content.Server/Construction/Completions/GivePrototype.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Content.Server.Stack;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Prototypes;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Construction.Completions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed class GivePrototype : IGraphAction
|
||||
{
|
||||
[DataField("prototype", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string Prototype { get; private set; } = string.Empty;
|
||||
[DataField("amount")]
|
||||
public int Amount { get; private set; } = 1;
|
||||
|
||||
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Prototype))
|
||||
return;
|
||||
|
||||
var coordinates = entityManager.GetComponent<TransformComponent>(userUid ?? uid).Coordinates;
|
||||
|
||||
if (EntityPrototypeHelpers.HasComponent<StackComponent>(Prototype))
|
||||
{
|
||||
var stackEnt = entityManager.SpawnEntity(Prototype, coordinates);
|
||||
var stack = entityManager.GetComponent<StackComponent>(stackEnt);
|
||||
entityManager.EntitySysManager.GetEntitySystem<StackSystem>().SetCount(stackEnt, Amount, stack);
|
||||
entityManager.EntitySysManager.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(userUid, stackEnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < Amount; i++)
|
||||
{
|
||||
var item = entityManager.SpawnEntity(Prototype, coordinates);
|
||||
entityManager.EntitySysManager.GetEntitySystem<SharedHandsSystem>().PickupOrDrop(userUid, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
Content.Server/Construction/Conditions/ApcPanel.cs
Normal file
51
Content.Server/Construction/Conditions/ApcPanel.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Construction;
|
||||
using Content.Shared.Examine;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.Construction.Conditions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[DataDefinition]
|
||||
public sealed class ApcPanel : IGraphCondition
|
||||
{
|
||||
[DataField("open")] public bool Open { get; private set; } = true;
|
||||
|
||||
public bool Condition(EntityUid uid, IEntityManager entityManager)
|
||||
{
|
||||
if (!entityManager.TryGetComponent(uid, out ApcComponent? apc))
|
||||
return true;
|
||||
|
||||
return apc.IsApcOpen == Open;
|
||||
}
|
||||
|
||||
public bool DoExamine(ExaminedEvent args)
|
||||
{
|
||||
var entity = args.Examined;
|
||||
|
||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out ApcComponent? apc)) return false;
|
||||
|
||||
switch (Open)
|
||||
{
|
||||
case true when !apc.IsApcOpen:
|
||||
args.PushMarkup(Loc.GetString("construction-examine-condition-apc-open"));
|
||||
return true;
|
||||
case false when apc.IsApcOpen:
|
||||
args.PushMarkup(Loc.GetString("construction-examine-condition-apc-close"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public IEnumerable<ConstructionGuideEntry> GenerateGuideEntry()
|
||||
{
|
||||
yield return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = Open
|
||||
? "construction-step-condition-apc-open"
|
||||
: "construction-step-condition-apc-close"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user