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

Trait Points #434

Merged
merged 31 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
87a51f1
new trait prototype, fix trait locales
DEATHB4DEFEAT Jun 3, 2024
0dc3c8d
reorganize trait systems
DEATHB4DEFEAT Jun 3, 2024
2f36cae
totally relevant loadout prototype changes
DEATHB4DEFEAT Jun 3, 2024
9ba13a5
CharacterRequirements system
DEATHB4DEFEAT Jun 3, 2024
f851ced
fix loadout requirements
DEATHB4DEFEAT Jun 3, 2024
4c4c38f
fix captain too
DEATHB4DEFEAT Jun 3, 2024
8472e2b
rename loadout reqs to character reqs
DEATHB4DEFEAT Jun 3, 2024
23b4b10
mostly functional everything else
DEATHB4DEFEAT Jun 3, 2024
58cf3d0
fix/improve category matching
DEATHB4DEFEAT Jun 3, 2024
df1720c
test categories
DEATHB4DEFEAT Jun 3, 2024
69359ad
fix game
DEATHB4DEFEAT Jun 11, 2024
bd19b72
Merge branch 'master' of https://github.com/Simple-Station/Einstein-E…
DEATHB4DEFEAT Jun 11, 2024
6c33709
I hate tabcontainer
DEATHB4DEFEAT Jun 11, 2024
f7f8c04
test trait point costs
DEATHB4DEFEAT Jun 11, 2024
2d14e8e
clientside point checks
DEATHB4DEFEAT Jun 11, 2024
585f6a6
UI locale
DEATHB4DEFEAT Jun 11, 2024
fec360d
improve points logic a TON
DEATHB4DEFEAT Jun 11, 2024
3fe2a04
STYLE
DEATHB4DEFEAT Jun 11, 2024
c9e42dc
sort traits backwards
DEATHB4DEFEAT Jun 11, 2024
2055c7d
trait point bar goes to max possible points
DEATHB4DEFEAT Jun 11, 2024
c01124b
trait counter and locale plurality
DEATHB4DEFEAT Jun 11, 2024
fa758af
max trait count
DEATHB4DEFEAT Jun 11, 2024
d9e68ab
show max traits to the player if there is any
DEATHB4DEFEAT Jun 20, 2024
43463d8
fix trait locs
DEATHB4DEFEAT Jun 20, 2024
2c9a744
prototype exclusion
DEATHB4DEFEAT Jun 20, 2024
212459e
trait point validation
DEATHB4DEFEAT Jun 20, 2024
59aa6e4
categorize traits
DEATHB4DEFEAT Jun 20, 2024
fdee791
disallow borgs from using many traits
DEATHB4DEFEAT Jun 20, 2024
9711c85
fix req loc, fill in lacking reqs, fix comments
DEATHB4DEFEAT Jun 20, 2024
1548b80
fix default trait category
DEATHB4DEFEAT Jun 20, 2024
5584ef7
Points are Done
VMSolidus Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,29 @@
<BoxContainer Name="CAntagList" Orientation="Vertical" />
</ScrollContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical" Margin="10">
<BoxContainer Name="CTraitsTab" Orientation="Vertical" Margin="10">
<!-- Traits -->
<ScrollContainer VerticalExpand="True">
<BoxContainer Name="CTraitsList" Orientation="Vertical" />
</ScrollContainer>
<Label Name="TraitPointsLabel" HorizontalAlignment="Stretch" Align="Center" />
<ProgressBar Name="TraitPointsBar" MaxValue="1" Value="1" MaxHeight="8" Margin="0 5" />

<Button Name="TraitsShowUnusableButton"
Text="{Loc 'humanoid-profile-editor-traits-show-unusable-button'}"
ToolTip="{Loc 'humanoid-profile-editor-traits-show-unusable-button-tooltip'}"
ToggleMode="True"
Margin="0 0 0 5" />

