Skip to content

Commit

Permalink
Merge pull request #115 from Evgencheg/master
Browse files Browse the repository at this point in the history
Апстрим+фиксы
  • Loading branch information
Evgencheg authored Sep 9, 2024
2 parents 6af981e + ff372d5 commit dc04056
Show file tree
Hide file tree
Showing 99 changed files with 984 additions and 559 deletions.
2 changes: 1 addition & 1 deletion Content.Server/Chat/Managers/ChatSanitizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager

private static readonly Dictionary<string, string> SmileyToEmote = new()
{
// I could've done this with regex, but felt it wasn't the right idea.
// Corvax-Localization-Start
{ "хд", "chatsan-laughs" },
{ "о-о", "chatsan-wide-eyed" }, // cyrillic о
{ "о.о", "chatsan-wide-eyed" }, // cyrillic о
Expand Down
25 changes: 10 additions & 15 deletions Content.Server/Mousetrap/MousetrapSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
using Content.Server.Explosion.EntitySystems;
using Content.Server.Popups;
using Content.Shared.Interaction.Events;
using Content.Shared.Inventory;
using Content.Shared.Mousetrap;
using Content.Shared.StepTrigger;
using Content.Shared.StepTrigger.Systems;
using Robust.Server.GameObjects;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;

namespace Content.Server.Mousetrap;

Expand Down Expand Up @@ -44,15 +40,16 @@ private void OnStepTriggerAttempt(EntityUid uid, MousetrapComponent component, r

private void BeforeDamageOnTrigger(EntityUid uid, MousetrapComponent component, BeforeDamageUserOnTriggerEvent args)
{
if (TryComp(args.Tripper, out PhysicsComponent? physics) && physics.Mass != 0)
{
// The idea here is inverse,
// Small - big damage,
// Large - small damage
// yes i punched numbers into a calculator until the graph looked right
var scaledDamage = -50 * Math.Atan(physics.Mass - component.MassBalance) + (25 * Math.PI);
args.Damage *= scaledDamage;
}
if (!TryComp<PhysicsComponent>(args.Tripper, out var physics)
|| physics.Mass is 0)
return;

// The idea here is inverse,
// Small - big damage,
// Large - small damage
// Yes, I punched numbers into a calculator until the graph looked right
var scaledDamage = -50 * MathF.Atan(physics.Mass - component.MassBalance) + 25 * MathF.PI;
args.Damage *= scaledDamage;
}

private void OnTrigger(EntityUid uid, MousetrapComponent component, TriggerEvent args)
Expand All @@ -64,9 +61,7 @@ private void OnTrigger(EntityUid uid, MousetrapComponent component, TriggerEvent
private void UpdateVisuals(EntityUid uid, MousetrapComponent? mousetrap = null, AppearanceComponent? appearance = null)
{
if (!Resolve(uid, ref mousetrap, ref appearance, false))
{
return;
}

_appearance.SetData(uid, MousetrapVisuals.Visual,
mousetrap.IsActive ? MousetrapVisuals.Armed : MousetrapVisuals.Unarmed, appearance);
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,7 @@ public static readonly CVarDef<int>
/// Whether the arrivals shuttle is enabled.
/// </summary>
public static readonly CVarDef<bool> ArrivalsShuttles =
CVarDef.Create("shuttle.arrivals", false, CVar.SERVERONLY);
CVarDef.Create("shuttle.arrivals", true, CVar.SERVERONLY);

/// <summary>
/// The map to use for the arrivals station.
Expand Down
21 changes: 21 additions & 0 deletions Content.Shared/Contests/ContestsSystem.Utilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Content.Shared.CCVar;

namespace Content.Shared.Contests;
public sealed partial class ContestsSystem
{
/// <summary>
/// Clamp a contest to a Range of [Epsilon, 32bit integer limit]. This exists to make sure contests are always "Safe" to divide by.
/// </summary>
private float ContestClamp(float input)
{
return Math.Clamp(input, float.Epsilon, float.MaxValue);
}

/// <summary>
/// Shorthand for checking if clamp overrides are allowed, and the bypass is used by a contest.
/// </summary>
private bool ContestClampOverride(bool bypassClamp)
{
return _cfg.GetCVar(CCVars.AllowClampOverride) && bypassClamp;
}
}
132 changes: 94 additions & 38 deletions Content.Shared/Contests/ContestsSystem.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile,
{
var succeeded = false;
var reasons = new List<FormattedMessage>();
var characterRequirements = entityManager.EntitySysManager.GetEntitySystem<CharacterRequirementsSystem>();

foreach (var requirement in Requirements)
{
if (requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager,
configManager, out var raisin, depth + 1))
if (characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype,
entityManager, prototypeManager, configManager, out var raisin, depth + 1))
{
succeeded = true;
break;
Expand Down Expand Up @@ -110,11 +112,12 @@ public override bool IsValid(JobPrototype job, HumanoidCharacterProfile profile,
{
var reasons = new List<FormattedMessage>();
var succeeded = false;
var characterRequirements = entityManager.EntitySysManager.GetEntitySystem<CharacterRequirementsSystem>();

foreach (var requirement in Requirements)
{
if (requirement.IsValid(job, profile, playTimes, whitelisted, prototype, entityManager, prototypeManager,
configManager, out var raisin, depth + 1))
if (characterRequirements.CheckRequirementValid(requirement, job, profile, playTimes, whitelisted, prototype,
entityManager, prototypeManager, configManager, out var raisin, depth + 1))
{
if (succeeded)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ public sealed class CharacterRequirementsSystem : EntitySystem
[Dependency] private readonly InventorySystem _inventory = default!;


public bool CheckRequirementValid(CharacterRequirement requirement, JobPrototype job,
HumanoidCharacterProfile profile, Dictionary<string, TimeSpan> playTimes, bool whitelisted, IPrototype prototype,
IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager,
out FormattedMessage? reason, int depth = 0)
{
// Return false if the requirement is invalid and not inverted
// If it's inverted return false when it's valid
return
!requirement.IsValid(job, profile, playTimes, whitelisted, prototype,
entityManager, prototypeManager, configManager,
out reason, depth)
? requirement.Inverted
: !requirement.Inverted;
}

public bool CheckRequirementsValid(List<CharacterRequirement> requirements, JobPrototype job,
HumanoidCharacterProfile profile, Dictionary<string, TimeSpan> playTimes, bool whitelisted, IPrototype prototype,
IEntityManager entityManager, IPrototypeManager prototypeManager, IConfigurationManager configManager,
Expand Down
26 changes: 16 additions & 10 deletions Content.Shared/Humanoid/Markings/MarkingCategories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ public enum MarkingCategories : byte
HeadSide,
Snout,
Chest,
Arms,
Legs,
RightArm,
RightHand,
LeftArm,
LeftHand,
RightLeg,
RightFoot,
LeftLeg,
LeftFoot,
Tail,
Overlay
}
Expand All @@ -31,14 +37,14 @@ public static MarkingCategories FromHumanoidVisualLayers(HumanoidVisualLayers la
HumanoidVisualLayers.HeadSide => MarkingCategories.HeadSide,
HumanoidVisualLayers.Snout => MarkingCategories.Snout,
HumanoidVisualLayers.Chest => MarkingCategories.Chest,
HumanoidVisualLayers.RArm => MarkingCategories.Arms,
HumanoidVisualLayers.LArm => MarkingCategories.Arms,
HumanoidVisualLayers.RHand => MarkingCategories.Arms,
HumanoidVisualLayers.LHand => MarkingCategories.Arms,
HumanoidVisualLayers.LLeg => MarkingCategories.Legs,
HumanoidVisualLayers.RLeg => MarkingCategories.Legs,
HumanoidVisualLayers.LFoot => MarkingCategories.Legs,
HumanoidVisualLayers.RFoot => MarkingCategories.Legs,
HumanoidVisualLayers.RArm => MarkingCategories.RightArm,
HumanoidVisualLayers.LArm => MarkingCategories.LeftArm,
HumanoidVisualLayers.RHand => MarkingCategories.RightHand,
HumanoidVisualLayers.LHand => MarkingCategories.LeftHand,
HumanoidVisualLayers.LLeg => MarkingCategories.LeftLeg,
HumanoidVisualLayers.RLeg => MarkingCategories.RightLeg,
HumanoidVisualLayers.LFoot => MarkingCategories.LeftFoot,
HumanoidVisualLayers.RFoot => MarkingCategories.RightFoot,
HumanoidVisualLayers.Tail => MarkingCategories.Tail,
_ => MarkingCategories.Overlay
};
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Preferences/HumanoidCharacterProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ IDependencyCollection collection

if (configManager.GetCVar(CCVars.RestrictedNames))
{
name = Regex.Replace(name, @"[^А-Я,а-я,A-Z,a-z,0-9, -]", string.Empty); // Theta: All the names pew-pew!
name = Regex.Replace(name, @"[^А-Яа-яёЁ0-9' -]", string.Empty); // Theta: All the names pew-pew!
/*
* 0030-0039 Basic Latin: ASCII Digits
* 0041-005A Basic Latin: Uppercase Latin Alphabet
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Robust.Shared.GameStates;

namespace Content.Shared.StepTrigger.Components;

/// <summary>
/// This component marks an entity as being immune to all step triggers.
/// For example, a Felinid or Harpy being so low density, that they don't set off landmines.
/// </summary>
/// <remarks>
/// This is the "Earliest Possible Exit" method, and therefore isn't possible to un-cancel.
/// It will prevent ALL step trigger events from firing. Therefore there may sometimes be unintended consequences to this.
/// Consider using a subscription to StepTriggerAttemptEvent if you wish to be more selective.
/// </remarks>
[RegisterComponent, NetworkedComponent]
public sealed partial class StepTriggerImmuneComponent : Component { }
Loading

0 comments on commit dc04056

Please sign in to comment.