Merge branch 'master' into prediction

This commit is contained in:
Pieter-Jan Briers
2020-04-18 14:07:02 +02:00
237 changed files with 4278 additions and 1948 deletions

View File

@@ -5,23 +5,23 @@ namespace Content.Server.GameObjects.EntitySystems
{
public interface IActionBlocker
{
bool CanMove();
bool CanMove() => true;
bool CanInteract();
bool CanInteract() => true;
bool CanUse();
bool CanUse() => true;
bool CanThrow();
bool CanThrow() => true;
bool CanSpeak();
bool CanSpeak() => true;
bool CanDrop();
bool CanDrop() => true;
bool CanPickup();
bool CanPickup() => true;
bool CanEmote();
bool CanEmote() => true;
bool CanAttack();
bool CanAttack() => true;
}
public class ActionBlockerSystem : EntitySystem

View File

@@ -0,0 +1,42 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
{
/// <summary>
/// This interface gives components behavior on whether entities solution (implying SolutionComponent is in place) is changed
/// </summary>
public interface ISolutionChange
{
/// <summary>
/// Called when solution is mixed with some other solution, or when some part of the solution is removed
/// </summary>
void SolutionChanged(SolutionChangeEventArgs eventArgs);
}
public class SolutionChangeEventArgs : EventArgs
{
public IEntity Owner { get; set; }
}
[UsedImplicitly]
public class ChemistrySystem : EntitySystem
{
public void HandleSolutionChange(IEntity owner)
{
var eventArgs = new SolutionChangeEventArgs
{
Owner = owner,
};
var solutionChangeArgs = owner.GetAllComponents<ISolutionChange>().ToList();
foreach (var solutionChangeArg in solutionChangeArgs)
{
solutionChangeArg.SolutionChanged(eventArgs);
}
}
}
}

View File

@@ -3,18 +3,22 @@ using Content.Server.GameObjects.Components.Mobs;
using Content.Server.GameObjects.Components.Movement;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.Interfaces.GameObjects.Components.Movement;
using Content.Server.Observer;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Inventory;
using Content.Shared.Maps;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Server.Interfaces.Timing;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.GameObjects.Components;
using Robust.Shared.Interfaces.Map;
@@ -23,6 +27,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Network;
using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -38,6 +43,7 @@ namespace Content.Server.GameObjects.EntitySystems
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager;
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IRobustRandom _robustRandom;
[Dependency] private readonly IConfigurationManager _configurationManager;
#pragma warning restore 649
private AudioSystem _audioSystem;
@@ -78,6 +84,8 @@ namespace Content.Server.GameObjects.EntitySystems
SubscribeLocalEvent<PlayerDetachedSystemMessage>(PlayerDetached);
_audioSystem = EntitySystemManager.GetEntitySystem<AudioSystem>();
_configurationManager.RegisterCVar("game.diagonalmovement", true, CVar.ARCHIVE);
}
private static void PlayerAttached(PlayerAttachSystemMessage ev)
@@ -133,6 +141,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
if (physics.LinearVelocity != Vector2.Zero)
physics.LinearVelocity = Vector2.Zero;
}
else
{
@@ -177,9 +186,20 @@ namespace Content.Server.GameObjects.EntitySystems
private static void HandleDirChange(ICommonSession session, Direction dir, bool state)
{
if (!TryGetAttachedComponent(session as IPlayerSession, out IMoverComponent moverComp))
var playerSes = session as IPlayerSession;
if (!TryGetAttachedComponent(playerSes, out IMoverComponent moverComp))
return;
var owner = playerSes?.AttachedEntity;
if (owner != null)
{
foreach (var comp in owner.GetAllComponents<IRelayMoveInput>())
{
comp.MoveInputPressed(playerSes);
}
}
moverComp.SetVelocityDirection(dir, state);
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Threading;
using Content.Server.Interfaces.GameTicking;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Timer = Robust.Shared.Timers.Timer;
namespace Content.Server.GameObjects.EntitySystems
{
public class RoundEndSystem : EntitySystem
{
#pragma warning disable 649
[Dependency] private IGameTicker _gameTicker;
[Dependency] private IGameTiming _gameTiming;
#pragma warning restore 649
private CancellationTokenSource _roundEndCancellationTokenSource = new CancellationTokenSource();
public bool IsRoundEndCountdownStarted { get; private set; }
public TimeSpan RoundEndCountdownTime { get; set; } = TimeSpan.FromMinutes(4);
public TimeSpan? ExpectedCountdownEnd = null;
public delegate void RoundEndCountdownStarted();
public event RoundEndCountdownStarted OnRoundEndCountdownStarted;
public delegate void RoundEndCountdownCancelled();
public event RoundEndCountdownCancelled OnRoundEndCountdownCancelled;
public delegate void RoundEndCountdownFinished();
public event RoundEndCountdownFinished OnRoundEndCountdownFinished;
public void RequestRoundEnd()
{
if (IsRoundEndCountdownStarted)
return;
IsRoundEndCountdownStarted = true;
ExpectedCountdownEnd = _gameTiming.CurTime + RoundEndCountdownTime;
Timer.Spawn(RoundEndCountdownTime, EndRound, _roundEndCancellationTokenSource.Token);
OnRoundEndCountdownStarted?.Invoke();
}
public void CancelRoundEndCountdown()
{
if (!IsRoundEndCountdownStarted)
return;
IsRoundEndCountdownStarted = false;
_roundEndCancellationTokenSource.Cancel();
_roundEndCancellationTokenSource = new CancellationTokenSource();
ExpectedCountdownEnd = null;
OnRoundEndCountdownCancelled?.Invoke();
}
private void EndRound()
{
OnRoundEndCountdownFinished?.Invoke();
_gameTicker.EndRound();
}
}
}