Skip to content

Commit 6d8fc12

Browse files
committed
Merge remote-tracking branch 'origin/master' into upstream_update_181123
2 parents d5bd4b2 + ccb405d commit 6d8fc12

File tree

1,343 files changed

+20981
-993
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,343 files changed

+20981
-993
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/Content.*/Nuclear14/* @Peptide90 @Partmedia @Cheackraze
22
/.github/ @Partmedia
33

4-
/Resources/Prototypes/Nuclear14/* @Peptide90 @Just-a-Unity-Dev
4+
/Resources/Prototypes/Nuclear14/* @Peptide90
55
/Resources/Textures/Nuclear14/* @Peptide90
66

77
# Sorting by path instead of by who added it one day :(

Content.Client/Lobby/LobbyState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected override void Startup()
6565

6666
_characterSetup.SaveButton.OnPressed += _ =>
6767
{
68-
_characterSetup.Save();
68+
// _characterSetup.Save(); //Nuclear14 workaround to prevent saving using this button, as I can't make it disable dependent on Special points
6969
_lobby.CharacterPreview.UpdateUI();
7070
};
7171

Content.Client/Preferences/UI/HumanoidProfileEditor.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,14 @@
141141
<humanoid:MarkingPicker Name="CMarkings" IgnoreCategories="Hair,FacialHair" />
142142
</ScrollContainer>
143143
</BoxContainer>
144+
<BoxContainer Orientation="Vertical">
145+
<!-- Specials -->
146+
<Label Name="SpecialPointsLabel" HorizontalAlignment="Stretch" Align="Center" />
147+
<ProgressBar Name="SpecialPointsBar" MaxValue="1" Value="1" MinHeight="20" MaxHeight="30" Margin="0 5 0 5" />
148+
<ScrollContainer VerticalExpand="True">
149+
<BoxContainer Name="CSpecialList" Orientation="Vertical" />
150+
</ScrollContainer>
151+
</BoxContainer>
144152
</TabContainer>
145153
</BoxContainer>
146154
<!-- Right side -->

Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
using Robust.Shared.Utility;
3434
using static Robust.Client.UserInterface.Controls.BoxContainer;
3535
using Direction = Robust.Shared.Maths.Direction;
36+
using Content.Shared.Nuclear14.Special;
37+
using Content.Shared.Nuclear14.CCVar;
3638

3739
namespace Content.Client.Preferences.UI
3840
{
@@ -78,9 +80,13 @@ public sealed partial class HumanoidProfileEditor : Control
7880

7981
private TabContainer _tabContainer => CTabContainer;
8082
private BoxContainer _jobList => CJobList;
83+
private Label _specialPointsLabel => SpecialPointsLabel; // Nuclear14 special bar points label
84+
private ProgressBar _specialPointsBar => SpecialPointsBar; // Nuclear14 The above labels' names are referencing their position relative to this element
85+
private BoxContainer _specialList => CSpecialList; // Nuclear14 Special list
8186
private BoxContainer _antagList => CAntagList;
8287
private BoxContainer _traitsList => CTraitsList;
8388
private readonly List<JobPrioritySelector> _jobPriorities;
89+
private readonly List<SpecialPrioritySelector> _specialPriorities; // Nuclear14 User special choice
8490
private OptionButton _preferenceUnavailableButton => CPreferenceUnavailableButton;
8591
private readonly Dictionary<string, BoxContainer> _jobCategories;
8692
// Mildly hacky, as I don't trust prototype order to stay consistent and don't want the UI to break should a new one get added mid-edit. --moony
@@ -384,6 +390,16 @@ public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IProt
384390

385391
#endregion Jobs
386392

393+
// Nuclear14 Special
394+
#region Specials
395+
396+
_tabContainer.SetTabTitle(5, Loc.GetString("humanoid-profile-editor-specials-tab"));
397+
_specialPriorities = new List<SpecialPrioritySelector>();
398+
UpdateSpecialRequirements();
399+
400+
#endregion Specials
401+
// Nuclear14 end
402+
387403
#region Antags
388404

389405
_tabContainer.SetTabTitle(2, Loc.GetString("humanoid-profile-editor-antags-tab"));
@@ -607,6 +623,57 @@ private void UpdateRoleRequirements()
607623
}
608624
}
609625

626+
// Nuclear14 update Special select requirments
627+
private void UpdateSpecialRequirements()
628+
{
629+
_specialList.DisposeAllChildren();
630+
_specialPriorities.Clear();
631+
632+
var points = _configurationManager.GetCVar(SpecialCCVars.MaxSpecial);
633+
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-loadouts-points-label", ("points", points), ("max", points));
634+
_specialPointsBar.MaxValue = points;
635+
_specialPointsBar.Value = points;
636+
637+
638+
foreach (var special in _prototypeManager.EnumeratePrototypes<SpecialPrototype>().OrderBy(a => a.Order))
639+
{
640+
var selector = new SpecialPrioritySelector(special, _prototypeManager);
641+
642+
_specialList.AddChild(selector);
643+
_specialPriorities.Add(selector);
644+
645+
selector.PriorityChanged += priority =>
646+
{
647+
foreach (var specialSelector in _specialPriorities)
648+
{
649+
650+
if(priority != 0)
651+
{
652+
var temp = _specialPointsBar.Value - (int) priority;
653+
if (temp < 0){
654+
}
655+
else
656+
{
657+
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", _specialPointsBar.Value), ("max", _specialPointsBar.MaxValue));
658+
_specialPointsBar.Value = temp;
659+
}
660+
}
661+
else
662+
{
663+
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", _specialPointsBar.Value), ("max", _specialPointsBar.MaxValue));
664+
_specialPointsBar.Value += (int) specialSelector.Priority;
665+
}
666+
Profile = Profile?.WithSpecialPriority(special.ID, priority);
667+
IsDirty = true;
668+
669+
UpdateSpecialPriorities();
670+
}
671+
};
672+
673+
}
674+
}
675+
// Nuclear14 end
676+
610677
private void OnFlavorTextChange(string content)
611678
{
612679
if (Profile is null)
@@ -1104,6 +1171,7 @@ public void UpdateControls()
11041171
UpdateEyePickers();
11051172
UpdateSaveButton();
11061173
UpdateJobPriorities();
1174+
UpdateSpecialPriorities(); // Nuclear14 Special Priorities
11071175
UpdateAntagPreferences();
11081176
UpdateTraitPreferences();
11091177
UpdateMarkings();
@@ -1138,7 +1206,132 @@ private void UpdateJobPriorities()
11381206
}
11391207
}
11401208

1209+
// Nuclear14 Special
1210+
private void UpdateSpecialPriorities()
1211+
{
1212+
var points = _configurationManager.GetCVar(SpecialCCVars.MaxSpecial);
1213+
_specialPointsBar.Value = points;
1214+
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", _specialPointsBar.Value), ("max", _specialPointsBar.MaxValue));
1215+
1216+
foreach (var prioritySelector in _specialPriorities)
1217+
{
1218+
var specialId = prioritySelector.Special.ID;
1219+
1220+
var priority = Profile?.SpecialPriorities.GetValueOrDefault(specialId, SpecialPriority.Zero) ?? SpecialPriority.Zero;
1221+
1222+
prioritySelector.Priority = priority;
1223+
1224+
if (priority != SpecialPriority.Zero)
1225+
{
1226+
points -= (int) priority;
1227+
_specialPointsBar.Value = points;
1228+
_specialPointsLabel.Text = Loc.GetString("humanoid-profile-editor-special-points-label", ("points", points), ("max", _specialPointsBar.MaxValue));
1229+
1230+
}
1231+
}
1232+
if (points < 0)
1233+
_saveButton.Disabled = true;
1234+
1235+
}
1236+
1237+
private sealed class SpecialPrioritySelector : Control
1238+
{
1239+
public SpecialPrototype Special { get; }
1240+
private readonly RadioOptions<int> _optionButton;
1241+
1242+
public SpecialPriority Priority
1243+
{
1244+
get => (SpecialPriority) _optionButton.SelectedValue;
1245+
set => _optionButton.SelectByValue((int) value);
1246+
}
1247+
1248+
public event Action<SpecialPriority>? PriorityChanged;
1249+
private Label _specialTitle;
1250+
1251+
public SpecialPrioritySelector(SpecialPrototype special, IPrototypeManager prototypeManager)
1252+
{
1253+
Special = special;
1254+
1255+
_optionButton = new RadioOptions<int>(RadioOptionsLayout.Horizontal)
1256+
{
1257+
FirstButtonStyle = StyleBase.ButtonOpenRight,
1258+
ButtonStyle = StyleBase.ButtonOpenBoth,
1259+
LastButtonStyle = StyleBase.ButtonOpenLeft
1260+
};
1261+
//Override default radio option button width
1262+
_optionButton.GenerateItem = GenerateButton;
1263+
// Text, Value
1264+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-one-button"), (int) SpecialPriority.One);
1265+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-two-button"), (int) SpecialPriority.Two);
1266+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-three-button"), (int) SpecialPriority.Three);
1267+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-four-button"), (int) SpecialPriority.Four);
1268+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-five-button"), (int) SpecialPriority.Five);
1269+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-six-button"), (int) SpecialPriority.Six);
1270+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-seven-button"), (int) SpecialPriority.Seven);
1271+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-eight-button"), (int) SpecialPriority.Eight);
1272+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-nine-button"), (int) SpecialPriority.Nine);
1273+
_optionButton.AddItem(Loc.GetString("humanoid-profile-editor-special-priority-ten-button"), (int) SpecialPriority.Ten);
1274+
1275+
_optionButton.OnItemSelected += args =>
1276+
{
1277+
_optionButton.Select(args.Id);
1278+
PriorityChanged?.Invoke(Priority);
1279+
};
1280+
1281+
var icon = new TextureRect
1282+
{
1283+
TextureScale = new Vector2(2, 2),
1284+
Stretch = TextureRect.StretchMode.KeepCentered
1285+
};
1286+
1287+
var specialIcon = prototypeManager.Index<StatusIconPrototype>(special.Icon);
1288+
icon.Texture = specialIcon.Icon.Frame0();
1289+
1290+
_specialTitle = new Label()
1291+
{
1292+
Margin = new Thickness(5f,5f,5f,5f),
1293+
Text = special.LocalizedName,
1294+
MinSize = new Vector2(100, 0),
1295+
MouseFilter = MouseFilterMode.Stop
1296+
};
1297+
1298+
if (special.LocalizedDescription != null)
1299+
{
1300+
_specialTitle.ToolTip = special.LocalizedDescription;
1301+
_specialTitle.TooltipDelay = 0.2f;
1302+
}
1303+
1304+
AddChild(new BoxContainer
1305+
{
1306+
Orientation = LayoutOrientation.Horizontal,
1307+
Children =
1308+
{
1309+
icon,
1310+
_specialTitle,
1311+
_optionButton,
1312+
}
1313+
});
1314+
}
1315+
private Button GenerateButton(string text, int value)
1316+
{
1317+
var btn = new Button
1318+
{
1319+
Text = text,
1320+
MinWidth = 40
1321+
};
1322+
return btn;
1323+
}
1324+
}
1325+
// Nuclear14 end
1326+
11411327
private abstract class RequirementsSelector<T> : Control
1328+
{
1329+
public JobPrototype Job { get; }
1330+
private readonly RadioOptions<int> _optionButton;
1331+
1332+
public JobPriority Priority
1333+
{
1334+
get => (JobPriority) _optionButton.SelectedValue;
11421335
{
11431336
public T Proto { get; }
11441337
public bool Disabled => _lockStripe.Visible;

Content.Client/Weapons/Ranged/GunSpreadOverlay.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Robust.Shared.Enums;
66
using Robust.Shared.Map;
77
using Robust.Shared.Timing;
8+
using Content.Shared.Nuclear14.Special.Components;
89

910
namespace Content.Client.Weapons.Ranged;
1011

@@ -58,9 +59,23 @@ protected override void Draw(in OverlayDrawArgs args)
5859
// (☞゚ヮ゚)☞
5960
var maxSpread = gun.MaxAngle;
6061
var minSpread = gun.MinAngle;
62+
// Nuclear14 Shotting accuracy depends on Perception
63+
var decay = gun.AngleDecay;
6164
var timeSinceLastFire = (_timing.CurTime - gun.NextFire).TotalSeconds;
62-
var currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - gun.AngleDecay.Theta * timeSinceLastFire,
63-
gun.MinAngle.Theta, gun.MaxAngle.Theta));
65+
Angle currentAngle;
66+
if (_entManager.TryGetComponent<SpecialComponent>(player, out var special))
67+
{
68+
maxSpread += Angle.FromDegrees((10f - special.TotalPerception));
69+
minSpread += Angle.FromDegrees((10f - special.TotalPerception));
70+
decay += Angle.FromDegrees((special.TotalPerception - 10f) / 5);
71+
72+
currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - decay.Theta * timeSinceLastFire,
73+
minSpread.Theta, maxSpread.Theta));
74+
}
75+
else
76+
currentAngle = new Angle(MathHelper.Clamp(gun.CurrentAngle.Theta - gun.AngleDecay.Theta * timeSinceLastFire,
77+
gun.MinAngle.Theta, gun.MaxAngle.Theta));
78+
// Nuclear14 end
6479
var direction = (mousePos.Position - mapPos.Position);
6580

6681
worldHandle.DrawLine(mapPos.Position, mousePos.Position + direction, Color.Orange);

Content.IntegrationTests/Tests/Preferences/ServerDbSqliteTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Content.Shared.GameTicking;
55
using Content.Shared.Humanoid;
66
using Content.Shared.Preferences;
7+
using Content.Shared.Nuclear14.Special;
78
using Microsoft.Data.Sqlite;
89
using Microsoft.EntityFrameworkCore;
910
using Robust.Shared.Configuration;
@@ -60,7 +61,17 @@ private static HumanoidCharacterProfile CharlieCharlieson()
6061
},
6162
PreferenceUnavailableMode.StayInLobby,
6263
new List<string> (),
63-
new List<string>()
64+
new List<string> (),
65+
new Dictionary<string, SpecialPriority>
66+
{
67+
{"Strength", SpecialPriority.Five},
68+
{"Perception", SpecialPriority.Five},
69+
{"Endurance", SpecialPriority.Five},
70+
{"Charisma", SpecialPriority.Five},
71+
{"Intelligence", SpecialPriority.Five},
72+
{"Agility", SpecialPriority.Five},
73+
{"Luck", SpecialPriority.Five}
74+
}
6475
);
6576
}
6677

0 commit comments

Comments
 (0)