Add pointing (#1435)

* Add pointing keybind and simple message

* Add turning the player when pointing

* Add pointing arrow

* Make the popup message appear on the pointing entity

* Add pointing to tiles and space and proper grammar

* Move pointing bind from HandsSystem to PointingSystem

* Add more messages for pointing depending on the viewer perspective

* Fix non nullable reference type

* Serialize pointing arrow duration

* Serialize pointing arrow step and add summaries

* Make arrow speed serializable and make it depend on frame time

* Add 0.2 second delay between pointings

* Add pointing arrow yaml examples

* Add the ability for pointing arrows to be rogue

* Remove rogue package reference

* Add point to verb

https://cdn.discordapp.com/attachments/313107470031650816/735268651636228197/unknown.png

* Add shift middle clicking an entity in the verb menu to point at it

* Add VV to PointingArrowComponent

* Increase pointing delay from 0.2 to 0.5 seconds

* Address reviews

* Fix nullability errors

* Separate pointing and rogue pointing code

* Fix rogue pointing arrow visuals

* Made rogue pointing arrow rotation adjustment readable for mortals

* Make rogue pointing arrows less destructive

* Cleanup more of the rogue pointing arrow code
This commit is contained in:
DrSmugleaf
2020-07-24 14:51:18 +02:00
committed by GitHub
parent 1eac63e5bb
commit 245dbdaa3a
19 changed files with 671 additions and 4 deletions

View File

@@ -0,0 +1,101 @@
#nullable enable
using Content.Shared.GameObjects.Components.Pointing;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using DrawDepth = Content.Shared.GameObjects.DrawDepth;
namespace Content.Server.GameObjects.Components.Pointing
{
[RegisterComponent]
public class PointingArrowComponent : SharedPointingArrowComponent
{
/// <summary>
/// The current amount of seconds left on this arrow.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
private float _duration;
/// <summary>
/// The amount of seconds before the arrow changes movement direction.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
private float _step;
/// <summary>
/// The amount of units that this arrow will move by when multiplied
/// by the frame time.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
private float _speed;
/// <summary>
/// The current amount of seconds left before the arrow changes
/// movement direction.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
private float _currentStep;
/// <summary>
/// Whether or not this arrow is currently going up.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
private bool _up;
/// <summary>
/// Whether or not this arrow will convert into a
/// <see cref="RoguePointingArrowComponent"/> when its duration runs out.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
private bool _rogue;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _duration, "duration", 4);
serializer.DataField(ref _step, "step", 0.5f);
serializer.DataField(ref _speed, "speed", 1);
serializer.DataField(ref _rogue, "rogue", false);
}
protected override void Startup()
{
base.Startup();
if (Owner.TryGetComponent(out SpriteComponent sprite))
{
sprite.DrawDepth = (int) DrawDepth.Overlays;
}
}
public void Update(float frameTime)
{
var movement = _speed * frameTime * (_up ? 1 : -1);
Owner.Transform.LocalPosition += (0, movement);
_duration -= frameTime;
_currentStep -= frameTime;
if (_duration <= 0)
{
if (_rogue)
{
Owner.RemoveComponent<PointingArrowComponent>();
Owner.AddComponent<RoguePointingArrowComponent>();
return;
}
Owner.Delete();
return;
}
if (_currentStep <= 0)
{
_currentStep = _step;
_up ^= true;
}
}
}
}