Add readonly where it is missing and fix those field names according to their modifiers (#2589)

This commit is contained in:
DrSmugleaf
2020-11-21 14:02:00 +01:00
committed by GitHub
parent c7f2b67297
commit 749cd11d33
94 changed files with 344 additions and 374 deletions

View File

@@ -15,9 +15,9 @@ namespace Content.Server.GameObjects.Components.Singularity
{
public readonly ContainmentFieldGeneratorComponent Generator1;
public readonly ContainmentFieldGeneratorComponent Generator2;
private List<IEntity> _fields = new List<IEntity>();
private readonly List<IEntity> _fields = new List<IEntity>();
private int _sharedEnergyPool;
private CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource();
private readonly CancellationTokenSource _powerDecreaseCancellationTokenSource = new CancellationTokenSource();
public int SharedEnergyPool
{
get => _sharedEnergyPool;

View File

@@ -1,24 +1,18 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.GameObjects.Components.Projectiles;
using Content.Server.Utility;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Physics;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Singularity
@@ -26,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Singularity
[RegisterComponent]
public class ContainmentFieldGeneratorComponent : Component, ICollideBehavior
{
[Dependency] private IPhysicsManager _physicsManager = null!;
[Dependency] private readonly IPhysicsManager _physicsManager = null!;
public override string Name => "ContainmentFieldGenerator";

View File

@@ -16,7 +16,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.ComponentDependencies;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -37,8 +36,8 @@ namespace Content.Server.GameObjects.Components.Singularity
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[ComponentDependency] private AppearanceComponent? _appearance = default;
[ComponentDependency] private AccessReader? _accessReader = default;
[ComponentDependency] private readonly AppearanceComponent? _appearance = default;
[ComponentDependency] private readonly AccessReader? _accessReader = default;
public override string Name => "Emitter";

View File

@@ -1,10 +1,8 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Server.GameObjects.Components.StationEvents;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.EntitySystemMessages;
using Content.Shared.Physics;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
@@ -15,7 +13,6 @@ using Robust.Shared.GameObjects.Components;
using Robust.Shared.GameObjects.Components.Map;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -29,9 +26,7 @@ namespace Content.Server.GameObjects.Components.Singularity
[RegisterComponent]
public class SingularityComponent : Component, ICollideBehavior
{
[Dependency] private IEntityManager _entityManager = null!;
[Dependency] private IRobustRandom _random = null!;
[Dependency] private readonly IRobustRandom _random = default!;
public override uint? NetID => ContentNetIDs.SINGULARITY;
@@ -163,17 +158,17 @@ namespace Content.Server.GameObjects.Components.Singularity
_singularityController?.Push(pushVector.Normalized, 2);
}
List<IEntity> _previousPulledEntites = new List<IEntity>();
private readonly List<IEntity> _previousPulledEntities = new List<IEntity>();
public void PullUpdate()
{
foreach (var previousPulledEntity in _previousPulledEntites)
foreach (var previousPulledEntity in _previousPulledEntities)
{
if(previousPulledEntity.Deleted) continue;
if (!previousPulledEntity.TryGetComponent<PhysicsComponent>(out var collidableComponent)) continue;
var controller = collidableComponent.EnsureController<SingularityPullController>();
controller.StopPull();
}
_previousPulledEntites.Clear();
_previousPulledEntities.Clear();
var entitiesToPull = Owner.EntityManager.GetEntitiesInRange(Owner.Transform.Coordinates, Level * 10);
foreach (var entity in entitiesToPull)
@@ -187,7 +182,7 @@ namespace Content.Server.GameObjects.Components.Singularity
var speed = 10 / vec.Length * Level;
controller.Pull(vec.Normalized, speed);
_previousPulledEntites.Add(entity);
_previousPulledEntities.Add(entity);
}
}