Skip to content

Commit

Permalink
Merge branch 'master' into cherrypick-shoot-over-bodies
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Jun 21, 2024
2 parents f73a169 + 287f33c commit b6de634
Show file tree
Hide file tree
Showing 80 changed files with 1,934 additions and 964 deletions.
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
21 changes: 21 additions & 0 deletions Content.Server/Implants/ImplanterSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Popups;
using Content.Shared.DoAfter;
using Content.Shared.IdentityManagement;
Expand Down Expand Up @@ -57,6 +58,17 @@ private void OnImplanterAfterInteract(EntityUid uid, ImplanterComponent componen
return;
}

// Check if we are trying to implant a implant which is already implanted
if (implant.HasValue && !component.AllowMultipleImplants && CheckSameImplant(target, implant.Value))
{
var name = Identity.Name(target, EntityManager, args.User);
var msg = Loc.GetString("implanter-component-implant-already", ("implant", implant), ("target", name));
_popup.PopupEntity(msg, target, args.User);
args.Handled = true;
return;
}


//Implant self instantly, otherwise try to inject the target.
if (args.User == target)
Implant(target, target, uid, component);
Expand All @@ -67,6 +79,15 @@ private void OnImplanterAfterInteract(EntityUid uid, ImplanterComponent componen
args.Handled = true;
}

public bool CheckSameImplant(EntityUid target, EntityUid implant)
{
if (!TryComp<ImplantedComponent>(target, out var implanted))
return false;

var implantPrototype = Prototype(implant);
return implanted.ImplantContainer.ContainedEntities.Any(entity => Prototype(entity) == implantPrototype);
}

/// <summary>
/// Attempt to implant someone else.
/// </summary>
Expand Down
63 changes: 63 additions & 0 deletions Content.Server/Speech/Components/RandomBarkComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace Content.Server.Speech.Components;

/// <summary>
/// Sends a random message from a list with a provided min/max time.
/// </summary>
[RegisterComponent]
public sealed partial class RandomBarkComponent : Component
{
/// <summary>
/// Should the message be sent to the chat log?
/// </summary>
[DataField]
public bool ChatLog = false;

/// <summary>
/// Minimum time an animal will go without speaking
/// </summary>
[DataField]
public int MinTime = 45;

/// <summary>
/// Maximum time an animal will go without speaking
/// </summary>
[DataField]
public int MaxTime = 350;

/// <summary>
/// Accumulator for counting time since the last bark
/// </summary>
[DataField]
public float BarkAccumulator = 8f;

/// <summary>
/// Multiplier applied to the random time. Good for changing the frequency without having to specify exact values
/// </summary>
[DataField]
public float BarkMultiplier = 1f;

/// <summary>
/// List of things to be said. Filled with garbage to be modified by an accent, but can be specified in the .yml
/// </summary>
[DataField]
public IReadOnlyList<string> Barks = new[]
{
"Bark",
"Boof",
"Woofums",
"Rawrl",
"Eeeeeee",
"Barkums",
"Awooooooooooooooooooo awoo awoooo",
"Grrrrrrrrrrrrrrrrrr",
"Rarrwrarrwr",
"Goddamn I love gold fish crackers",
"Bork bork boof boof bork bork boof boof boof bork",
"Bark",
"Boof",
"Woofums",
"Rawrl",
"Eeeeeee",
"Barkums",
};
}
47 changes: 47 additions & 0 deletions Content.Server/Speech/Systems/RandomBarkSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Content.Server.Chat.Systems;
using Content.Shared.Mind.Components;
using Robust.Shared.Random;
using Content.Server.Speech.Components;

namespace Content.Server.Speech.Systems;

public sealed class RandomBarkSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ChatSystem _chat = default!;
[Dependency] private readonly EntityManager _entity = default!;


public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<RandomBarkComponent, ComponentInit>(OnInit);
}


private void OnInit(EntityUid uid, RandomBarkComponent barker, ComponentInit args)
{
barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime) * barker.BarkMultiplier;
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<RandomBarkComponent>();
while (query.MoveNext(out var uid, out var barker))
{
barker.BarkAccumulator -= frameTime;
if (barker.BarkAccumulator > 0)
continue;

barker.BarkAccumulator = _random.NextFloat(barker.MinTime, barker.MaxTime) * barker.BarkMultiplier;
if (_entity.TryGetComponent<MindContainerComponent>(uid, out var actComp) &&
actComp.HasMind)
continue;

_chat.TrySendInGameICMessage(uid, _random.Pick(barker.Barks), InGameICChatType.Speak, barker.ChatLog ? ChatTransmitRange.Normal : ChatTransmitRange.HideChat);
}
}
}
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);
}
}
}
}
27 changes: 27 additions & 0 deletions Content.Server/Weapons/Ranged/Systems/FireOnDropSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Shared.Throwing;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Random;

namespace Content.Server.Weapons.Ranged.Systems;

public sealed class FireOnDropSystem : EntitySystem
{
[Dependency] private readonly SharedGunSystem _gun = default!;
[Dependency] private readonly IRobustRandom _random = default!;


public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<GunComponent, ThrowDoHitEvent>(HandleLand);
}


private void HandleLand(EntityUid uid, GunComponent component, ref ThrowDoHitEvent args)
{
if (_random.Prob(component.FireOnDropChance))
_gun.AttemptShoot(uid, uid, component, Transform(uid).Coordinates.Offset(Transform(uid).LocalRotation.ToVec()));
}
}
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
Loading

0 comments on commit b6de634

Please sign in to comment.