Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction rework. #225

Merged
merged 1 commit into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Content.Server/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public override void Init()
factory.Register<DestructibleComponent>();
factory.Register<TemperatureComponent>();
factory.Register<ServerDoorComponent>();
factory.RegisterReference<ServerDoorComponent, IActivate>();

//Power Components
factory.Register<PowerTransferComponent>();
Expand Down Expand Up @@ -127,6 +128,7 @@ public override void Init()
factory.RegisterReference<ServerStorageComponent, IActivate>();
factory.Register<EntityStorageComponent>();
factory.RegisterReference<EntityStorageComponent, IStorageComponent>();
factory.RegisterReference<EntityStorageComponent, IActivate>();

factory.Register<ToolLockerFillComponent>();
factory.Register<ToolboxElectricalFillComponent>();
Expand All @@ -135,6 +137,7 @@ public override void Init()
factory.Register<PoweredLightComponent>();
factory.Register<SmesComponent>();
factory.Register<ApcComponent>();
factory.RegisterReference<ApcComponent, IActivate>();
factory.Register<MaterialComponent>();
factory.Register<StackComponent>();
factory.Register<MaterialStorageComponent>();
Expand All @@ -152,6 +155,7 @@ public override void Init()
factory.RegisterReference<SpawnPointComponent, SharedSpawnPointComponent>();

factory.Register<LatheComponent>();
factory.RegisterReference<LatheComponent, IActivate>();
factory.Register<LatheDatabaseComponent>();

factory.RegisterReference<LatheDatabaseComponent, SharedLatheDatabaseComponent>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void TryStartStructureConstruction(GridCoordinates loc, string prototypeName, An
var prototype = _prototypeManager.Index<ConstructionPrototype>(prototypeName);

var transform = Owner.Transform;
if (!loc.InRange(_mapManager, transform.GridPosition, InteractionSystem.INTERACTION_RANGE))
if (!loc.InRange(_mapManager, transform.GridPosition, InteractionSystem.InteractionRange))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Content.Server.GameObjects
{
public class ServerDoorComponent : Component, IAttackHand
public class ServerDoorComponent : Component, IActivate
{
public override string Name => "Door";

Expand Down Expand Up @@ -41,7 +41,7 @@ public override void OnRemove()
base.OnRemove();
}

public bool AttackHand(AttackHandEventArgs eventArgs)
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (_state == DoorState.Open)
{
Expand All @@ -51,7 +51,6 @@ public bool AttackHand(AttackHandEventArgs eventArgs)
{
Open();
}
return true;
}

public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Content.Server.GameObjects.Components
{
public class EntityStorageComponent : Component, IAttackHand, IStorageComponent
public class EntityStorageComponent : Component, IActivate, IStorageComponent
{
public override string Name => "EntityStorage";

Expand All @@ -41,7 +41,7 @@ public override void ExposeData(ObjectSerializer serializer)
[ViewVariables]
public bool Open { get; private set; }

public bool AttackHand(AttackHandEventArgs eventArgs)
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (Open)
{
Expand All @@ -51,7 +51,6 @@ public bool AttackHand(AttackHandEventArgs eventArgs)
{
OpenStorage();
}
return true;
}

private void CloseStorage()
Expand Down
7 changes: 3 additions & 4 deletions Content.Server/GameObjects/Components/Power/ApcComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace Content.Server.GameObjects.Components.Power
{
public sealed class ApcComponent : SharedApcComponent, IAttackHand
public sealed class ApcComponent : SharedApcComponent, IActivate
{
PowerStorageComponent Storage;
AppearanceComponent Appearance;
Expand Down Expand Up @@ -106,15 +106,14 @@ private ApcExternalPowerState CalcExtPowerState()
return net.Lack > 0 ? ApcExternalPowerState.Low : ApcExternalPowerState.Good;
}

bool IAttackHand.AttackHand(AttackHandEventArgs eventArgs)
void IActivate.Activate(ActivateEventArgs eventArgs)
{
if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
{
return false;
return;
}

_userInterface.Open(actor.playerSession);
return true;
}

private void _clickSound()
Expand Down
13 changes: 1 addition & 12 deletions Content.Server/GameObjects/Components/Research/LatheComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Content.Server.GameObjects.Components.Research
{
public class LatheComponent : SharedLatheComponent, IAttackHand, IAttackBy, IActivate
public class LatheComponent : SharedLatheComponent, IAttackBy, IActivate
{
public const int VolumePerSheet = 3750;

Expand Down Expand Up @@ -94,17 +94,6 @@ void IActivate.Activate(ActivateEventArgs eventArgs)
_userInterface.Open(actor.playerSession);
return;
}

bool IAttackHand.AttackHand(AttackHandEventArgs eventArgs)
{

if (!eventArgs.User.TryGetComponent(out IActorComponent actor))
return false;

_userInterface.Open(actor.playerSession);
return true;
}

bool IAttackBy.AttackBy(AttackByEventArgs eventArgs)
{
if (!Owner.TryGetComponent(out MaterialStorageComponent storage)
Expand Down
Loading