<TabContainer Name="CTraitsTabs" VerticalExpand="True" />
</BoxContainer>
<BoxContainer Name="CLoadoutsTab" Orientation="Vertical" Margin="10">
<!-- Loadouts -->
<Label Name="LoadoutPointsLabel" HorizontalAlignment="Stretch" Align="Center" />
<ProgressBar Name="LoadoutPointsBar" MaxValue="1" Value="1" MaxHeight="8" Margin="0 5" />

<Button Name="CHideShowUnusableButton" Text="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button'}" ToolTip="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button-tooltip'}" ToggleMode="True" Margin="0 0 0 5" />
<Button Name="LoadoutsShowUnusableButton"
Text="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button'}"
ToolTip="{Loc 'humanoid-profile-editor-loadouts-show-unusable-button-tooltip'}"
ToggleMode="True"
Margin="0 0 0 5" />

<TabContainer Name="CLoadoutsTabs" VerticalExpand="True" />
</BoxContainer>
Expand Down
555 changes: 440 additions & 115 deletions Content.Client/Preferences/UI/HumanoidProfileEditor.xaml.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Content.Client/Traits/ParacusiaSystem.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Numerics;
using Content.Shared.Traits.Assorted;
using Content.Shared.Traits.Assorted.Systems;
using Robust.Shared.Random;
using Robust.Client.Player;
using Robust.Shared.Player;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing;
using Content.Shared.Traits.Assorted.Components;

namespace Content.Client.Traits;

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Flash/FlashSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
using Content.Shared.Inventory;
using Content.Shared.Physics;
using Content.Shared.Tag;
using Content.Shared.Traits.Assorted;
using Content.Shared.Weapons.Melee.Events;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Timing;
using InventoryComponent = Content.Shared.Inventory.InventoryComponent;
using Content.Shared.Traits.Assorted.Components;

namespace Content.Server.Flash
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Content.Server.StationEvents.Components;
using Content.Server.Traits.Assorted;
using Content.Shared.Mind.Components;
using Content.Shared.Traits.Assorted;
using Content.Shared.Traits.Assorted.Components;

namespace Content.Server.StationEvents.Events;

Expand Down
2 changes: 2 additions & 0 deletions Content.Server/Traits/Assorted/ParacusiaSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Traits.Assorted;
using Content.Shared.Traits.Assorted.Systems;
using Robust.Shared.Audio;
using Content.Shared.Traits.Assorted.Components;

namespace Content.Server.Traits.Assorted;

Expand Down
40 changes: 19 additions & 21 deletions Content.Server/Traits/TraitSystem.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
using System.Linq;
using Content.Server.GameTicking;
using Content.Server.Players.PlayTimeTracking;
using Content.Shared.Customization.Systems;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Roles;
using Content.Shared.Traits;
using Pidgin.Configuration;
using Robust.Shared.Configuration;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.Manager;

namespace Content.Server.Traits;

public sealed class TraitSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
[Dependency] private readonly SharedHandsSystem _sharedHandsSystem = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly CharacterRequirementsSystem _characterRequirements = default!;
[Dependency] private readonly PlayTimeTrackingManager _playTimeTracking = default!;
[Dependency] private readonly IConfigurationManager _configuration = default!;

