Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,38 @@
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Random;
#nullable enable
namespace Content.Server.Interaction.Components
{
/// <summary>
/// A simple clumsy tag-component.
/// </summary>
[RegisterComponent]
public class ClumsyComponent : Component
{
[Dependency] private readonly IRobustRandom _random = default!;
public override string Name => "Clumsy";
public bool RollClumsy(float chance)
{
return Running && _random.Prob(chance);
}
/// <summary>
/// Rolls a probability chance for a "bad action" if the target entity is clumsy.
/// </summary>
/// <param name="entity">The entity that the clumsy check is happening for.</param>
/// <param name="chance">
/// The chance that a "bad action" happens if the user is clumsy, between 0 and 1 inclusive.
/// </param>
/// <returns>True if a "bad action" happened, false if the normal action should happen.</returns>
public static bool TryRollClumsy(IEntity entity, float chance)
{
return entity.TryGetComponent(out ClumsyComponent? clumsy)
&& clumsy.RollClumsy(chance);
}
}
}

View File

@@ -0,0 +1,45 @@
using Content.Shared.Audio;
using Content.Shared.Interaction;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Content.Server.Interaction.Components
{
/// <summary>
/// Simple sound emitter that emits sound on use in hand
/// </summary>
[RegisterComponent]
public class EmitSoundOnUseComponent : Component, IUse
{
/// <inheritdoc />
///
public override string Name => "EmitSoundOnUse";
[ViewVariables(VVAccess.ReadWrite)] [DataField("sound")] public string? _soundName;
[ViewVariables(VVAccess.ReadWrite)] [DataField("variation")] public float _pitchVariation;
[ViewVariables(VVAccess.ReadWrite)] [DataField("semitoneVariation")] public int _semitoneVariation;
bool IUse.UseEntity(UseEntityEventArgs eventArgs)
{
if (!string.IsNullOrWhiteSpace(_soundName))
{
if (_pitchVariation > 0.0)
{
SoundSystem.Play(Filter.Pvs(Owner), _soundName, Owner, AudioHelpers.WithVariation(_pitchVariation).WithVolume(-2f));
return true;
}
if (_semitoneVariation > 0)
{
SoundSystem.Play(Filter.Pvs(Owner), _soundName, Owner, AudioHelpers.WithSemitoneVariation(_semitoneVariation).WithVolume(-2f));
return true;
}
SoundSystem.Play(Filter.Pvs(Owner), _soundName, Owner, AudioParams.Default.WithVolume(-2f));
return true;
}
return false;
}
}
}