Мозговой Червь (#17)

* - add: Added Cortic Borer.

* - fix: Removed unnecessary imports, unused fields, variables, methods.

* - fix: Изменён принцип вселения: теперь не создаётся новый энтити с переходом разума, вместо этого хост хранит в себе контейнер для червя, в который последний и погружается

* - fix: Убрано использование устаревших методов и полей, исправлена ошибка, из-за которой при вселении в носителя уровень сахара не проверялся

* - fix: Изменено тестировочное значение добавления очков химикатов

* - fix: Borer can't speak now

* - fix: Some bug and shitcode fixes

* - fix: Some bug and shitcode fixes

* - fix: Added cooldown after releasing the humanoid's body

* - fix: fix

* - add: Added russian localization

* - add: Убрал использование метода _chatManager.ChatMessageToOne в некоторых местах, т.к. popup включает в себя вывод сообщения в чат.

* - fix: fix

* - fix: fix
This commit is contained in:
Ogunefu
2024-02-03 20:31:56 +03:00
committed by GitHub
parent 1594dff648
commit ff26505b11
39 changed files with 1630 additions and 3 deletions

View File

@@ -0,0 +1,55 @@
using System.Numerics;
using Content.Shared.Borer;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Shared.Enums;
namespace Content.Client.Borer;
public sealed class BorerOverlay : Overlay
{
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
[Dependency] private readonly IResourceCache _client = default!;
private IPlayerManager _playerManager;
private IEntityManager _entManager;
private Font _font;
private Texture _chemBackground;
int points;
float X, Y;
public BorerOverlay(IEntityManager entManager, IPlayerManager playerManager, IResourceCache client)
{
_entManager = entManager;
_playerManager = playerManager;
_client = client;
_font = new VectorFont(_client.GetResource<FontResource>("/Fonts/Boxfont-round/Boxfont Round.ttf"), 30);
_chemBackground = _client.GetResource<TextureResource>("/Textures/Interface/Borer/chem_bg.png");
}
protected override void Draw(in OverlayDrawArgs args)
{
var localPlayer = _playerManager.LocalEntity;
if (_entManager.TryGetComponent(localPlayer, out BorerComponent? borComp))
points = borComp.Points;
else if (_entManager.TryGetComponent(localPlayer, out InfestedBorerComponent? infestedComp))
{
if (infestedComp.ControllingBrain)
return;
points = infestedComp.Points;
}
else
return;
if (args.ViewportControl != null)
{
X = (args.ViewportControl.Window!.Size.X / 2f) - 32;
Y = args.ViewportControl.Window!.Size.Y - 130f;
}
var screenHandle = args.ScreenHandle;
screenHandle.DrawTextureRect(_chemBackground, new UIBox2(new Vector2(X,Y), new Vector2(X+128f,Y+128f)));
screenHandle.DrawString(_font, new Vector2(X+18, Y+42), points.ToString(), new Color(30, 200, 30));
}
}

View File

@@ -0,0 +1,60 @@
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.Borer;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
namespace Content.Client.Borer;
public sealed class BorerScannerUIController : UIController
{
[Dependency] private readonly GameplayStateLoadController _gameplayStateLoad = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private ScannerWindow? _window;
public override void Initialize()
{
base.Initialize();
_gameplayStateLoad.OnScreenLoad += LoadGui;
_gameplayStateLoad.OnScreenUnload += UnloadGui;
SubscribeNetworkEvent<BorerScanDoAfterEvent>(OpenWindow);
}
private void LoadGui()
{
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<ScannerWindow>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
}
private void UnloadGui()
{
if (_window != null)
{
_window.Dispose();
_window = null;
}
}
private void OpenWindow(BorerScanDoAfterEvent msg, EntitySessionEventArgs args)
{
var ent = _playerManager.LocalEntity;
if (_window == null || _window.IsOpen || ent != args.SenderSession.AttachedEntity)
return;
_window.SolutionContainer.DisposeAllChildren();
foreach (var reagent in msg.Solution)
{
var reagLabel = new Label();
reagLabel.Text = reagent.Key + " - " + reagent.Value + "u";
_window.SolutionContainer.Children.Add(reagLabel);
}
_window.Open();
}
}

View File

@@ -0,0 +1,31 @@
using Content.Shared.Borer;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
namespace Content.Client.Borer;
/// <summary>
/// This handles...
/// </summary>
public sealed class ClientBorerSystem : EntitySystem
{
[Dependency] private readonly IResourceCache _client = default!;
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IOverlayManager _overlayManager = default!;
[Dependency] private readonly IPlayerManager _playerMgr = default!;
public override void Initialize()
{
SubscribeNetworkEvent<BorerOverlayResponceEvent>(OnOverlayResponce);
}
private void OnOverlayResponce(BorerOverlayResponceEvent ev)
{
if(!_overlayManager.HasOverlay<BorerOverlay>())
_overlayManager.AddOverlay(new BorerOverlay(
_entManager,
_playerMgr,
_client));
}
}

View File

@@ -0,0 +1,110 @@
using Content.Client.Actions;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Systems.Actions;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Shared.Actions;
using Content.Shared.Borer;
using Content.Shared.Input;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input.Binding;
using Robust.Shared.Utility;
namespace Content.Client.Borer;
public sealed class ReagentUIController : UIController, IOnSystemChanged<ActionsSystem>, IOnStateEntered<GameplayState>
{
[Dependency] private readonly GameplayStateLoadController _gameplayStateLoad = default!;
[UISystemDependency] private readonly SharedBorerSystem _borerSystem = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private ReagentWindow? _window;
private bool _reagentsLoaded = false;
public override void Initialize()
{
base.Initialize();
_gameplayStateLoad.OnScreenLoad += LoadGui;
_gameplayStateLoad.OnScreenUnload += UnloadGui;
SubscribeLocalEvent<BorerInjectWindowOpenEvent>(ev =>
{
OpenWindow();
});
}
private void LoadGui()
{
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<ReagentWindow>();
LayoutContainer.SetAnchorPreset(_window, LayoutContainer.LayoutPreset.CenterTop);
}
private void UnloadGui()
{
if (_window != null)
{
_window.Dispose();
_window = null;
}
}
private void OnInjectReagent(string protoId, int cost)
{
_borerSystem.RaiseInjectEvent(protoId, cost);
}
private void OpenWindow()
{
var ent = _playerManager.LocalEntity;
if (_window == null || _window.IsOpen || !ent.HasValue)
return;
if (!_reagentsLoaded)
{
foreach (var reagent in _borerSystem.GetReagents(ent.Value))
{
var button = new Button();
button.Text = Loc.GetString("borer-ui-secrete-inject-label",
("reagent",Loc.GetString("reagent-name-"+
reagent.Key.ToLower().Replace("spacedrugs", "space-drugs"))),
("cost", reagent.Value));
button.OnPressed += _ => OnInjectReagent(reagent.Key, reagent.Value);
_window.MainContainer.AddChild(button);
}
_reagentsLoaded = true;
}
_window.Open();
}
public void OnSystemLoaded(ActionsSystem system)
{
system.LinkActions += OnComponentLinked;
}
public void OnSystemUnloaded(ActionsSystem system)
{
system.LinkActions -= OnComponentLinked;
}
private void OnComponentLinked(ActionsComponent component)
{
}
public void OnStateEntered(GameplayState state)
{
CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenActionsMenu, InputCmdHandler.FromDelegate(_ => OpenWindow()))
.Register<ReagentWindow>();
}
public void OnStateExited(GameplayState state)
{
CommandBinds.Unregister<ReagentWindow>();
}
}