public override void Initialize()
{
Expand All @@ -25,16 +34,17 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)
{
foreach (var traitId in args.Profile.TraitPreferences)
{
if (!_prototypeManager.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
if (!_prototype.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
{
Log.Warning($"No trait found with ID {traitId}!");
return;
}

if (traitPrototype.Whitelist != null && !traitPrototype.Whitelist.IsValid(args.Mob))
continue;

if (traitPrototype.Blacklist != null && traitPrototype.Blacklist.IsValid(args.Mob))
if (!_characterRequirements.CheckRequirementsValid(traitPrototype, traitPrototype.Requirements,
_prototype.Index<JobPrototype>(args.JobId ?? _prototype.EnumeratePrototypes<JobPrototype>().First().ID),
args.Profile, _playTimeTracking.GetTrackerTimes(args.Player),
EntityManager, _prototype, _configuration,
out _))
continue;

// Add all components required by the prototype
Expand All @@ -43,22 +53,10 @@ private void OnPlayerSpawnComplete(PlayerSpawnCompleteEvent args)
if (HasComp(args.Mob, entry.Component.GetType()))
continue;

var comp = (Component) _serializationManager.CreateCopy(entry.Component, notNullableOverride: true);
var comp = (Component) _serialization.CreateCopy(entry.Component, notNullableOverride: true);
comp.Owner = args.Mob;
EntityManager.AddComponent(args.Mob, comp);
}

// Add item required by the trait
if (traitPrototype.TraitGear != null)
{
if (!TryComp(args.Mob, out HandsComponent? handsComponent))
continue;

var coords = Transform(args.Mob).Coordinates;
var inhandEntity = EntityManager.SpawnEntity(traitPrototype.TraitGear, coords);
_sharedHandsSystem.TryPickup(args.Mob, inhandEntity, checkActionBlocker: false,
handsComp: handsComponent);
}
}
}
}
2 changes: 1 addition & 1 deletion Content.Server/Zombies/ZombieSystem.Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
using Content.Shared.Weapons.Melee;
using Content.Shared.Zombies;
using Content.Shared.Prying.Components;
using Content.Shared.Traits.Assorted;
using Robust.Shared.Audio.Systems;
using Content.Shared.Traits.Assorted.Components;

namespace Content.Server.Zombies
{
Expand Down
24 changes: 22 additions & 2 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,14 +341,34 @@ public static readonly CVarDef<bool>
public static readonly CVarDef<bool> DebugCoordinatesAdminOnly =
CVarDef.Create("game.debug_coordinates_admin_only", true, CVar.SERVER | CVar.REPLICATED);


/// <summary>
/// Whether to allow characters to select traits.
/// </summary>
public static readonly CVarDef<bool> GameTraitsEnabled =
CVarDef.Create("game.traits_enabled", true, CVar.REPLICATED);

/// <summary>
/// How many traits a character can have at most.
/// </summary>
public static readonly CVarDef<int> GameTraitsMax =
CVarDef.Create("game.traits_max", 5, CVar.REPLICATED);

/// <summary>
/// How many points a character should start with.
/// </summary>
public static readonly CVarDef<int> GameTraitsDefaultPoints =
CVarDef.Create("game.traits_default_points", 5, CVar.REPLICATED);


/// <summary>
/// Whether or not to allow characters to select loadout items.
/// Whether to allow characters to select loadout items.
/// </summary>
public static readonly CVarDef<bool> GameLoadoutsEnabled =
CVarDef.Create("game.loadouts_enabled", true, CVar.REPLICATED);

/// <summary>
/// How many points to give to each player for loadouts.
/// How many points to give to each player for loadouts.
/// </summary>
public static readonly CVarDef<int> GameLoadoutsPoints =
CVarDef.Create("game.loadouts_points", 14, CVar.REPLICATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Content.Shared.Clothing.Loadouts.Prototypes;


/// <summary>
/// A prototype defining a valid category for <see cref="LoadoutPrototype"/>s to go into.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.Customization.Systems;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;

namespace Content.Shared.Clothing.Loadouts.Prototypes;


[Prototype("loadout")]
public sealed class LoadoutPrototype : IPrototype
{
Expand All @@ -17,7 +19,7 @@ public sealed class LoadoutPrototype : IPrototype
/// <summary>
/// Which tab category to put this under
/// </summary>
[DataField(customTypeSerializer:typeof(PrototypeIdSerializer<LoadoutCategoryPrototype>))]
[DataField, ValidatePrototypeId<LoadoutCategoryPrototype>]
public string Category = "Uncategorized";

/// <summary>
Expand All @@ -41,5 +43,5 @@ public sealed class LoadoutPrototype : IPrototype


[DataField]
public List<LoadoutRequirement> Requirements = new();
public List<CharacterRequirement> Requirements = new();
}
Loading
Loading