Merge remote-tracking branch 'upstream/master' into 20-10-30-admins

This commit is contained in:
Pieter-Jan Briers
2020-10-30 16:23:21 +01:00
747 changed files with 26214 additions and 11240 deletions

View File

@@ -0,0 +1,18 @@
using Content.Server.GameObjects.Components.Power;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class BatterySystem : EntitySystem
{
public override void Update(float frameTime)
{
foreach (var comp in ComponentManager.EntityQuery<BatteryComponent>(false))
{
comp.OnUpdate(frameTime);
}
}
}
}

View File

@@ -2,11 +2,12 @@
using System.Linq;
using Content.Server.GameObjects.Components.Medical;
using Content.Server.Mobs;
using Content.Shared.GameTicking;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
internal sealed class CloningSystem : EntitySystem
internal sealed class CloningSystem : EntitySystem, IResettingEntitySystem
{
public override void Update(float frameTime)
{
@@ -16,9 +17,9 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
public static Dictionary<int, Mind> Minds = new Dictionary<int, Mind>();
public readonly Dictionary<int, Mind> Minds = new Dictionary<int, Mind>();
public static void AddToDnaScans(Mind mind)
public void AddToDnaScans(Mind mind)
{
if (!Minds.ContainsValue(mind))
{
@@ -26,14 +27,19 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
public static bool HasDnaScan(Mind mind)
public bool HasDnaScan(Mind mind)
{
return Minds.ContainsValue(mind);
}
public static Dictionary<int, string> getIdToUser()
public Dictionary<int, string> GetIdToUser()
{
return Minds.ToDictionary(m => m.Key, m => m.Value.CharacterName);
}
public void Reset()
{
Minds.Clear();
}
}
}

View File

@@ -0,0 +1,28 @@
using Content.Server.Interfaces;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems.DeviceNetwork
{
public class DeviceNetworkSystem : EntitySystem
{
private IDeviceNetwork _network;
public override void Initialize()
{
base.Initialize();
_network = IoCManager.Resolve<IDeviceNetwork>();
}
public override void Update(float frameTime)
{
base.Update(frameTime);
if (_network == null)
return;
//(ノ°Д°)ノ︵ ┻━┻
_network.Update();
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using Content.Server.GameObjects.Components.Atmos;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.EntitySystemMessages;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class GasTankSystem : EntitySystem
{
private float _timer = 0f;
private const float Interval = 0.5f;
public override void Update(float frameTime)
{
base.Update(frameTime);
_timer += frameTime;
if (_timer < Interval) return;
_timer = 0f;
foreach (var gasTank in EntityManager.ComponentManager.EntityQuery<GasTankComponent>())
{
gasTank.Update();
}
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Linq;
using Content.Server.GameObjects.Components.Gravity;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Gravity;
using Content.Shared.GameObjects.EntitySystemMessages.Gravity;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Player;
@@ -41,7 +42,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
generator.UpdateState();
}
if (generator.Status == GravityGeneratorStatus.On)
{
gridsWithGravity.Add(generator.Owner.Transform.GridID);
@@ -52,12 +53,11 @@ namespace Content.Server.GameObjects.EntitySystems
{
if (grid.HasGravity && !gridsWithGravity.Contains(grid.Index))
{
grid.HasGravity = false;
ScheduleGridToShake(grid.Index, ShakeTimes);
} else if (!grid.HasGravity && gridsWithGravity.Contains(grid.Index))
DisableGravity(grid);
}
else if (!grid.HasGravity && gridsWithGravity.Contains(grid.Index))
{
grid.HasGravity = true;
ScheduleGridToShake(grid.Index, ShakeTimes);
EnableGravity(grid);
}
}
@@ -68,6 +68,26 @@ namespace Content.Server.GameObjects.EntitySystems
}
}
private void EnableGravity(IMapGrid grid)
{
grid.HasGravity = true;
ScheduleGridToShake(grid.Index, ShakeTimes);
var message = new GravityChangedMessage(grid);
RaiseLocalEvent(message);
}
private void DisableGravity(IMapGrid grid)
{
grid.HasGravity = false;
ScheduleGridToShake(grid.Index, ShakeTimes);
var message = new GravityChangedMessage(grid);
RaiseLocalEvent(message);
}
private void ScheduleGridToShake(GridId gridId, uint shakeTimes)
{
if (!_gridsToShake.Keys.Contains(gridId))

View File

@@ -9,7 +9,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
public override void Update(float frameTime)
{
foreach (var comp in ComponentManager.EntityQuery<HandheldLightComponent>())
foreach (var comp in ComponentManager.EntityQuery<HandheldLightComponent>(false))
{
comp.OnUpdate(frameTime);
}

View File

@@ -0,0 +1,27 @@
using Content.Server.GameObjects.Components.Morgue;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class MorgueSystem : EntitySystem
{
private float _accumulatedFrameTime;
public override void Update(float frameTime)
{
_accumulatedFrameTime += frameTime;
if (_accumulatedFrameTime >= 10)
{
foreach (var morgue in ComponentManager.EntityQuery<MorgueEntityStorageComponent>())
{
morgue.Update();
}
_accumulatedFrameTime -= 10;
}
}
}
}

View File

@@ -0,0 +1,28 @@
#nullable enable
using Content.Server.GameObjects.Components.PA;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class ParticleAcceleratorPartSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
EntityManager.EventBus.SubscribeEvent<RotateEvent>(EventSource.Local, this, RotateEvent);
}
private static void RotateEvent(RotateEvent ev)
{
if (ev.Sender.TryGetComponent(out ParticleAcceleratorPartComponent? part))
{
part.Rotated();
}
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Content.Server.Botany;
using Content.Server.GameObjects.Components.Botany;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
@@ -12,7 +13,7 @@ using Robust.Shared.Prototypes;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class PlantSystem : EntitySystem
public class PlantSystem : EntitySystem, IResettingEntitySystem
{
[Dependency] private readonly IComponentManager _componentManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -29,6 +30,15 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
PopulateDatabase();
}
private void PopulateDatabase()
{
_nextUid = 0;
_seeds.Clear();
foreach (var seed in _prototypeManager.EnumeratePrototypes<Seed>())
{
AddSeedToDatabase(seed);
@@ -66,5 +76,10 @@ namespace Content.Server.GameObjects.EntitySystems
plantHolder.Update();
}
}
public void Reset()
{
PopulateDatabase();
}
}
}

View File

@@ -0,0 +1,41 @@
using Content.Server.GameObjects.Components.Singularity;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
public class SingularitySystem : EntitySystem
{
private float curTimeSingulo;
private float curTimePull;
public override void Update(float frameTime)
{
base.Update(frameTime);
curTimeSingulo += frameTime;
curTimePull += frameTime;
var shouldUpdate = curTimeSingulo >= 1f;
var shouldPull = curTimePull >= 0.2f;
if (!shouldUpdate && !shouldPull) return;
var singulos = ComponentManager.EntityQuery<SingularityComponent>();
if (curTimeSingulo >= 1f)
{
curTimeSingulo -= 1f;
foreach (var singulo in singulos)
{
singulo.Update();
}
}
if (curTimePull >= 0.5f)
{
curTimePull -= 0.5f;
foreach (var singulo in singulos)
{
singulo.PullUpdate();
}
}
}
}
}

View File

@@ -25,12 +25,12 @@ namespace Content.Server.GameObjects.EntitySystems
if (newState != oldState)
{
appearance.SetData(RotationVisuals.RotationState, newState);
}
if (playSound)
{
var file = AudioHelpers.GetRandomFileFromSoundCollection("bodyfall");
Get<AudioSystem>().PlayFromEntity(file, entity, AudioHelpers.WithVariation(0.25f));
if (playSound)
{
var file = AudioHelpers.GetRandomFileFromSoundCollection("bodyfall");
Get<AudioSystem>().PlayFromEntity(file, entity, AudioHelpers.WithVariation(0.25f));
}
}
return true;
@@ -61,5 +61,21 @@ namespace Content.Server.GameObjects.EntitySystems
hands.Drop(heldItem.Owner, doMobChecks);
}
}
//TODO: RotationState can be null and I want to burn all lifeforms in the universe for this!!!
//If you use these it's atleast slightly less painful (null is treated as false)
public bool IsStanding(IEntity entity)
{
return entity.TryGetComponent<AppearanceComponent>(out var appearance)
&& appearance.TryGetData<RotationState>(RotationVisuals.RotationState, out var rotation)
&& rotation == RotationState.Vertical;
}
public bool IsDown(IEntity entity)
{
return entity.TryGetComponent<AppearanceComponent>(out var appearance)
&& appearance.TryGetData<RotationState>(RotationVisuals.RotationState, out var rotation)
&& rotation == RotationState.Horizontal;
}
}
}

