Repairable Component (#3418)
* Adds a repairable component * Ignores RepairableComponent in the client * fix localization * fix localization
This commit is contained in:
@@ -238,6 +238,7 @@ namespace Content.Client
|
|||||||
"SecretStash",
|
"SecretStash",
|
||||||
"Toilet",
|
"Toilet",
|
||||||
"ClusterFlash",
|
"ClusterFlash",
|
||||||
|
"Repairable",
|
||||||
"GasGenerator",
|
"GasGenerator",
|
||||||
"SolutionTransfer",
|
"SolutionTransfer",
|
||||||
"Shovel",
|
"Shovel",
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Content.Server.GameObjects.Components.Interactable;
|
|
||||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||||
using Content.Server.Utility;
|
using Content.Server.Utility;
|
||||||
using Content.Shared.GameObjects.Components.Damage;
|
|
||||||
using Content.Shared.GameObjects.Components.Gravity;
|
using Content.Shared.GameObjects.Components.Gravity;
|
||||||
using Content.Shared.GameObjects.Components.Interactable;
|
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
|
||||||
using Content.Shared.Interfaces.GameObjects.Components;
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.Components.Gravity
|
namespace Content.Server.GameObjects.Components.Gravity
|
||||||
{
|
{
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public class GravityGeneratorComponent : SharedGravityGeneratorComponent, IInteractUsing, IBreakAct, IInteractHand
|
public class GravityGeneratorComponent : SharedGravityGeneratorComponent, IBreakAct, IInteractHand
|
||||||
{
|
{
|
||||||
[ComponentDependency] private readonly AppearanceComponent? _appearance = default!;
|
[ComponentDependency] private readonly AppearanceComponent? _appearance = default!;
|
||||||
|
|
||||||
@@ -96,28 +90,6 @@ namespace Content.Server.GameObjects.Components.Gravity
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
|
||||||
{
|
|
||||||
if (!eventArgs.Using.TryGetComponent(out WelderComponent? tool))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!await tool.UseTool(eventArgs.User, Owner, 2f, ToolQuality.Welding, 5f))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Repair generator
|
|
||||||
if (Owner.TryGetComponent(out IDamageableComponent? damageable))
|
|
||||||
{
|
|
||||||
damageable.Heal();
|
|
||||||
}
|
|
||||||
|
|
||||||
_intact = true;
|
|
||||||
|
|
||||||
Owner.PopupMessage(eventArgs.User,
|
|
||||||
Loc.GetString("You repair {0:theName} with {1:theName}", Owner, eventArgs.Using));
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnBreak(BreakageEventArgs eventArgs)
|
public void OnBreak(BreakageEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
_intact = false;
|
_intact = false;
|
||||||
|
|||||||
57
Content.Server/GameObjects/Components/RepairableComponent.cs
Normal file
57
Content.Server/GameObjects/Components/RepairableComponent.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#nullable enable
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Content.Shared.Interfaces;
|
||||||
|
using Content.Shared.GameObjects.Components.Interactable;
|
||||||
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
|
using Content.Shared.Interfaces.GameObjects.Components;
|
||||||
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class RepairableComponent : Component, IInteractUsing
|
||||||
|
{
|
||||||
|
public override string Name => "Repairable";
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
private int _fuelCost;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
private int _doAfterDelay;
|
||||||
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
base.ExposeData(serializer);
|
||||||
|
|
||||||
|
serializer.DataField(ref _fuelCost, "fuelCost", 5);
|
||||||
|
serializer.DataField(ref _doAfterDelay, "doAfterDelay", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
// Only repair if you are using a lit welder
|
||||||
|
if (!eventArgs.Using.TryGetComponent(out WelderComponent? welder) || !welder.WelderLit)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (Owner.TryGetComponent(out IDamageableComponent? damageable))
|
||||||
|
{
|
||||||
|
// Repair the target if it is damaged, oherwise do nothing
|
||||||
|
if (damageable.TotalDamage > 0)
|
||||||
|
{
|
||||||
|
if (!await welder.UseTool(eventArgs.User, Owner, _doAfterDelay, ToolQuality.Welding, _fuelCost))
|
||||||
|
return false;
|
||||||
|
damageable.Heal();
|
||||||
|
|
||||||
|
Owner.PopupMessage(eventArgs.User,
|
||||||
|
Loc.GetString("comp-repairable-repair",
|
||||||
|
("target", Owner),
|
||||||
|
("welder", eventArgs.Using)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Resources/Locale/en-US/components/repairable-component.ftl
Normal file
10
Resources/Locale/en-US/components/repairable-component.ftl
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
### Interaction Messages
|
||||||
|
|
||||||
|
# Shown when repairing something
|
||||||
|
comp-repairable-repair = You repair {PROPER($target) ->
|
||||||
|
[true] {""}
|
||||||
|
*[false] the{" "}
|
||||||
|
}{$target} with {PROPER($welder) ->
|
||||||
|
[true] {""}
|
||||||
|
*[false] the{" "}
|
||||||
|
}{$welder}
|
||||||
@@ -13,7 +13,6 @@
|
|||||||
state: activated
|
state: activated
|
||||||
shader: unshaded
|
shader: unshaded
|
||||||
map: ["enum.GravityGeneratorVisualLayers.Core"]
|
map: ["enum.GravityGeneratorVisualLayers.Core"]
|
||||||
|
|
||||||
- type: SnapGrid
|
- type: SnapGrid
|
||||||
offset: Center
|
offset: Center
|
||||||
- type: PowerReceiver
|
- type: PowerReceiver
|
||||||
@@ -31,6 +30,9 @@
|
|||||||
- type: InteractionOutline
|
- type: InteractionOutline
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
resistances: metallicResistances
|
resistances: metallicResistances
|
||||||
|
- type: Repairable
|
||||||
|
fuelCost: 10
|
||||||
|
doAfterDelay: 5
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
- trigger:
|
- trigger:
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
- SmallImpassable
|
- SmallImpassable
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
resistances: metallicResistances
|
resistances: metallicResistances
|
||||||
|
- type: Repairable
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
- trigger:
|
- trigger:
|
||||||
@@ -65,8 +66,9 @@
|
|||||||
sprite: Constructible/Structures/Windows/reinforced_window.rsi
|
sprite: Constructible/Structures/Windows/reinforced_window.rsi
|
||||||
- type: Icon
|
- type: Icon
|
||||||
sprite: Constructible/Structures/Windows/reinforced_window.rsi
|
sprite: Constructible/Structures/Windows/reinforced_window.rsi
|
||||||
- type: Damageable
|
- type: Repairable
|
||||||
resistances: metallicResistances
|
fuelCost: 10
|
||||||
|
doAfterDelay: 2
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
thresholds:
|
thresholds:
|
||||||
- trigger:
|
- trigger:
|
||||||
|
|||||||
Reference in New Issue
Block a user