-
-
Notifications
You must be signed in to change notification settings - Fork 54
Новый крутой режим побега из комплекса #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
RavMorgan
wants to merge
14
commits into
master
Choose a base branch
from
scp-sl-gamemode
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
967b609
Init
eb1e0df
wip
0cf8792
Merge branch 'main' into scp-sl-gamemode
3450263
Merge remote-tracking branch 'origin/master' into scp-sl-gamemode
08f156b
Merge remote-tracking branch 'origin/master' into scp-sl-gamemode
a6b554e
SCP-914 stuff
4f892d3
914 Logic update
6ecac3c
More prikols
2289cfa
Merge remote-tracking branch 'origin/master' into scp-sl-gamemode
d36a9a0
Gamemode stable
7116789
Oopsie Woopsie We Made a Fucky Wucky
1ba482e
Code cleanup
b651075
Fixes
fc691e7
Merge remote-tracking branch 'origin/master' into scp-sl-gamemode
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| using Content.Shared._Scp.Scp914; | ||
|
|
||
| namespace Content.Client._Scp.Scp914; | ||
|
|
||
| public sealed class Scp914System : SharedScp914System | ||
| { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| using Content.Client.Anomaly.Ui; | ||
| using Content.Shared._Scp.Scp914; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Client._Scp.Scp914.Ui; | ||
|
|
||
| public sealed class Scp914BoundUserInterface : BoundUserInterface | ||
| { | ||
| private Scp914Window? _window; | ||
| private IGameTiming _gameTiming; | ||
|
|
||
| public Scp914BoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
| { | ||
|
|
||
| _gameTiming = IoCManager.Resolve<IGameTiming>(); | ||
| } | ||
|
|
||
| protected override void Open() | ||
| { | ||
| base.Open(); | ||
|
|
||
| _window = new Scp914Window(_gameTiming); | ||
| _window.OnClose += Close; | ||
| _window.OnNewModeSelected += OnNewModeSelected; | ||
| _window.OnStartCycle += OnStartCycle; | ||
|
|
||
| if (State != null) | ||
| { | ||
| UpdateState(State); | ||
| } | ||
|
|
||
| _window.OpenCentered(); | ||
| } | ||
|
|
||
| private void OnStartCycle() | ||
| { | ||
| var startCycleMessage = new Scp914StartCycleMessage(); | ||
| SendPredictedMessage(startCycleMessage); | ||
| } | ||
|
|
||
| private void OnNewModeSelected(Scp914CycleDirection direction) | ||
| { | ||
| var changeModeMessage = new Scp914ChangeModeRequestMessage(direction); | ||
| SendPredictedMessage(changeModeMessage); | ||
| } | ||
|
|
||
| protected override void UpdateState(BoundUserInterfaceState state) | ||
| { | ||
| base.UpdateState(state); | ||
|
|
||
| if (state is not Scp914BuiState newState) | ||
| { | ||
| return; | ||
RavMorgan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| _window?.UpdateState(newState); | ||
| } | ||
|
|
||
| protected override void Dispose(bool disposing) | ||
| { | ||
| base.Dispose(disposing); | ||
|
|
||
| if (_window == null) | ||
| { | ||
| return; | ||
RavMorgan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| _window.OnClose -= Close; | ||
| _window.OnNewModeSelected -= OnNewModeSelected; | ||
|
|
||
| _window.Dispose(); | ||
| _window = null; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <ui:FancyWindow xmlns="https://spacestation14.io" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2007/xaml" | ||
| xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls" | ||
| xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
| MinSize="200 150" Resizable="False" Title="SCP 914"> | ||
| <BoxContainer Align="Center" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True"> | ||
| <BoxContainer Orientation="Horizontal" HorizontalAlignment="Center" HorizontalExpand="True"> | ||
| <Button HorizontalAlignment="Left" Name="TurnLeftButton" TextAlign="Center" Text="{Loc scp914-cycle-left-button}" SetSize="35 35"/> | ||
| <Label HorizontalAlignment="Stretch" Name="CurrentModeLabel" Align="Center" HorizontalExpand="True" SetSize="100 25"/> | ||
| <Button HorizontalAlignment="Right" Name="TurnRightButton" TextAlign="Center" Text="{Loc scp914-cycle-right-button}" SetSize="35 35"/> | ||
| </BoxContainer> | ||
| <Button Name="StartCycleBytton" TextAlign="Center" SetHeight="35" HorizontalExpand="True" Text="{Loc scp914-start-cycle}"></Button> | ||
| </BoxContainer> | ||
| </ui:FancyWindow> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| using Content.Client.UserInterface.Controls; | ||
| using Content.Shared._Scp.Scp914; | ||
| using Robust.Client.AutoGenerated; | ||
| using Robust.Client.UserInterface.XAML; | ||
| using Robust.Shared.Timing; | ||
|
|
||
| namespace Content.Client._Scp.Scp914.Ui; | ||
|
|
||
| [GenerateTypedNameReferences] | ||
| public sealed partial class Scp914Window : FancyWindow | ||
| { | ||
| public Action<Scp914CycleDirection>? OnNewModeSelected; | ||
| public Action? OnStartCycle; | ||
|
|
||
| private IGameTiming _gameTiming; | ||
|
|
||
| private TimeSpan _nextTimeUse; | ||
| private bool _active; | ||
|
|
||
| public Scp914Window(IGameTiming gameTiming) | ||
| { | ||
| RobustXamlLoader.Load(this); | ||
|
|
||
| _gameTiming = gameTiming; | ||
|
|
||
| TurnLeftButton.OnPressed += _ => OnTurnLeftPressed(); | ||
| TurnRightButton.OnPressed += _ => OnTurnRightPressed(); | ||
| StartCycleBytton.OnPressed += _ => OnStartCyclePressed(); | ||
| } | ||
|
|
||
| protected override void FrameUpdate(FrameEventArgs args) | ||
| { | ||
| base.FrameUpdate(args); | ||
|
|
||
| var disabled = _active || _gameTiming.CurTime < _nextTimeUse; | ||
|
|
||
| TurnLeftButton.Disabled = disabled; | ||
| TurnRightButton.Disabled = disabled; | ||
| StartCycleBytton.Disabled = disabled; | ||
| } | ||
|
|
||
| public void UpdateState(Scp914BuiState newState) | ||
| { | ||
| CurrentModeLabel.Text = newState.NewMode.ToString(); | ||
| _active = newState.Active; | ||
| } | ||
|
|
||
| private void OnStartCyclePressed() | ||
| { | ||
| OnStartCycle?.Invoke(); | ||
| SetNextTimeUse(); | ||
| } | ||
|
|
||
| private void OnTurnRightPressed() | ||
| { | ||
| OnNewModeSelected?.Invoke(Scp914CycleDirection.Right); | ||
| SetNextTimeUse(); | ||
| } | ||
|
|
||
| private void OnTurnLeftPressed() | ||
| { | ||
| OnNewModeSelected?.Invoke(Scp914CycleDirection.Left); | ||
| SetNextTimeUse(); | ||
| } | ||
|
|
||
| private void SetNextTimeUse() | ||
| { | ||
| _nextTimeUse = _gameTiming.CurTime + TimeSpan.FromSeconds(1); | ||
| } | ||
| } |
138 changes: 138 additions & 0 deletions
138
Content.IntegrationTests/Tests/GameRules/ScpSlGameRuleTest.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| using System.Linq; | ||
| using Content.Server._Scp.GameRules.ScpSl; | ||
| using Content.Server._Sunrise.StationCentComm; | ||
| using Content.Server.GameTicking; | ||
| using Content.Server.GameTicking.Presets; | ||
| using Content.Server.GameTicking.Rules.Components; | ||
| using Content.Server.RoundEnd; | ||
| using Content.Shared._Scp.GameRule.Sl; | ||
| using Content.Shared.GameTicking; | ||
| using Content.Shared.Pinpointer; | ||
| using Content.Shared.Station.Components; | ||
| using Robust.Server.GameObjects; | ||
| using Robust.Shared.GameObjects; | ||
| using Robust.Shared.Map.Components; | ||
|
|
||
| namespace Content.IntegrationTests.Tests.GameRules; | ||
|
|
||
| [TestFixture] | ||
| public sealed class ScpSlGameRuleTest | ||
| { | ||
| [Test] | ||
| public async Task TryStartGameRuleTestWithSufficientPlayers() | ||
| { | ||
| await using var pair = await PoolManager.GetServerClient(new PoolSettings | ||
| { | ||
| Dirty = true, | ||
| DummyTicker = false, | ||
| Connected = true, | ||
| InLobby = true, | ||
| }); | ||
|
|
||
| var server = pair.Server; | ||
| var client = pair.Client; | ||
|
|
||
| var entMan = server.EntMan; | ||
|
|
||
| var ticker = server.System<GameTicker>(); | ||
| var xformSystem = server.System<TransformSystem>(); | ||
| var physicsSystem = server.System<PhysicsSystem>(); | ||
|
|
||
| Assert.That(ticker.DummyTicker, Is.False); | ||
|
|
||
| Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby)); | ||
| Assert.That(client.AttachedEntity, Is.Null); | ||
| Assert.That(ticker.PlayerGameStatuses[client.User!.Value], Is.EqualTo(PlayerGameStatus.NotReadyToPlay)); | ||
|
|
||
| var dummies = await pair.Server.AddDummySessions(30); | ||
|
|
||
| await pair.RunTicksSync(5); | ||
|
|
||
| // Initially, the players have no attached entities | ||
| Assert.That(pair.Player?.AttachedEntity, Is.Null); | ||
| Assert.That(dummies.All(x => x.AttachedEntity == null)); | ||
|
|
||
| Assert.That(entMan.Count<MapComponent>(), Is.Zero); | ||
| Assert.That(entMan.Count<MapGridComponent>(), Is.Zero); | ||
| Assert.That(entMan.Count<StationMapComponent>(), Is.Zero); | ||
| Assert.That(entMan.Count<StationMemberComponent>(), Is.Zero); | ||
| Assert.That(entMan.Count<StationCentCommComponent>(), Is.Zero); // Sunrise-Edit | ||
|
|
||
| // And no sl related components | ||
| Assert.That(entMan.Count<ScpSlGameRuleComponent>(), Is.Zero); | ||
| Assert.That(entMan.Count<ScpSlHumanoidMarkerComponent>(), Is.Zero); | ||
| Assert.That(entMan.Count<ScpSlScpMarkerComponent>(), Is.Zero); | ||
|
|
||
| ticker.ToggleReadyAll(true); | ||
| Assert.That(ticker.PlayerGameStatuses.Values.All(x => x == PlayerGameStatus.ReadyToPlay)); | ||
|
|
||
| await pair.WaitCommand("forcepreset ScpSl"); | ||
| await pair.RunTicksSync(10); | ||
|
|
||
| Assert.That(ticker.RunLevel, Is.EqualTo(GameRunLevel.InRound)); | ||
| Assert.That(ticker.PlayerGameStatuses.Values.All(x => x == PlayerGameStatus.JoinedGame)); | ||
| Assert.That(client.EntMan.EntityExists(client.AttachedEntity)); | ||
|
|
||
| Assert.That(entMan.Count<ScpSlGameRuleComponent>(), Is.EqualTo(1)); | ||
| Assert.That(entMan.Count<ScpSlHumanoidMarkerComponent>, Is.AtLeast(1)); | ||
| Assert.That(entMan.Count<ScpSlScpMarkerComponent>, Is.AtLeast(1)); | ||
|
|
||
|
|
||
| //Try escape | ||
|
|
||
| var (escapeZoneXform, _) = entMan.EntityQuery<TransformComponent, ScpSlEscapeZoneComponent>().First(); | ||
|
|
||
| var chaosBefore = dummies.Count(x => | ||
| entMan.TryGetComponent<ScpSlHumanoidMarkerComponent>(x.AttachedEntity!.Value!, out var marker) && | ||
| marker.HumanoidType == ScpSlHumanoidType.Chaos); | ||
|
|
||
| var dBefore = dummies.Count(x => | ||
| entMan.TryGetComponent<ScpSlHumanoidMarkerComponent>(x.AttachedEntity!.Value!, out var marker) && | ||
| marker.HumanoidType == ScpSlHumanoidType.ClassD); | ||
|
|
||
| var dummyD = dummies | ||
| .First(x => entMan.TryGetComponent<ScpSlHumanoidMarkerComponent>(x.AttachedEntity!.Value!, out var marker) && | ||
| marker.HumanoidType == ScpSlHumanoidType.ClassD) | ||
| .AttachedEntity!.Value!; | ||
|
|
||
| physicsSystem.WakeBody(escapeZoneXform.Owner); | ||
| physicsSystem.WakeBody(dummyD); | ||
|
|
||
| await pair.RunTicksSync(5); | ||
|
|
||
| xformSystem.SetCoordinates(dummyD, escapeZoneXform.Coordinates); | ||
|
|
||
| await pair.RunTicksSync(5); | ||
|
|
||
| var dAfter = dummies.Count(x => | ||
| entMan.TryGetComponent<ScpSlHumanoidMarkerComponent>(x.AttachedEntity!.Value!, out var marker) && | ||
| marker.HumanoidType == ScpSlHumanoidType.ClassD); | ||
|
|
||
| var chaosAfter = dummies.Count(x => | ||
| entMan.TryGetComponent<ScpSlHumanoidMarkerComponent>(x.AttachedEntity!.Value!, out var marker) && | ||
| marker.HumanoidType == ScpSlHumanoidType.Chaos); | ||
|
|
||
|
|
||
| Assert.That(dBefore > dAfter, Is.True); | ||
| Assert.That(chaosBefore < chaosAfter, Is.True); | ||
|
|
||
| // Try end round | ||
| var player = pair.Player!.AttachedEntity!.Value; | ||
|
|
||
| var dummyEntity = dummies.Select(x => x.AttachedEntity ?? default).Append(player).Where(x=> entMan.HasComponent<ScpSlHumanoidMarkerComponent>(x)).ToList(); | ||
|
|
||
| await server.WaitAssertion(() => | ||
| { | ||
| foreach (var entityUid in dummyEntity) | ||
| { | ||
| entMan.DeleteEntity(entityUid); | ||
| } | ||
|
|
||
| }); | ||
|
|
||
| Assert.That(ticker.RunLevel == GameRunLevel.PostRound, Is.True, "All humanoids are dead, but round doesn't end!"); | ||
|
|
||
| ticker.SetGamePreset((GamePresetPrototype?) null); | ||
| await pair.CleanReturnAsync(); | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
Content.Server/_Scp/GameRules/ScpSl/ScpSLGameRuleSystem.Subs.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| namespace Content.Server._Scp.GameRules.ScpSl; | ||
|
|
||
| public sealed partial class ScpSlGameRuleSystem | ||
| { | ||
| private int _maxChaosSpawnCount; | ||
| private int _maxMogSpawnCount; | ||
| private float _chaosSpawnChance; | ||
| private void InitializeSubs() | ||
| { | ||
| _cfg.OnValueChanged(SlCvars.MaxChaosSpawnCount, newValue => _maxChaosSpawnCount = newValue); | ||
| _cfg.OnValueChanged(SlCvars.MaxMogSpawnCount, newValue => _maxMogSpawnCount = newValue); | ||
| _cfg.OnValueChanged(SlCvars.ChaosSpawnChance, newValue => _chaosSpawnChance = newValue); | ||
| } | ||
| } |
25 changes: 25 additions & 0 deletions
25
Content.Server/_Scp/GameRules/ScpSl/ScpSlEscapeZoneComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| using Content.Shared._Scp.GameRule.Sl; | ||
| using Robust.Shared.Prototypes; | ||
|
|
||
| namespace Content.Server._Scp.GameRules.ScpSl; | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class ScpSlEscapeZoneComponent : Component; | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class SlHumanoidSpawnPointComponent : Component | ||
| { | ||
| [DataField(required: true)] | ||
| public ScpSlHumanoidType SpawnPointType { get; private set; } | ||
| } | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class SlScpSpawnPointComponent : Component | ||
| { | ||
| [DataField(required: true)] | ||
| public EntProtoId ScpProtoId { get; private set; } | ||
|
|
||
| [DataField] | ||
| public bool Playable { get; private set; } = true; | ||
| } | ||
|
|
46 changes: 46 additions & 0 deletions
46
Content.Server/_Scp/GameRules/ScpSl/ScpSlGameRuleComponent.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| using Content.Shared._Scp.GameRule.Sl; | ||
| using Content.Shared.Humanoid.Prototypes; | ||
| using Robust.Shared.Map.Components; | ||
| using Robust.Shared.Prototypes; | ||
|
|
||
| namespace Content.Server._Scp.GameRules.ScpSl; | ||
|
|
||
| [RegisterComponent] | ||
| public sealed partial class ScpSlGameRuleComponent : Component | ||
| { | ||
|
|
||
| [DataField(required: true)] | ||
| public Dictionary<ScpSlHumanoidType, List<ProtoId<RandomHumanoidSettingsPrototype>>> HumanoidPresets { get; private set; } = new(); | ||
|
|
||
| public Dictionary<SlZoneType, Entity<MapGridComponent>> Zones { get; private set; } = new(); | ||
|
|
||
| [DataField(required: true)] | ||
| public ProtoId<RandomHumanoidSettingsPrototype> MogCaptainPrototype { get; set; } | ||
|
|
||
| [DataField, ViewVariables(VVAccess.ReadWrite)] | ||
| public TimeSpan WaveSpawnCooldown { get; set; } = TimeSpan.FromSeconds(300); | ||
|
|
||
| public TimeSpan NextWaveSpawnTime { get; set; } | ||
|
|
||
| public int EscapedScientists = 0; | ||
| public int EscapedDClass = 0; | ||
|
|
||
| public int ContainedScps = 0; | ||
|
|
||
| public SlWinType WinType = SlWinType.Tie; | ||
| } | ||
|
|
||
| public enum SlWinType : byte | ||
| { | ||
| FondWin = 0, | ||
| Tie = 1, | ||
| ScpWin = 2, | ||
| ChaosWin = 3 | ||
| } | ||
|
|
||
| public enum SlZoneType | ||
| { | ||
| Light, | ||
| Hard, | ||
| Office | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.