Basic rotatable component (#416)
* Basic rotatable component * Added counter-clockwise verb * RegisterIgnore
This commit is contained in:
committed by
Pieter-Jan Briers
parent
e8679d9308
commit
4720353fa2
@@ -111,6 +111,7 @@ namespace Content.Client
|
|||||||
"MedicalScanner",
|
"MedicalScanner",
|
||||||
"WirePlacer",
|
"WirePlacer",
|
||||||
"Species",
|
"Species",
|
||||||
|
"Rotatable",
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var ignoreName in registerIgnore)
|
foreach (var ignoreName in registerIgnore)
|
||||||
|
|||||||
74
Content.Server/GameObjects/Components/RotatableComponent.cs
Normal file
74
Content.Server/GameObjects/Components/RotatableComponent.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using Content.Server.Interfaces;
|
||||||
|
using Content.Shared.GameObjects;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class RotatableComponent : Component
|
||||||
|
{
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private readonly IServerNotifyManager _notifyManager;
|
||||||
|
[Dependency] private readonly ILocalizationManager _localizationManager;
|
||||||
|
#pragma warning restore 649
|
||||||
|
public override string Name => "Rotatable";
|
||||||
|
|
||||||
|
private void TryRotate(IEntity user, Angle angle)
|
||||||
|
{
|
||||||
|
if (Owner.TryGetComponent(out PhysicsComponent physics))
|
||||||
|
{
|
||||||
|
if (physics.Anchored)
|
||||||
|
{
|
||||||
|
_notifyManager.PopupMessage(Owner.Transform.GridPosition, user, _localizationManager.GetString("It's stuck."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Owner.Transform.LocalRotation += angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Verb]
|
||||||
|
public sealed class RotateVerb : Verb<RotatableComponent>
|
||||||
|
{
|
||||||
|
protected override string GetText(IEntity user, RotatableComponent component)
|
||||||
|
{
|
||||||
|
return "Rotate clockwise";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override VerbVisibility GetVisibility(IEntity user, RotatableComponent component)
|
||||||
|
{
|
||||||
|
return VerbVisibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Activate(IEntity user, RotatableComponent component)
|
||||||
|
{
|
||||||
|
component.TryRotate(user, Angle.FromDegrees(90));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Verb]
|
||||||
|
public sealed class RotateCounterVerb : Verb<RotatableComponent>
|
||||||
|
{
|
||||||
|
protected override string GetText(IEntity user, RotatableComponent component)
|
||||||
|
{
|
||||||
|
return "Rotate counter-clockwise";
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override VerbVisibility GetVisibility(IEntity user, RotatableComponent component)
|
||||||
|
{
|
||||||
|
return VerbVisibility.Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Activate(IEntity user, RotatableComponent component)
|
||||||
|
{
|
||||||
|
component.TryRotate(user, Angle.FromDegrees(-90));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
name: White Office Chair
|
name: White Office Chair
|
||||||
id: chairOfficeLight
|
id: chairOfficeLight
|
||||||
components:
|
components:
|
||||||
|
- type: Rotatable
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
- type: Collidable
|
- type: Collidable
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
name: Dark Office Chair
|
name: Dark Office Chair
|
||||||
id: chairOfficeDark
|
id: chairOfficeDark
|
||||||
components:
|
components:
|
||||||
|
- type: Rotatable
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
- type: Collidable
|
- type: Collidable
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
id: VendingMachine
|
id: VendingMachine
|
||||||
name: vending machine
|
name: vending machine
|
||||||
components:
|
components:
|
||||||
|
- type: Physics
|
||||||
|
Anchored: true
|
||||||
|
- type: Rotatable
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Buildings/VendingMachines/empty.rsi
|
sprite: Buildings/VendingMachines/empty.rsi
|
||||||
|
|||||||
Reference in New Issue
Block a user