Merge branch 'master' into 2020-08-31-click-attack

This commit is contained in:
Víctor Aguilera Puerto
2020-09-02 15:12:17 +02:00
committed by GitHub
299 changed files with 42728 additions and 31895 deletions

View File

@@ -12,13 +12,14 @@ namespace Content.Server.GameObjects.Components.Weapon
[RegisterComponent]
public sealed class FlashableComponent : SharedFlashableComponent
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
private double _duration;
private TimeSpan _lastFlash;
public void Flash(double duration)
{
var timing = IoCManager.Resolve<IGameTiming>();
_lastFlash = timing.CurTime;
_lastFlash = _gameTiming.CurTime;
_duration = duration;
Dirty();
}

View File

@@ -23,7 +23,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
public class FlashComponent : MeleeWeaponComponent, IUse, IExamine
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly ISharedNotifyManager _notifyManager = default!;
public override string Name => "Flash";
@@ -101,7 +100,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
{
sprite.LayerSetState(0, "burnt");
_notifyManager.PopupMessage(Owner, user, Loc.GetString("The flash burns out!"));
Owner.PopupMessage(user, Loc.GetString("The flash burns out!"));
}
else if (!_flashing)
{
@@ -155,7 +154,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
if (entity != user)
{
_notifyManager.PopupMessage(user, entity, Loc.GetString("{0:TheName} blinds you with {1:theName}", user, Owner));
user.PopupMessage(entity, Loc.GetString("{0:TheName} blinds you with {1:theName}", user, Owner));
}
}

View File

@@ -27,6 +27,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IPhysicsManager _physicsManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "MeleeWeapon";
private TimeSpan _lastAttackTime;
@@ -84,7 +85,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
{
if (!eventArgs.WideAttack) return true;
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
var curTime = _gameTiming.CurTime;
if(curTime < _cooldownEnd)
return true;
@@ -142,7 +143,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
{
if (eventArgs.WideAttack) return false;
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
var curTime = _gameTiming.CurTime;
if(curTime < _cooldownEnd || !eventArgs.Target.IsValid())
return true;

View File

@@ -31,7 +31,6 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
public class StunbatonComponent : MeleeWeaponComponent, IUse, IExamine, IMapInit, IInteractUsing
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly ISharedNotifyManager _notifyManager = default!;
public override string Name => "Stunbaton";
@@ -165,14 +164,14 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
{
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Cell missing..."));
Owner.PopupMessage(user, Loc.GetString("Cell missing..."));
return;
}
if (cell.CurrentCharge < EnergyPerUse)
{
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Machines/button.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
_notifyManager.PopupMessage(Owner, user, Loc.GetString("Dead cell..."));
Owner.PopupMessage(user, Loc.GetString("Dead cell..."));
return;
}

View File

@@ -25,6 +25,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
[RegisterComponent]
public class AmmoComponent : Component, IExamine
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
public override string Name => "Ammo";
public BallisticCaliber Caliber => _caliber;
private BallisticCaliber _caliber;
@@ -135,7 +137,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
return;
}
var time = IoCManager.Resolve<IGameTiming>().CurTime;
var time = _gameTiming.CurTime;
var deathTime = time + TimeSpan.FromMilliseconds(200);
// Offset the sprite so it actually looks like it's coming from the gun
var offset = angle.ToVec().Normalized / 2;

View File

@@ -25,6 +25,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
[RegisterComponent]
public sealed class RevolverBarrelComponent : ServerRangedBarrelComponent
{
[Dependency] private readonly IRobustRandom _random = default!;
public override string Name => "RevolverBarrel";
public override uint? NetID => ContentNetIDs.REVOLVER_BARREL;
@@ -176,7 +178,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
/// </summary>
public void Spin()
{
var random = IoCManager.Resolve<IRobustRandom>().Next(_ammoSlots.Length - 1);
var random = _random.Next(_ammoSlots.Length - 1);
_currentSlot = random;
if (_soundSpin != null)
{

View File

@@ -32,6 +32,10 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
[RegisterComponent]
public sealed class ServerRangedWeaponComponent : SharedRangedWeaponComponent, IHandSelected
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private TimeSpan _lastFireTime;
[ViewVariables(VVAccess.ReadWrite)]
@@ -102,7 +106,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
if (msg.TargetGrid != GridId.Invalid)
{
// grid pos
if (!IoCManager.Resolve<IMapManager>().TryGetGrid(msg.TargetGrid, out var grid))
if (!_mapManager.TryGetGrid(msg.TargetGrid, out var grid))
{
// Client sent us a message with an invalid grid.
break;
@@ -147,7 +151,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
return;
}
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
var curTime = _gameTiming.CurTime;
var span = curTime - _lastFireTime;
if (span.TotalSeconds < 1 / _barrel.FireRate)
{
@@ -158,7 +162,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
if (ClumsyCheck &&
user.HasComponent<ClumsyComponent>() &&
IoCManager.Resolve<IRobustRandom>().Prob(ClumsyExplodeChance))
_random.Prob(ClumsyExplodeChance))
{
var soundSystem = EntitySystem.Get<AudioSystem>();
soundSystem.PlayAtCoords("/Audio/Items/bikehorn.ogg",
@@ -178,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged
stun.Paralyze(3f);
}
user.PopupMessage(user, Loc.GetString("The gun blows up in your face!"));
user.PopupMessage(Loc.GetString("The gun blows up in your face!"));
Owner.Delete();
return;