Pointing arrow changes (#11097)
This commit is contained in:
@@ -1,84 +1,18 @@
|
||||
using Content.Server.Pointing.EntitySystems;
|
||||
using Content.Shared.Pointing.Components;
|
||||
using Robust.Server.GameObjects;
|
||||
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
||||
|
||||
namespace Content.Server.Pointing.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedPointingArrowComponent))]
|
||||
[Access(typeof(PointingSystem))]
|
||||
public sealed class PointingArrowComponent : SharedPointingArrowComponent
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The current amount of seconds left on this arrow.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("duration")]
|
||||
private float _duration = 4;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of seconds before the arrow changes movement direction.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("step")]
|
||||
private float _step = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of units that this arrow will move by when multiplied
|
||||
/// by the frame time.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("speed")]
|
||||
private float _speed = 1;
|
||||
|
||||
/// <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)]
|
||||
[DataField("rogue")]
|
||||
public bool Rogue = false;
|
||||
|
||||
public void Update(float frameTime)
|
||||
{
|
||||
var movement = _speed * frameTime * (_up ? 1 : -1);
|
||||
_entMan.GetComponent<TransformComponent>(Owner).LocalPosition += (0, movement);
|
||||
|
||||
_duration -= frameTime;
|
||||
_currentStep -= frameTime;
|
||||
|
||||
if (_duration <= 0)
|
||||
{
|
||||
if (Rogue)
|
||||
{
|
||||
_entMan.RemoveComponent<PointingArrowComponent>(Owner);
|
||||
_entMan.AddComponent<RoguePointingArrowComponent>(Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
_entMan.DeleteEntity(Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_currentStep <= 0)
|
||||
{
|
||||
_currentStep = _step;
|
||||
_up ^= true;
|
||||
}
|
||||
}
|
||||
public bool Rogue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ using Robust.Shared.Timing;
|
||||
namespace Content.Server.Pointing.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class PointingSystem : EntitySystem
|
||||
internal sealed class PointingSystem : SharedPointingSystem
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
@@ -128,7 +128,12 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
|
||||
_rotateToFaceSystem.TryFaceCoordinates(player, mapCoords.Position);
|
||||
|
||||
var arrow = EntityManager.SpawnEntity("pointingarrow", mapCoords);
|
||||
var arrow = EntityManager.SpawnEntity("PointingArrow", mapCoords);
|
||||
|
||||
if (TryComp<PointingArrowComponent>(arrow, out var pointing))
|
||||
{
|
||||
pointing.EndTime = _gameTiming.CurTime + TimeSpan.FromSeconds(4);
|
||||
}
|
||||
|
||||
if (EntityQuery<PointingArrowAngeringComponent>().FirstOrDefault() != null)
|
||||
{
|
||||
@@ -231,10 +236,28 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var component in EntityManager.EntityQuery<PointingArrowComponent>(true))
|
||||
var currentTime = _gameTiming.CurTime;
|
||||
|
||||
foreach (var component in EntityQuery<PointingArrowComponent>(true))
|
||||
{
|
||||
component.Update(frameTime);
|
||||
Update(component, currentTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update(PointingArrowComponent component, TimeSpan currentTime)
|
||||
{
|
||||
// TODO: That pause PR
|
||||
if (component.EndTime > currentTime)
|
||||
return;
|
||||
|
||||
if (component.Rogue)
|
||||
{
|
||||
RemComp<PointingArrowComponent>(component.Owner);
|
||||
EnsureComp<RoguePointingArrowComponent>(component.Owner);
|
||||
return;
|
||||
}
|
||||
|
||||
Del(component.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
if (component.Chasing is not {Valid: true} chasing || Deleted(chasing))
|
||||
{
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
component.TurningDelay -= frameTime;
|
||||
@@ -73,10 +73,10 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
var adjusted = angle.Degrees + 90;
|
||||
var newAngle = Angle.FromDegrees(adjusted);
|
||||
|
||||
transform.LocalRotation = newAngle;
|
||||
transform.WorldRotation = newAngle;
|
||||
|
||||
UpdateAppearance(uid, component, transform);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
transform.WorldRotation += Angle.FromDegrees(20);
|
||||
@@ -91,8 +91,10 @@ namespace Content.Server.Pointing.EntitySystems
|
||||
|
||||
if (component.ChasingTime > 0)
|
||||
{
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
_explosion.QueueExplosion(uid, ExplosionSystem.DefaultExplosionPrototypeId, 50, 3, 10);
|
||||
EntityManager.QueueDeleteEntity(uid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user