Merge branch 'master' into 2020-04-28-tool-component
# Conflicts: # Content.Server/GameObjects/Components/AnchorableComponent.cs # Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs # Content.Server/GameObjects/Components/Doors/AirlockComponent.cs # Content.Server/GameObjects/Components/Gravity/GravityGeneratorComponent.cs # Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs # Content.Server/GameObjects/Components/Power/PowerTransferComponent.cs # Content.Server/GameObjects/Components/WiresComponent.cs
This commit is contained in:
@@ -18,8 +18,8 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IAttackBy))]
|
||||
public sealed class PowerCellChargerComponent : BaseCharger, IActivate, IAttackBy
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public sealed class PowerCellChargerComponent : BaseCharger, IActivate, IInteractUsing
|
||||
{
|
||||
public override string Name => "PowerCellCharger";
|
||||
public override double CellChargePercent => _container.ContainedEntity != null ?
|
||||
@@ -37,9 +37,9 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
||||
_powerDevice.OnPowerStateChanged += PowerUpdate;
|
||||
}
|
||||
|
||||
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
||||
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
var result = TryInsertItem(eventArgs.AttackWith);
|
||||
var result = TryInsertItem(eventArgs.Using);
|
||||
if (result)
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -21,17 +21,17 @@ namespace Content.Server.GameObjects.Components.Power.Chargers
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
[ComponentReference(typeof(IAttackBy))]
|
||||
public sealed class WeaponCapacitorChargerComponent : BaseCharger, IActivate, IAttackBy
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public sealed class WeaponCapacitorChargerComponent : BaseCharger, IActivate, IInteractUsing
|
||||
{
|
||||
public override string Name => "WeaponCapacitorCharger";
|
||||
public override double CellChargePercent => _container.ContainedEntity != null ?
|
||||
_container.ContainedEntity.GetComponent<HitscanWeaponCapacitorComponent>().Charge /
|
||||
_container.ContainedEntity.GetComponent<HitscanWeaponCapacitorComponent>().Capacity * 100 : 0.0f;
|
||||
|
||||
bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
|
||||
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
var result = TryInsertItem(eventArgs.AttackWith);
|
||||
var result = TryInsertItem(eventArgs.Using);
|
||||
if (!result)
|
||||
{
|
||||
var localizationManager = IoCManager.Resolve<ILocalizationManager>();
|
||||
|
||||
@@ -10,20 +10,20 @@ using Robust.Shared.Interfaces.GameObjects.Components;
|
||||
namespace Content.Server.GameObjects.Components.Power
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class PowerDebugTool : SharedPowerDebugTool, IAfterAttack
|
||||
public class PowerDebugTool : SharedPowerDebugTool, IAfterInteract
|
||||
{
|
||||
void IAfterAttack.AfterAttack(AfterAttackEventArgs eventArgs)
|
||||
void IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Attacked == null)
|
||||
if (eventArgs.Target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
|
||||
builder.AppendFormat("Entity: {0} ({1})\n", eventArgs.Attacked.Name, eventArgs.Attacked.Uid);
|
||||
builder.AppendFormat("Entity: {0} ({1})\n", eventArgs.Target.Name, eventArgs.Target.Uid);
|
||||
|
||||
if (eventArgs.Attacked.TryGetComponent<PowerNodeComponent>(out var node))
|
||||
if (eventArgs.Target.TryGetComponent<PowerNodeComponent>(out var node))
|
||||
{
|
||||
builder.AppendFormat("Power Node:\n");
|
||||
if (node.Parent == null)
|
||||
@@ -51,7 +51,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
if (eventArgs.Attacked.TryGetComponent<PowerDeviceComponent>(out var device))
|
||||
if (eventArgs.Target.TryGetComponent<PowerDeviceComponent>(out var device))
|
||||
{
|
||||
builder.AppendFormat(@"Power Device:
|
||||
Load: {0} W
|
||||
@@ -76,7 +76,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
if (eventArgs.Attacked.TryGetComponent<PowerStorageNetComponent>(out var storage))
|
||||
if (eventArgs.Target.TryGetComponent<PowerStorageNetComponent>(out var storage))
|
||||
{
|
||||
var stateSeconds = (DateTime.Now - storage.LastChargeStateChange).TotalSeconds;
|
||||
builder.AppendFormat(@"Power Storage:
|
||||
@@ -85,7 +85,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
", storage.Capacity, storage.Charge, storage.ChargeRate, storage.DistributionRate, storage.ChargePowernet, storage.LastChargeState, storage.GetChargeState(), stateSeconds);
|
||||
}
|
||||
|
||||
if (eventArgs.Attacked.TryGetComponent<PowerTransferComponent>(out var transfer))
|
||||
if (eventArgs.Target.TryGetComponent<PowerTransferComponent>(out var transfer))
|
||||
{
|
||||
builder.AppendFormat(@"Power Transfer:
|
||||
Powernet: {0}
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
/// Component to transfer power to nearby components, can create powernets and connect to nodes
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class PowerTransferComponent : Component, IAttackBy
|
||||
public class PowerTransferComponent : Component, IInteractUsing
|
||||
{
|
||||
public override string Name => "PowerTransfer";
|
||||
|
||||
@@ -140,9 +140,9 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
return Parent != null && Parent.Dirty == false && !Regenerating;
|
||||
}
|
||||
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.AttackWith.TryGetComponent(out ToolComponent tool)) return false;
|
||||
if (!eventArgs.Using.TryGetComponent(out ToolComponent tool)) return false;
|
||||
if (!tool.UseTool(eventArgs.User, Owner, ToolQuality.Cutting)) return false;
|
||||
|
||||
Owner.Delete();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
/// Component that represents a wall light. It has a light bulb that can be replaced when broken.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public class PoweredLightComponent : Component, IAttackHand, IAttackBy
|
||||
public class PoweredLightComponent : Component, IInteractHand, IInteractUsing
|
||||
{
|
||||
public override string Name => "PoweredLight";
|
||||
|
||||
@@ -49,12 +49,12 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
}
|
||||
}
|
||||
|
||||
public bool AttackBy(AttackByEventArgs eventArgs)
|
||||
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
return InsertBulb(eventArgs.AttackWith);
|
||||
return InsertBulb(eventArgs.Using);
|
||||
}
|
||||
|
||||
public bool AttackHand(AttackHandEventArgs eventArgs)
|
||||
public bool InteractHand(InteractHandEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.User.TryGetComponent(out DamageableComponent damageableComponent))
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ using Robust.Shared.Map;
|
||||
namespace Content.Server.GameObjects.Components.Power
|
||||
{
|
||||
[RegisterComponent]
|
||||
internal class WirePlacerComponent : Component, IAfterAttack
|
||||
internal class WirePlacerComponent : Component, IAfterInteract
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly IServerEntityManager _entityManager;
|
||||
@@ -24,7 +24,7 @@ namespace Content.Server.GameObjects.Components.Power
|
||||
public override string Name => "WirePlacer";
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AfterAttack(AfterAttackEventArgs eventArgs)
|
||||
public void AfterInteract(AfterInteractEventArgs eventArgs)
|
||||
{
|
||||
if (!InteractionChecks.InRangeUnobstructed(eventArgs)) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user