Fix namespaces and optimize imports (#1651)

* Fix namespaces and optimize imports

* Cleanup fixes

* Merge conflict fixes

* Merge conflict fixes

* Merge conflict fixes
This commit is contained in:
DrSmugleaf
2020-08-13 14:40:27 +02:00
committed by GitHub
parent 05a76d55f7
commit 4a8ed41e3a
500 changed files with 1044 additions and 1557 deletions

View File

@@ -1,39 +1,40 @@
#nullable enable
using System;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components;
using Content.Server.GameObjects.Components.Damage;
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Mobs;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.GameObjects.EntitySystems
namespace Content.Server.GameObjects.EntitySystems.DoAfter
{
public sealed class DoAfter
{
public Task<DoAfterStatus> AsTask { get; }
private TaskCompletionSource<DoAfterStatus> Tcs { get;}
public DoAfterEventArgs EventArgs;
public TimeSpan StartTime { get; }
public float Elapsed { get; set; }
public GridCoordinates UserGrid { get; }
public GridCoordinates TargetGrid { get; }
private bool _tookDamage;
public DoAfterStatus Status => AsTask.IsCompletedSuccessfully ? AsTask.Result : DoAfterStatus.Running;
// NeedHand
private string? _activeHand;
private ItemComponent? _activeItem;
public DoAfter(DoAfterEventArgs eventArgs)
{
EventArgs = eventArgs;
@@ -57,7 +58,7 @@ namespace Content.Server.GameObjects.EntitySystems
_activeHand = handsComponent.ActiveHand;
_activeItem = handsComponent.GetActiveHand;
}
Tcs = new TaskCompletionSource<DoAfterStatus>();
AsTask = Tcs.Task;
}
@@ -79,15 +80,15 @@ namespace Content.Server.GameObjects.EntitySystems
default:
throw new ArgumentOutOfRangeException();
}
Elapsed += frameTime;
if (IsFinished())
{
Tcs.SetResult(DoAfterStatus.Finished);
return;
}
if (IsCancelled())
{
Tcs.SetResult(DoAfterStatus.Cancelled);
@@ -101,13 +102,13 @@ namespace Content.Server.GameObjects.EntitySystems
{
return true;
}
// TODO :Handle inertia in space.
if (EventArgs.BreakOnUserMove && EventArgs.User.Transform.GridPosition != UserGrid)
{
return true;
}
if (EventArgs.BreakOnTargetMove && EventArgs.Target!.Transform.GridPosition != TargetGrid)
{
return true;
@@ -129,7 +130,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
return true;
}
if (EventArgs.NeedHand)
{
if (!EventArgs.User.TryGetComponent(out HandsComponent handsComponent))
@@ -169,4 +170,4 @@ namespace Content.Server.GameObjects.EntitySystems
return true;
}
}
}
}

View File

@@ -2,9 +2,10 @@
using System;
using System.Threading;
using Robust.Shared.Interfaces.GameObjects;
// ReSharper disable UnassignedReadonlyField
namespace Content.Server.GameObjects.EntitySystems
namespace Content.Server.GameObjects.EntitySystems.DoAfter
{
public sealed class DoAfterEventArgs
{

View File

@@ -3,13 +3,13 @@ using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components;
using Content.Server.GameObjects.Components.Damage;
using JetBrains.Annotations;
using Robust.Server.Interfaces.Timing;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems
namespace Content.Server.GameObjects.EntitySystems.DoAfter
{
[UsedImplicitly]
public sealed class DoAfterSystem : EntitySystem
@@ -19,18 +19,18 @@ namespace Content.Server.GameObjects.EntitySystems
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var comp in ComponentManager.EntityQuery<DoAfterComponent>())
{
if (_pauseManager.IsGridPaused(comp.Owner.Transform.GridID)) continue;
var cancelled = new List<DoAfter>(0);
var finished = new List<DoAfter>(0);
foreach (var doAfter in comp.DoAfters)
{
doAfter.Run(frameTime);
switch (doAfter.Status)
{
case DoAfterStatus.Running:
@@ -59,7 +59,7 @@ namespace Content.Server.GameObjects.EntitySystems
finished.Clear();
}
}
/// <summary>
/// Tasks that are delayed until the specified time has passed
/// These can be potentially cancelled by the user moving or when other things happen.
@@ -74,7 +74,7 @@ namespace Content.Server.GameObjects.EntitySystems
var doAfterComponent = eventArgs.User.GetComponent<DoAfterComponent>();
doAfterComponent.Add(doAfter);
DamageableComponent? damageableComponent = null;
// TODO: If the component's deleted this may not get unsubscribed?
if (eventArgs.BreakOnDamage && eventArgs.User.TryGetComponent(out damageableComponent))
{
@@ -82,12 +82,12 @@ namespace Content.Server.GameObjects.EntitySystems
}
await doAfter.AsTask;
if (damageableComponent != null)
{
damageableComponent.Damaged -= doAfter.HandleDamage;
}
return doAfter.Status;
}
}
@@ -98,4 +98,4 @@ namespace Content.Server.GameObjects.EntitySystems
Cancelled,
Finished,
}
}
}