Replace resolve dependency with attribute in components (#1995)
* Replace resolve dependency with attribute in components * Add changes that went missing in translation
This commit is contained in:
@@ -32,6 +32,8 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
public class GridAtmosphereComponent : Component, IGridAtmosphereComponent
|
||||
{
|
||||
[Robust.Shared.IoC.Dependency] private IMapManager _mapManager = default!;
|
||||
[Robust.Shared.IoC.Dependency] private ITileDefinitionManager _tileDefinitionManager = default!;
|
||||
[Robust.Shared.IoC.Dependency] private IServerEntityManager _serverEntityManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Check current execution time every n instances processed.
|
||||
@@ -162,14 +164,13 @@ namespace Content.Server.GameObjects.Components.Atmos
|
||||
var mapGrid = mapGridComponent.Grid;
|
||||
var tile = mapGrid.GetTileRef(indices).Tile;
|
||||
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.TypeId];
|
||||
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.TypeId];
|
||||
|
||||
var underplating = tileDefinitionManager["underplating"];
|
||||
var underplating = _tileDefinitionManager["underplating"];
|
||||
mapGrid.SetTile(indices, new Tile(underplating.TileId));
|
||||
|
||||
//Actually spawn the relevant tile item at the right position and give it some offset to the corner.
|
||||
var tileItem = IoCManager.Resolve<IServerEntityManager>().SpawnEntity(tileDef.ItemDropPrototypeName, new GridCoordinates(indices.X, indices.Y, mapGrid));
|
||||
var tileItem = _serverEntityManager.SpawnEntity(tileDef.ItemDropPrototypeName, new GridCoordinates(indices.X, indices.Y, mapGrid));
|
||||
tileItem.Transform.WorldPosition += (0.2f, 0.2f);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,7 @@ using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -271,8 +267,6 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
|
||||
private void TryCreatePackage(IEntity user, UiAction action, int pillAmount, int bottleAmount)
|
||||
{
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
if (BufferSolution.CurrentVolume == 0)
|
||||
return;
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
[ComponentReference(typeof(IInteractUsing))]
|
||||
public class ReagentDispenserComponent : SharedReagentDispenserComponent, IActivate, IInteractUsing, ISolutionChange
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
[ViewVariables] private ContainerSlot _beakerContainer = default!;
|
||||
[ViewVariables] private string _packPrototypeId = "";
|
||||
|
||||
@@ -97,8 +99,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packPrototypeId)) return;
|
||||
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (!prototypeManager.TryIndex(_packPrototypeId, out ReagentDispenserInventoryPrototype packPrototype))
|
||||
if (!_prototypeManager.TryIndex(_packPrototypeId, out ReagentDispenserInventoryPrototype packPrototype))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
// to check for low volumes for evaporation or whatever
|
||||
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public override string Name => "Puddle";
|
||||
|
||||
@@ -134,8 +136,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
// Random sprite state set server-side so it's consistent across all clients
|
||||
_spriteComponent = Owner.EnsureComponent<SpriteComponent>();
|
||||
|
||||
var robustRandom = IoCManager.Resolve<IRobustRandom>();
|
||||
var randomVariant = robustRandom.Next(0, _spriteVariants - 1);
|
||||
var randomVariant = _random.Next(0, _spriteVariants - 1);
|
||||
|
||||
if (_spriteComponent.BaseRSIPath != null)
|
||||
{
|
||||
@@ -388,8 +389,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
||||
if (puddle == default)
|
||||
{
|
||||
var grid = _snapGrid.DirectionToGrid(direction);
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
puddle = () => entityManager.SpawnEntity(Owner.Prototype.ID, grid).GetComponent<PuddleComponent>();
|
||||
puddle = () => _entityManager.SpawnEntity(Owner.Prototype.ID, grid).GetComponent<PuddleComponent>();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -4,10 +4,7 @@ using System.Threading.Tasks;
|
||||
using Content.Server.GameObjects.Components.Body;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Server.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Storage;
|
||||
using Content.Shared.GameObjects.EntitySystems;
|
||||
using Content.Shared.GameObjects.Verbs;
|
||||
@@ -35,6 +32,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
||||
[ComponentReference(typeof(IStorageComponent))]
|
||||
public class EntityStorageComponent : Component, IActivate, IStorageComponent, IInteractUsing, IDestroyAct, IActionBlocker, IExAct
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override string Name => "EntityStorage";
|
||||
|
||||
private const float MaxSize = 1.0f; // maximum width or height of an entity allowed inside the storage.
|
||||
@@ -301,14 +300,13 @@ namespace Content.Server.GameObjects.Components.Items.Storage
|
||||
case RelayMovementEntityMessage msg:
|
||||
if (msg.Entity.HasComponent<HandsComponent>())
|
||||
{
|
||||
var timing = IoCManager.Resolve<IGameTiming>();
|
||||
if (timing.CurTime <
|
||||
if (_gameTiming.CurTime <
|
||||
_lastInternalOpenAttempt + InternalOpenAttemptDelay)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
_lastInternalOpenAttempt = timing.CurTime;
|
||||
_lastInternalOpenAttempt = _gameTiming.CurTime;
|
||||
TryOpenStorage(msg.Entity);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
|
||||
void IMapInit.MapInit()
|
||||
{
|
||||
var storage = Owner.GetComponent<IStorageComponent>();
|
||||
var random = IoCManager.Resolve<IRobustRandom>();
|
||||
|
||||
void Spawn(string prototype)
|
||||
{
|
||||
|
||||
@@ -9,12 +9,14 @@ namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
[RegisterComponent]
|
||||
public class OwOAccentComponent : Component, IAccentComponent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random;
|
||||
|
||||
public override string Name => "OwOAccent";
|
||||
|
||||
private static readonly IReadOnlyList<string> Faces = new List<string>{
|
||||
" (・`ω´・)", " ;;w;;", " owo", " UwU", " >w<", " ^w^"
|
||||
}.AsReadOnly();
|
||||
private string RandomFace => IoCManager.Resolve<IRobustRandom>().Pick(Faces);
|
||||
private string RandomFace => _random.Pick(Faces);
|
||||
|
||||
private static readonly Dictionary<string, string> SpecialWords = new Dictionary<string, string>
|
||||
{
|
||||
@@ -23,7 +25,7 @@ namespace Content.Server.GameObjects.Components.Mobs.Speech
|
||||
|
||||
public string Accentuate(string message)
|
||||
{
|
||||
foreach ((var word,var repl) in SpecialWords)
|
||||
foreach (var (word, repl) in SpecialWords)
|
||||
{
|
||||
message = message.Replace(word, repl);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,9 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
[RegisterComponent, ComponentReference(typeof(IMoverComponent))]
|
||||
public class AiControllerComponent : Component, IMoverComponent
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IGameTicker _gameTicker = default!;
|
||||
|
||||
private string? _logicName;
|
||||
private float _visionRadius;
|
||||
|
||||
@@ -64,8 +67,8 @@ namespace Content.Server.GameObjects.Components.Movement
|
||||
|
||||
if (StartingGearPrototype != null)
|
||||
{
|
||||
var startingGear = IoCManager.Resolve<IPrototypeManager>().Index<StartingGearPrototype>(StartingGearPrototype);
|
||||
IoCManager.Resolve<IGameTicker>().EquipStartingGear(Owner, startingGear);
|
||||
var startingGear = _prototypeManager.Index<StartingGearPrototype>(StartingGearPrototype);
|
||||
_gameTicker.EquipStartingGear(Owner, startingGear);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Content.Shared.GameObjects.Components.Damage;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.Components.Nutrition;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -19,6 +18,8 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
[RegisterComponent]
|
||||
public sealed class HungerComponent : SharedHungerComponent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
// Base stuff
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float BaseDecayRate
|
||||
@@ -141,7 +142,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
{
|
||||
base.Startup();
|
||||
// Similar functionality to SS13. Should also stagger people going to the chef.
|
||||
_currentHunger = IoCManager.Resolve<IRobustRandom>().Next(
|
||||
_currentHunger = _random.Next(
|
||||
(int)_hungerThresholds[HungerThreshold.Peckish] + 10,
|
||||
(int)_hungerThresholds[HungerThreshold.Okay] - 1);
|
||||
_currentHungerThreshold = GetHungerThreshold(_currentHunger);
|
||||
|
||||
@@ -6,7 +6,6 @@ using Content.Shared.GameObjects.Components.Damage;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Movement;
|
||||
using Content.Shared.GameObjects.Components.Nutrition;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Interfaces.Random;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -19,6 +18,8 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
[RegisterComponent]
|
||||
public sealed class ThirstComponent : SharedThirstComponent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
// Base stuff
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float BaseDecayRate
|
||||
@@ -136,7 +137,7 @@ namespace Content.Server.GameObjects.Components.Nutrition
|
||||
protected override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
_currentThirst = IoCManager.Resolve<IRobustRandom>().Next(
|
||||
_currentThirst = _random.Next(
|
||||
(int)ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
||||
(int)ThirstThresholds[ThirstThreshold.Okay] - 1);
|
||||
_currentThirstThreshold = GetThirstThreshold(_currentThirst);
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
||||
[RegisterComponent]
|
||||
public class PowerProviderComponent : BaseApcNetComponent, IPowerProvider
|
||||
{
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IServerEntityManager _serverEntityManager;
|
||||
|
||||
public override string Name => "PowerProvider";
|
||||
|
||||
/// <summary>
|
||||
@@ -91,14 +94,13 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
||||
|
||||
private List<PowerReceiverComponent> FindAvailableReceivers()
|
||||
{
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
var nearbyEntities = IoCManager.Resolve<IServerEntityManager>()
|
||||
var nearbyEntities = _serverEntityManager
|
||||
.GetEntitiesInRange(Owner, PowerTransferRange);
|
||||
return nearbyEntities.Select(entity => entity.TryGetComponent<PowerReceiverComponent>(out var receiver) ? receiver : null)
|
||||
.Where(receiver => receiver != null)
|
||||
.Where(receiver => receiver.Connectable)
|
||||
.Where(receiver => receiver.NeedsProvider)
|
||||
.Where(receiver => receiver.Owner.Transform.GridPosition.Distance(mapManager, Owner.Transform.GridPosition) < Math.Min(PowerTransferRange, receiver.PowerReceptionRange))
|
||||
.Where(receiver => receiver.Owner.Transform.GridPosition.Distance(_mapManager, Owner.Transform.GridPosition) < Math.Min(PowerTransferRange, receiver.PowerReceptionRange))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
||||
[RegisterComponent]
|
||||
public class PowerReceiverComponent : Component, IExamine
|
||||
{
|
||||
[Dependency] private readonly IServerEntityManager _serverEntityManager = default!;
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
|
||||
public override string Name => "PowerReceiver";
|
||||
|
||||
public event EventHandler<PowerStateEventArgs> OnPowerStateChanged;
|
||||
@@ -116,16 +119,16 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
||||
|
||||
private bool TryFindAvailableProvider(out IPowerProvider foundProvider)
|
||||
{
|
||||
var nearbyEntities = IoCManager.Resolve<IServerEntityManager>()
|
||||
var nearbyEntities = _serverEntityManager
|
||||
.GetEntitiesInRange(Owner, PowerReceptionRange);
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
|
||||
foreach (var entity in nearbyEntities)
|
||||
{
|
||||
if (entity.TryGetComponent<PowerProviderComponent>(out var provider))
|
||||
{
|
||||
if (provider.Connectable)
|
||||
{
|
||||
var distanceToProvider = provider.Owner.Transform.GridPosition.Distance(mapManager, Owner.Transform.GridPosition);
|
||||
var distanceToProvider = provider.Owner.Transform.GridPosition.Distance(_mapManager, Owner.Transform.GridPosition);
|
||||
if (distanceToProvider < Math.Min(PowerReceptionRange, provider.PowerTransferRange))
|
||||
{
|
||||
foundProvider = provider;
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
[RegisterComponent]
|
||||
public class HitscanComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override string Name => "Hitscan";
|
||||
public CollisionGroup CollisionMask => (CollisionGroup) _collisionMask;
|
||||
private int _collisionMask;
|
||||
@@ -60,7 +62,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
||||
public void FireEffects(IEntity user, float distance, Angle angle, IEntity hitEntity = null)
|
||||
{
|
||||
var effectSystem = EntitySystem.Get<EffectSystem>();
|
||||
_startTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
_startTime = _gameTiming.CurTime;
|
||||
_deathTime = _startTime + TimeSpan.FromSeconds(1);
|
||||
|
||||
var afterEffect = AfterEffects(user.Transform.GridPosition, angle, distance, 1.0f);
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace Content.Server.GameObjects.Components
|
||||
class RadioComponent : Component, IUse, IListen
|
||||
{
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
public override string Name => "Radio";
|
||||
|
||||
@@ -51,8 +52,7 @@ namespace Content.Server.GameObjects.Components
|
||||
|
||||
public void Speaker(string message)
|
||||
{
|
||||
var chat = IoCManager.Resolve<IChatManager>();
|
||||
chat.EntitySay(Owner, message);
|
||||
_chatManager.EntitySay(Owner, message);
|
||||
}
|
||||
|
||||
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
[ComponentReference(typeof(SharedLatheDatabaseComponent))]
|
||||
public class ProtolatheDatabaseComponent : SharedProtolatheDatabaseComponent
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override string Name => "ProtolatheDatabase";
|
||||
|
||||
public override ComponentState GetComponentState()
|
||||
@@ -24,13 +26,11 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
{
|
||||
if (!Owner.TryGetComponent(out TechnologyDatabaseComponent database)) return;
|
||||
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
foreach (var technology in database.Technologies)
|
||||
{
|
||||
foreach (var id in technology.UnlockedRecipes)
|
||||
{
|
||||
var recipe = (LatheRecipePrototype)prototypeManager.Index(typeof(LatheRecipePrototype), id);
|
||||
var recipe = (LatheRecipePrototype) _prototypeManager.Index(typeof(LatheRecipePrototype), id);
|
||||
UnlockRecipe(recipe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,7 @@ namespace Content.Server.GameObjects.Components.Research
|
||||
switch (message.Message)
|
||||
{
|
||||
case ConsoleUnlockTechnologyMessage msg:
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (!protoMan.TryIndex(msg.Id, out TechnologyPrototype tech)) break;
|
||||
if (!_prototypeManager.TryIndex(msg.Id, out TechnologyPrototype tech)) break;
|
||||
if (client.Server == null) break;
|
||||
if (!client.Server.CanUnlockTechnology(tech)) break;
|
||||
if (client.Server.UnlockTechnology(tech))
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace Content.Server.GameObjects.Components.StationEvents
|
||||
[RegisterComponent]
|
||||
public sealed class RadiationPulseComponent : SharedRadiationPulseComponent
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
|
||||
private const float MinPulseLifespan = 0.8f;
|
||||
private const float MaxPulseLifespan = 2.5f;
|
||||
|
||||
@@ -33,10 +36,10 @@ namespace Content.Server.GameObjects.Components.StationEvents
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
var currentTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
var currentTime = _gameTiming.CurTime;
|
||||
var duration =
|
||||
TimeSpan.FromSeconds(
|
||||
IoCManager.Resolve<IRobustRandom>().NextFloat() * (MaxPulseLifespan - MinPulseLifespan) +
|
||||
_random.NextFloat() * (MaxPulseLifespan - MinPulseLifespan) +
|
||||
MinPulseLifespan);
|
||||
|
||||
_endTime = currentTime + duration;
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
|
||||
public class VendingMachineComponent : SharedVendingMachineComponent, IActivate, IExamine, IBreakAct, IWires
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
private bool _ejecting;
|
||||
private TimeSpan _animationDuration = TimeSpan.Zero;
|
||||
@@ -77,8 +78,7 @@ namespace Content.Server.GameObjects.Components.VendingMachines
|
||||
private void InitializeFromPrototype()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packPrototypeId)) { return; }
|
||||
var prototypeManger = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (!prototypeManger.TryIndex(_packPrototypeId, out VendingMachineInventoryPrototype packPrototype))
|
||||
if (!_prototypeManager.TryIndex(_packPrototypeId, out VendingMachineInventoryPrototype packPrototype))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
[Dependency] private readonly IMapManager _mapManager = default!;
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
|
||||
[Dependency] private readonly IPhysicsManager _physicsManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override string Name => "MeleeWeapon";
|
||||
private TimeSpan _lastAttackTime;
|
||||
@@ -85,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
|
||||
void IAttack.Attack(AttackEventArgs eventArgs)
|
||||
{
|
||||
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
var curTime = _gameTiming.CurTime;
|
||||
var span = curTime - _lastAttackTime;
|
||||
if(span.TotalSeconds < _cooldownTime) {
|
||||
return;
|
||||
@@ -127,7 +128,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||
sys.SendAnimation(Arc, angle, eventArgs.User, hitEntities);
|
||||
}
|
||||
|
||||
_lastAttackTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||
_lastAttackTime = _gameTiming.CurTime;
|
||||
|
||||
if (Owner.TryGetComponent(out ItemCooldownComponent cooldown))
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user