Toy Box filled with toys (ready for merge) (#16252)

This commit is contained in:
brainfood1183
2023-06-03 04:31:47 +01:00
committed by GitHub
parent 3d29ab3486
commit c99585c94f
75 changed files with 1118 additions and 13 deletions

View File

@@ -0,0 +1,61 @@
using Content.Shared.IdentityManagement;
using Content.Shared.Popups;
using Content.Shared.Item;
using Content.Shared.Interaction.Components;
using Content.Shared.Glue;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Interaction;
using Content.Server.Nutrition.Components;
namespace Content.Server.Glue
{
public sealed class GlueSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly FoodSystem _food = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GlueComponent, AfterInteractEvent>(OnInteract);
}
// When glue bottle is used on item it will apply the glued and unremoveable components.
private void OnInteract(EntityUid uid, GlueComponent component, AfterInteractEvent args)
{
if (args.Handled)
return;
if (!args.CanReach || args.Target is not { Valid: true } target)
return;
if (HasComp<GluedComponent>(target))
{
_popup.PopupEntity(Loc.GetString("glue-failure", ("target", Identity.Entity(target, EntityManager))), args.User,
args.User, PopupType.Medium);
return;
}
if (HasComp<ItemComponent>(target))
{
_audio.PlayPvs(component.Squeeze, uid);
EnsureComp<UnremoveableComponent>(target);
_popup.PopupEntity(Loc.GetString("glue-success", ("target", Identity.Entity(target, EntityManager))), args.User,
args.User, PopupType.Medium);
EnsureComp<GluedComponent>(target);
}
if (TryComp<FoodComponent>(uid, out var food))
{
_food.DeleteAndSpawnTrash(food, uid, args.User);
}
args.Handled = true;
}
}
}

View File

@@ -0,0 +1,64 @@
using Content.Shared.Interaction.Components;
using Robust.Shared.Timing;
using Content.Shared.Interaction;
using Content.Shared.Glue;
using Content.Shared.Hands.Components;
namespace Content.Server.Glue;
public sealed class GluedSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IGameTiming _timing = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GluedComponent, ComponentInit>(OnGluedInit);
SubscribeLocalEvent<GluedComponent, InteractHandEvent>(OnPickUp);
}
// Timing to remove glued and unremoveable.
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator<GluedComponent>();
while (query.MoveNext(out var uid, out var glue))
{
if (!glue.GlueBroken || glue.Glued)
continue;
if (_timing.CurTime < glue.GlueTime)
continue;
glue.Glued = false;
glue.GlueBroken = false;
MetaData(uid).EntityName = glue.BeforeGluedEntityName;
RemComp<UnremoveableComponent>(uid);
RemComp<GluedComponent>(uid);
}
}
//Adds the prefix on init.
private void OnGluedInit(EntityUid uid, GluedComponent component, ComponentInit args)
{
var meta = MetaData(uid);
var name = meta.EntityName;
component.BeforeGluedEntityName = meta.EntityName;
meta.EntityName = Loc.GetString("glued-name-prefix", ("target", name));
}
// Timers start only when the glued item is picked up.
private void OnPickUp(EntityUid uid, GluedComponent component, InteractHandEvent args)
{
var userHands = Comp<HandsComponent>(args.User);
if (userHands.ActiveHandEntity == uid)
{
component.GlueBroken = true;
component.GlueTime = _timing.CurTime + component.GlueCooldown;
}
}
}

View File

