Skip to content
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

Update 12/22/2024 #120

Closed
wants to merge 12 commits into from
32 changes: 19 additions & 13 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public HumanoidProfileEditor(
IPlayerManager playerManager,
IPrototypeManager prototypeManager,
JobRequirementsManager requirements,
MarkingManager markings)
MarkingManager markings
)
{
RobustXamlLoader.Load(this);
_cfgManager = cfgManager;
Expand All @@ -114,7 +115,8 @@ public HumanoidProfileEditor(
SaveButton.OnPressed += args => { Save?.Invoke(); };
ResetButton.OnPressed += args =>
{
SetProfile((HumanoidCharacterProfile?) _preferencesManager.Preferences?.SelectedCharacter,
SetProfile(
(HumanoidCharacterProfile?) _preferencesManager.Preferences?.SelectedCharacter,
_preferencesManager.Preferences?.SelectedCharacterIndex);
};

Expand Down Expand Up @@ -193,12 +195,11 @@ public HumanoidProfileEditor(

#endregion Species

#region Height
#region Height and Width

var prototype = _species.Find(x => x.ID == Profile?.Species) ?? _species.First();

UpdateHeightWidthSliders();
UpdateDimensions(SliderUpdate.Both);

HeightSlider.OnValueChanged += _ => UpdateDimensions(SliderUpdate.Height);
WidthSlider.OnValueChanged += _ => UpdateDimensions(SliderUpdate.Width);
Expand Down Expand Up @@ -492,7 +493,7 @@ public void RefreshFlavorText()
if (_flavorText != null)
return;

_flavorText = new FlavorText.FlavorText();
_flavorText = new();
_flavorText.OnFlavorTextChanged += OnFlavorTextChange;
_flavorTextEdit = _flavorText.CFlavorTextInput;
CTabContainer.AddTab(_flavorText, Loc.GetString("humanoid-profile-editor-flavortext-tab"));
Expand Down Expand Up @@ -763,11 +764,11 @@ public void RefreshJobs()
foreach (var job in jobs)
{
var jobContainer = new BoxContainer { Orientation = LayoutOrientation.Horizontal, };
var selector = new RequirementsSelector { Margin = new Thickness(3f, 3f, 3f, 0f) };
var selector = new RequirementsSelector { Margin = new(3f, 3f, 3f, 0f) };

var icon = new TextureRect
{
TextureScale = new Vector2(2, 2),
TextureScale = new(2, 2),
VerticalAlignment = VAlignment.Center
};
var jobIcon = _prototypeManager.Index<StatusIconPrototype>(job.Icon);
Expand Down Expand Up @@ -1349,21 +1350,26 @@ private void UpdateSpawnPriorityControls()

private void UpdateHeightWidthSliders()
{
if (Profile is null)
return;

var species = _species.Find(x => x.ID == Profile?.Species) ?? _species.First();

HeightSlider.MinValue = species.MinHeight;
HeightSlider.MaxValue = species.MaxHeight;
HeightSlider.Value = Profile?.Height ?? species.DefaultHeight;
HeightSlider.SetValueWithoutEvent(Profile?.Height ?? species.DefaultHeight);

WidthSlider.MinValue = species.MinWidth;
WidthSlider.MaxValue = species.MaxWidth;
WidthSlider.Value = Profile?.Width ?? species.DefaultWidth;
WidthSlider.SetValueWithoutEvent(Profile?.Width ?? species.DefaultWidth);

var height = MathF.Round(species.AverageHeight * HeightSlider.Value);
HeightLabel.Text = Loc.GetString("humanoid-profile-editor-height-label", ("height", (int) height));

var width = MathF.Round(species.AverageWidth * WidthSlider.Value);
WidthLabel.Text = Loc.GetString("humanoid-profile-editor-width-label", ("width", (int) width));

UpdateDimensions(SliderUpdate.Both);
}

private enum SliderUpdate
Expand All @@ -1375,9 +1381,10 @@ private enum SliderUpdate

private void UpdateDimensions(SliderUpdate updateType)
{
var species = _species.Find(x => x.ID == Profile?.Species) ?? _species.First();
if (Profile == null)
return;

if (Profile == null) return;
var species = _species.Find(x => x.ID == Profile?.Species) ?? _species.First();

var heightValue = Math.Clamp(HeightSlider.Value, species.MinHeight, species.MaxHeight);
var widthValue = Math.Clamp(WidthSlider.Value, species.MinWidth, species.MaxWidth);
Expand All @@ -1386,13 +1393,12 @@ private void UpdateDimensions(SliderUpdate updateType)

if (updateType == SliderUpdate.Height || updateType == SliderUpdate.Both)
if (ratio < 1 / sizeRatio || ratio > sizeRatio)
widthValue = heightValue / (ratio < 1 / sizeRatio ? (1 / sizeRatio) : sizeRatio);
widthValue = heightValue * (ratio < 1 / sizeRatio ? (1 / sizeRatio) : sizeRatio);

if (updateType == SliderUpdate.Width || updateType == SliderUpdate.Both)
if (ratio < 1 / sizeRatio || ratio > sizeRatio)
heightValue = widthValue * (ratio < 1 / sizeRatio ? (1 / sizeRatio) : sizeRatio);


heightValue = Math.Clamp(heightValue, species.MinHeight, species.MaxHeight);
widthValue = Math.Clamp(widthValue, species.MinWidth, species.MaxWidth);

Expand Down
26 changes: 24 additions & 2 deletions Content.Client/MainMenu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Robust.Client.UserInterface.Controls;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Network;
using Robust.Shared.Utility;
using UsernameHelpers = Robust.Shared.AuthLib.UsernameHelpers;
Expand All @@ -25,9 +26,11 @@ public sealed class MainScreen : Robust.Client.State.State
[Dependency] private readonly IGameController _controllerProxy = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IConsoleHost _console = default!;

private MainMenuControl _mainMenuControl = default!;
private bool _isConnecting;
private bool _shouldGoLobby;

// ReSharper disable once InconsistentNaming
private static readonly Regex IPv6Regex = new(@"\[(.*:.*:.*)](?::(\d+))?");
Expand All @@ -38,15 +41,27 @@ protected override void Startup()
_mainMenuControl = new MainMenuControl(_resourceCache, _configurationManager);
_userInterfaceManager.StateRoot.AddChild(_mainMenuControl);

_client.PlayerJoinedGame += OnPlayerJoinedGame;

_mainMenuControl.QuitButton.OnPressed += QuitButtonPressed;
_mainMenuControl.OptionsButton.OnPressed += OptionsButtonPressed;
_mainMenuControl.DirectConnectButton.OnPressed += DirectConnectButtonPressed;
_mainMenuControl.GoToLobbyButton.OnPressed += GoToLobbyButtonPressed;
_mainMenuControl.AddressBox.OnTextEntered += AddressBoxEntered;
_mainMenuControl.ChangelogButton.OnPressed += ChangelogButtonPressed;

_client.RunLevelChanged += RunLevelChanged;
}

private void OnPlayerJoinedGame(object? sender, PlayerEventArgs e)
{
if (_shouldGoLobby)
{
_console.ExecuteCommand("golobby");
_shouldGoLobby = false;
}
}

/// <inheritdoc />
protected override void Shutdown()
{
Expand Down Expand Up @@ -77,12 +92,18 @@ private void DirectConnectButtonPressed(BaseButton.ButtonEventArgs args)
TryConnect(input.Text);
}

private void GoToLobbyButtonPressed(BaseButton.ButtonEventArgs obj)
{
var input = _mainMenuControl.AddressBox;
TryConnect(input.Text);

_shouldGoLobby = true;
}

private void AddressBoxEntered(LineEdit.LineEditEventArgs args)
{
if (_isConnecting)
{
return;
}

TryConnect(args.Text);
}
Expand Down Expand Up @@ -185,6 +206,7 @@ private void _setConnectingState(bool state)
{
_isConnecting = state;
_mainMenuControl.DirectConnectButton.Disabled = state;
_mainMenuControl.GoToLobbyButton.Disabled = state;
}
}
}
5 changes: 5 additions & 0 deletions Content.Client/MainMenu/UI/MainMenuControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
Text="{Loc 'main-menu-direct-connect-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<Button Name="GoToLobbyButton"
Access="Public"
Text="{Loc 'main-menu-go-lobby-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu"/>
<Button Name="OptionsButton"
Access="Public"
Text="{Loc 'main-menu-options-button'}"
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public SalvageMagnetBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner
protected override void Open()
{
base.Open();
_window = new OfferingWindow();

_window = this.CreateWindow<OfferingWindow>();
_window.Title = Loc.GetString("salvage-magnet-window-title");
_window.OnClose += Close;
_window.OpenCenteredLeft();
}

Expand Down
44 changes: 43 additions & 1 deletion Content.Server/Abilities/Psionics/PsionicAbilitiesSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Abilities.Psionics;
using Content.Shared.Actions;
using Content.Shared.Popups;
using Content.Shared.Chat;
using Content.Shared.Psionics.Glimmer;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
Expand All @@ -12,7 +13,12 @@
using System.Linq;
using Robust.Server.Player;
using Content.Server.Chat.Managers;

using Robust.Shared.Configuration;
using Content.Shared.CCVar;
using Content.Server.NPC.Systems;
using Content.Server.NPC.HTN;
using Content.Server.Ghost;
using Content.Server.Mind;
namespace Content.Server.Abilities.Psionics
{
public sealed class PsionicAbilitiesSystem : EntitySystem
Expand All @@ -29,6 +35,10 @@ public sealed class PsionicAbilitiesSystem : EntitySystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly PsionicFamiliarSystem _psionicFamiliar = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly MindSystem _mind = default!;

private ProtoId<WeightedRandomPrototype> _pool = "RandomPsionicPowerPool";
private const string GenericInitializationMessage = "generic-power-initialization-feedback";
Expand Down Expand Up @@ -178,7 +188,39 @@ public void RefreshPsionicModifiers(EntityUid uid)
/// </summary>
public void MindBreak(EntityUid uid)
{
if (!HasComp<PsionicComponent>(uid))
return;

RemoveAllPsionicPowers(uid, true);
if (_config.GetCVar(CCVars.ScarierMindbreaking))
ScarierMindbreak(uid);
}

/// <summary>
/// An even more advanced form of Mindbreaking. Turn the victim into an NPC.
/// For the people who somehow didn't intuit from the absolutely horrifying text that mindbreaking people is very fucking bad.
/// </summary>
public void ScarierMindbreak(EntityUid uid)
{
if (!_playerManager.TryGetSessionByEntity(uid, out var session) || session is null)
return;

var feedbackMessage = $"[font size=24][color=#ff0000]{"Your characters personhood has been obliterated. If you wish to continue playing, consider respawning as a new character."}[/color][/font]";
_chatManager.ChatMessageToOne(
ChatChannel.Emotes,
feedbackMessage,
feedbackMessage,
EntityUid.Invalid,
false,
session.Channel);

if (!_mind.TryGetMind(session, out var mindId, out var mind))
return;

_ghost.SpawnGhost((mindId, mind), Transform(uid).Coordinates, false);
_npcFaction.AddFaction(uid, "SimpleNeutral");
var htn = EnsureComp<HTNComponent>(uid);
htn.RootTask = new HTNCompoundTask() { Task = "IdleCompound" };
}

/// <summary>
Expand Down
30 changes: 30 additions & 0 deletions Content.Server/Clothing/Systems/LoadoutSystem.Functions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using JetBrains.Annotations;
using Robust.Shared.Serialization.Manager;
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Server.NPC.Components;
using Content.Server.NPC.Systems;
using Content.Server.NPC.HTN;
using Content.Server.NPC;
using Robust.Shared.Map;
using System.Numerics;

namespace Content.Server.Clothing.Systems;

[UsedImplicitly]
public sealed partial class LoadoutMakeFollower : LoadoutFunction
{
public override void OnPlayerSpawn(EntityUid character,
EntityUid loadoutEntity,
IComponentFactory factory,
IEntityManager entityManager,
ISerializationManager serializationManager)
{
var npc = entityManager.System<NPCSystem>();
var htn = entityManager.System<HTNSystem>();
if (!entityManager.TryGetComponent<HTNComponent>(loadoutEntity, out var hTNComponent))
return;

npc.SetBlackboard(loadoutEntity, NPCBlackboard.FollowTarget, new EntityCoordinates(character, Vector2.Zero), hTNComponent);
htn.Replan(hTNComponent);
}
}
5 changes: 4 additions & 1 deletion Content.Server/Clothing/Systems/LoadoutSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Content.Shared.Storage;
using Content.Shared.Storage.EntitySystems;
using Content.Shared.Traits.Assorted.Components;
using Content.Shared.Whitelist;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
Expand All @@ -33,6 +32,7 @@ public sealed class LoadoutSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;


public override void Initialize()
Expand Down Expand Up @@ -103,6 +103,9 @@ public void ApplyCharacterLoadout(
comp.Owner = loadout.Item1;
EntityManager.AddComponent(loadout.Item1, comp);
}

foreach (var function in loadoutProto.Functions)
function.OnPlayerSpawn(uid, loadout.Item1, _componentFactory, EntityManager, _serialization);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,9 @@ public void RemoveItem(EntityUid uid, EntityUid mech, EntityUid toRemove, MechGr
var xform = Transform(toRemove);
_transform.AttachToGridOrMap(toRemove, xform);
var (mechPos, mechRot) = _transform.GetWorldPositionRotation(mechxform);
var toRemoveWorldPos = _transform.GetWorldPosition(xform);

var offset = mechPos + mechRot.RotateVec(component.DepositOffset);
_transform.SetWorldPositionRotation(toRemove, toRemoveWorldPos + offset, Angle.Zero);
_transform.SetWorldPositionRotation(toRemove, offset, Angle.Zero);
_mech.UpdateUserInterface(mech);
}

Expand Down Expand Up @@ -157,7 +156,7 @@ private void OnInteract(EntityUid uid, MechGrabberComponent component, UserActiv

args.Handled = true;
var audio = _audio.PlayPvs(component.GrabSound, uid);

if (audio == null)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Effect(ReagentEffectArgs args)

var psySys = args.EntityManager.EntitySysManager.GetEntitySystem<PsionicAbilitiesSystem>();

psySys.RemoveAllPsionicPowers(args.SolutionEntity, true);
psySys.MindBreak(args.SolutionEntity);
}
}
}
5 changes: 0 additions & 5 deletions Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,6 @@ private void SetupArrivalsStation()
{
var template = _random.Pick(_arrivalsBiomeOptions);
_biomes.EnsurePlanet(mapUid, _protoManager.Index(template));
var restricted = new RestrictedRangeComponent
{
Range = 32f
};
AddComp(mapUid, restricted);
}

_mapManager.DoMapInitialize(mapId);
Expand Down
Loading
Loading