View File

@@ -0,0 +1,125 @@
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.Components.Mobs;
using Content.Shared.GameObjects.EntitySystemMessages.Gravity;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Components.Map;
using Robust.Shared.GameObjects.EntitySystemMessages;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Utility;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class WeightlessSystem : EntitySystem, IResettingEntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
private readonly Dictionary<GridId, List<ServerStatusEffectsComponent>> _statuses = new Dictionary<GridId, List<ServerStatusEffectsComponent>>();
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GravityChangedMessage>(GravityChanged);
SubscribeLocalEvent<EntParentChangedMessage>(EntParentChanged);
}
public void Reset()
{
_statuses.Clear();
}
public void AddStatus(ServerStatusEffectsComponent status)
{
var gridId = status.Owner.Transform.GridID;
var statuses = _statuses.GetOrNew(gridId);
statuses.Add(status);
if (_mapManager.TryGetGrid(status.Owner.Transform.GridID, out var grid))
{
if (grid.HasGravity)
{
RemoveWeightless(status);
}
else
{
AddWeightless(status);
}
}
}
public void RemoveStatus(ServerStatusEffectsComponent status)
{
var grid = status.Owner.Transform.GridID;
if (!_statuses.TryGetValue(grid, out var statuses))
{
return;
}
statuses.Remove(status);
}
private void GravityChanged(GravityChangedMessage ev)
{
if (!_statuses.TryGetValue(ev.Grid.Index, out var statuses))
{
return;
}
if (ev.HasGravity)
{
foreach (var status in statuses)
{
RemoveWeightless(status);
}
}
else
{
foreach (var status in statuses)
{
AddWeightless(status);
}
}
}
private void AddWeightless(ServerStatusEffectsComponent status)
{
status.ChangeStatusEffect(StatusEffect.Weightless, "/Textures/Interface/StatusEffects/Weightless/weightless.png", null);
}
private void RemoveWeightless(ServerStatusEffectsComponent status)
{
status.RemoveStatusEffect(StatusEffect.Weightless);
}
private void EntParentChanged(EntParentChangedMessage ev)
{
if (!ev.Entity.TryGetComponent(out ServerStatusEffectsComponent status))
{
return;
}
if (ev.OldParent != null &&
ev.OldParent.TryGetComponent(out IMapGridComponent mapGrid))
{
var oldGrid = mapGrid.GridIndex;
if (_statuses.TryGetValue(oldGrid, out var oldStatuses))
{
oldStatuses.Remove(status);
}
}
var newGrid = ev.Entity.Transform.GridID;
var newStatuses = _statuses.GetOrNew(newGrid);
newStatuses.Add(status);
}
}
}