View File

@@ -0,0 +1,15 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Borer;
[GenerateTypedNameReferences]
public sealed partial class ReagentWindow : DefaultWindow
{
public ReagentWindow()
{
RobustXamlLoader.Load(this);
}
}

View File

@@ -0,0 +1,13 @@
<windows:ReagentWindow
xmlns="https://spacestation14.io"
xmlns:windows="clr-namespace:Content.Client.Borer"
Name="AvailableReagents"
HorizontalExpand="True"
Title="Reagents"
VerticalExpand="True"
Resizable="True"
MinHeight="300"
MinWidth="300">
<BoxContainer Name="MainContainer" Orientation="Vertical" SeparationOverride="4" MinWidth="150" Access="Public">
</BoxContainer>
</windows:ReagentWindow>

View File

@@ -0,0 +1,16 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Borer;
[GenerateTypedNameReferences]
public sealed partial class ScannerWindow : DefaultWindow
{
public ScannerWindow()
{
RobustXamlLoader.Load(this);
}
}

View File

@@ -0,0 +1,17 @@
<windows:ScannerWindow
xmlns="https://spacestation14.io"
xmlns:windows="clr-namespace:Content.Client.Borer"
Name="AvailableReagents"
HorizontalExpand="True"
Title="{Loc 'borer-ui-scan-title'}"
VerticalExpand="True"
Resizable="True"
MinHeight="300"
MinWidth="300">
<BoxContainer Name="MainContainer" Orientation="Vertical" SeparationOverride="4" MinWidth="150">
<Label FontColorOverride="#55FF55" HorizontalAlignment="Center" Text="{Loc 'borer-ui-scan-label'}"/>
<BoxContainer Name="SolutionContainer" Orientation="Vertical" SeparationOverride="4" MinWidth="150" Access="Public">
</BoxContainer>
</BoxContainer>
</windows:ScannerWindow>