Co-authored-by: mirrorcult <lunarautomaton6@gmail.com>
This commit is contained in:
Alex Evgrashin
2022-01-19 01:18:22 +03:00
committed by GitHub
parent ac36f15a70
commit 16a532137d
12 changed files with 155 additions and 12 deletions

View File

@@ -144,6 +144,7 @@ namespace Content.Client.Entry
"MovedByPressure",
"Spray",
"Vapor",
"AddAccentClothing",
"DamageOnHighSpeedImpact",
"SolutionContainerManager",
"RefillableSolution",

View File

@@ -173,16 +173,16 @@ namespace Content.Server.Chat.Managers
return;
}
message = message.Trim();
message = SanitizeMessageCapital(source, message);
foreach (var handler in _chatTransformHandlers)
{
//TODO: rather return a bool and use a out var?
message = handler(source, message);
}
message = message.Trim();
message = SanitizeMessageCapital(source, message);
var listeners = EntitySystem.Get<ListeningSystem>();
listeners.PingListeners(source, message);
@@ -211,16 +211,16 @@ namespace Content.Server.Chat.Managers
return;
}
message = message.Trim();
message = SanitizeMessageCapital(source, message);
foreach (var handler in _chatTransformHandlers)
{
//TODO: rather return a bool and use a out var?
message = handler(source, message);
}
message = message.Trim();
message = SanitizeMessageCapital(source, message);
var listeners = EntitySystem.Get<ListeningSystem>();
listeners.PingListeners(source, message);

View File

@@ -0,0 +1,32 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Speech.Components;
/// <summary>
/// Applies accent to user while they wear entity as a clothing.
/// </summary>
[RegisterComponent]
public class AddAccentClothingComponent : Component
{
public override string Name => "AddAccentClothing";
/// <summary>
/// Component name for accent that will be applied.
/// </summary>
[DataField("accent", required: true)]
public string Accent = default!;
/// <summary>
/// What <see cref="ReplacementAccentPrototype"/> to use.
/// Will be applied only with <see cref="ReplacementAccentComponent"/>.
/// </summary>
[DataField("replacement", customTypeSerializer: typeof(PrototypeIdSerializer<ReplacementAccentPrototype>))]
public string? ReplacementPrototype;
/// <summary>
/// Is that clothing is worn and affecting someones accent?
/// </summary>
public bool IsActive = false;
}

View File

@@ -0,0 +1,60 @@
using Content.Server.Clothing.Components;
using Content.Server.Speech.Components;
using Content.Shared.Inventory.Events;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Speech.EntitySystems;
public class AddAccentClothingSystem : EntitySystem
{
[Dependency] private readonly IComponentFactory _componentFactory = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AddAccentClothingComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<AddAccentClothingComponent, GotUnequippedEvent>(OnGotUnequipped);
}
private void OnGotEquipped(EntityUid uid, AddAccentClothingComponent component, GotEquippedEvent args)
{
if (!TryComp(uid, out ClothingComponent? clothing))
return;
// check if entity was actually used as clothing
// not just taken in pockets or something
var isCorrectSlot = clothing.SlotFlags.HasFlag(args.SlotFlags);
if (!isCorrectSlot) return;
// does the user already has this accent?
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (EntityManager.HasComponent(args.Equipee, componentType)) return;
// add accent to the user
var accentComponent = (Component) _componentFactory.GetComponent(componentType);
accentComponent.Owner = args.Equipee;
EntityManager.AddComponent(args.Equipee, accentComponent);
// snowflake case for replacement accent
if (accentComponent is ReplacementAccentComponent rep)
rep.Accent = component.ReplacementPrototype!;
component.IsActive = true;
}
private void OnGotUnequipped(EntityUid uid, AddAccentClothingComponent component, GotUnequippedEvent args)
{
if (!component.IsActive)
return;
// try to remove accent
var componentType = _componentFactory.GetRegistration(component.Accent).Type;
if (EntityManager.HasComponent(args.Equipee, componentType))
{
EntityManager.RemoveComponent(args.Equipee, componentType);
}
component.IsActive = false;
}
}

View File

@@ -12,6 +12,8 @@
amount: 2
- id: ClothingShoesColorBlack
amount: 2
- id: ClothingMaskMuzzle
amount: 1
#- type: entity
# id: WardrobePajamaFilled
@@ -75,8 +77,8 @@
prob: 0.5
- id: CrowbarRed #The jojoke - hit video game Half-Life
prob: 0.1
- type: entity
id: WardrobeBotanistFilled
suffix: Filled
@@ -139,7 +141,7 @@
amount: 1
- id: ClothingUniformJumpskirtChaplain
amount: 1
- type: entity
id: WardrobeSecurityFilled
@@ -182,7 +184,7 @@
amount: 1
- id: ClothingUniformJumpskirtCargo
amount: 1
# - type: entity
# id: WardrobeAtmosphericsFilled

View File

@@ -72,3 +72,18 @@
sprite: Clothing/Mask/sterile.rsi
- type: BreathMask
- type: IngestionBlocker
- type: entity
parent: ClothingMaskBase
id: ClothingMaskMuzzle
name: muzzle
description: To stop that awful noise.
components:
- type: Sprite
sprite: Clothing/Mask/muzzle.rsi
- type: Clothing
sprite: Clothing/Mask/muzzle.rsi
- type: IngestionBlocker
- type: AddAccentClothing
accent: ReplacementAccent
replacement: mumble

View File

@@ -23,3 +23,10 @@
- Piep!
- Chuu!
- Eeee!
- type: accent
id: mumble
words:
- Mmfph!
- Mmmf mrrfff!
- Mmmf mnnf!

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

View File

@@ -0,0 +1,26 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/4f6190e2895e09116663ef282d3ce1d8b35c032e",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "icon"
},
{
"name": "equipped-MASK",
"directions": 4
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}