@@ -300,7 +300,7 @@ namespace Content.Server.Nutrition.EntitySystems
DeleteAndSpawnTrash(component, uid, args.User);
}
private void DeleteAndSpawnTrash(FoodComponent component, EntityUid food, EntityUid? user = null)
public void DeleteAndSpawnTrash(FoodComponent component, EntityUid food, EntityUid? user = null)
{
//We're empty. Become trash.
var position = Transform(food).MapPosition;

View File

@@ -0,0 +1,100 @@
using Content.Server.Ghost.Roles.Components;
using Content.Server.Popups;
using Content.Shared.Interaction.Events;
using Content.Shared.Puppet;
using Content.Shared.Hands.Components;
using Content.Server.Speech.Muting;
using Content.Shared.CombatMode;
using Content.Shared.Hands;
namespace Content.Server.Puppet
{
public sealed class PuppetDummySystem : SharedPuppetDummySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PuppetDummyComponent, DroppedEvent>(OnDropped);
SubscribeLocalEvent<PuppetDummyComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<PuppetDummyComponent, GotUnequippedHandEvent>(OnUnequippedHand);
}
/// <summary>
/// When used user inserts hand into dummy and the dummy can speak, when used again the user removes hand
/// from dummy and the dummy cannot speak.
/// </summary>
/// <param name="uid"></param>
/// <param name="component"></param>
/// <param name="args"></param>
private void OnUseInHand(EntityUid uid, PuppetDummyComponent component, UseInHandEvent args)
{
if (args.Handled)
return;
var userHands = Comp<HandsComponent>(args.User);
if (userHands.ActiveHandEntity == uid && HasComp<MutedComponent>(uid))
{
RemComp<MutedComponent>(uid);
_popupSystem.PopupEntity(Loc.GetString("dummy-insert-hand"), uid, args.User);
_popupSystem.PopupEntity(Loc.GetString("dummy-inserted-hand"), uid, uid);
AddComp<CombatModeComponent>(uid);
if (!HasComp<GhostTakeoverAvailableComponent>(uid))
{
EnsureComp<GhostTakeoverAvailableComponent>(uid);
var ghostRole = AddComp<GhostRoleComponent>(uid);
ghostRole.RoleName = Loc.GetString("dummy-role-name");
ghostRole.RoleDescription = Loc.GetString("dummy-role-description");
}
}
else if (userHands.ActiveHandEntity == uid && !HasComp<MutedComponent>(uid))
{
_popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
args.Handled = true;
}
/// <summary>
/// When dropped the dummy is muted again.
/// </summary>
private void OnDropped(EntityUid uid, PuppetDummyComponent component, DroppedEvent args)
{
if (HasComp<MutedComponent>(uid))
return;
_popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
/// <summary>
/// When unequipped from a hand slot the dummy is muted again.
/// </summary>
private void OnUnequippedHand(EntityUid uid, PuppetDummyComponent component, GotUnequippedHandEvent args)
{
if (HasComp<MutedComponent>(uid))
return;
_popupSystem.PopupEntity(Loc.GetString("dummy-remove-hand"), uid, args.User);
MuteDummy(uid, component);
}
/// <summary>
/// Mutes the dummy.
/// </summary>
private void MuteDummy(EntityUid uid, PuppetDummyComponent component)
{
_popupSystem.PopupEntity(Loc.GetString("dummy-removed-hand"), uid, uid);
AddComp<MutedComponent>(uid);
RemComp<CombatModeComponent>(uid);
}
}
}

View File

@@ -4,6 +4,7 @@ using Content.Server.Popups;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Puppet;
using Content.Shared.Speech;
namespace Content.Server.Speech.Muting
@@ -36,6 +37,7 @@ namespace Content.Server.Speech.Muting
if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Handled = true;
@@ -46,8 +48,13 @@ namespace Content.Server.Speech.Muting
{
if (HasComp<MimePowersComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("mime-cant-speak"), uid, uid);
if (HasComp<PuppetDummyComponent>(uid))
_popupSystem.PopupEntity(Loc.GetString("dummy-cant-speak"), uid, uid);
else
_popupSystem.PopupEntity(Loc.GetString("speech-muted"), uid, uid);
args.Cancel();
}
}

View File

@@ -0,0 +1,40 @@
using Content.Shared.Damage;
using Robust.Shared.Audio;
namespace Content.Server.Weapons.Melee.WeaponRandom;
[RegisterComponent]
internal sealed class WeaponRandomComponent : Component
{
/// <summary>
/// Amount of damage that will be caused. This is specified in the yaml.
/// </summary>
[DataField("damageBonus")]
public DamageSpecifier DamageBonus = new();
/// <summary>
/// Chance for the damage bonus to occur.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float RandomDamageChance = 0.00001f;
/// <summary>
/// If this is true then the random damage will occur.
/// </summary>
[DataField("randomDamage")]
public bool RandomDamage = true;
/// <summary>
/// If this is true then the weapon will have a unique interaction with cluwnes.
/// </summary>
[DataField("antiCluwne")]
public bool AntiCluwne = true;
/// <summary>
/// Noise to play when the damage bonus occurs.
/// </summary>
[DataField("damageSound")]
public SoundSpecifier DamageSound = new SoundPathSpecifier("/Audio/Items/bikehorn.ogg");
}

View File

@@ -0,0 +1,36 @@
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Random;
using Content.Shared.Cluwne;
namespace Content.Server.Weapons.Melee.WeaponRandom;
public sealed class WeaponRandomSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WeaponRandomComponent, MeleeHitEvent>(OnMeleeHit);
}
private void OnMeleeHit(EntityUid uid, WeaponRandomComponent component, MeleeHitEvent args)
{
foreach (var entity in args.HitEntities)
{
if (HasComp<CluwneComponent>(entity) && component.AntiCluwne)
{
_audio.PlayPvs(component.DamageSound, uid);
args.BonusDamage = component.DamageBonus;
}
else if (_random.Prob(component.RandomDamageChance) && component.RandomDamage)
{
_audio.PlayPvs(component.DamageSound, uid);
args.BonusDamage = component.DamageBonus;
}
}
}
}