Merge pull request #911 from Zumorica/2020-05-13-stuns
Adds StunnableComponent, Stunbaton...
@@ -101,6 +101,7 @@ namespace Content.Client.GameObjects
|
|||||||
ActiveIndex = cast.ActiveIndex;
|
ActiveIndex = cast.ActiveIndex;
|
||||||
|
|
||||||
_gui?.UpdateHandIcons();
|
_gui?.UpdateHandIcons();
|
||||||
|
RefreshInHands();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _setHand(string hand, IEntity entity)
|
private void _setHand(string hand, IEntity entity)
|
||||||
@@ -116,7 +117,19 @@ namespace Content.Client.GameObjects
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = entity.GetComponent<ItemComponent>();
|
SetInHands(hand, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetInHands(string hand, IEntity entity)
|
||||||
|
{
|
||||||
|
if (entity == null)
|
||||||
|
{
|
||||||
|
_sprite.LayerSetVisible($"hand-{hand}", false);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!entity.TryGetComponent(out ItemComponent item)) return;
|
||||||
var maybeInhands = item.GetInHandStateInfo(hand);
|
var maybeInhands = item.GetInHandStateInfo(hand);
|
||||||
if (!maybeInhands.HasValue)
|
if (!maybeInhands.HasValue)
|
||||||
{
|
{
|
||||||
@@ -130,6 +143,16 @@ namespace Content.Client.GameObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RefreshInHands()
|
||||||
|
{
|
||||||
|
if (!Initialized) return;
|
||||||
|
|
||||||
|
foreach (var (hand, entity) in _hands)
|
||||||
|
{
|
||||||
|
SetInHands(hand, entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void ExposeData(ObjectSerializer serializer)
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
{
|
{
|
||||||
base.ExposeData(serializer);
|
base.ExposeData(serializer);
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ using Content.Shared.GameObjects.Components.Items;
|
|||||||
using Robust.Client.Graphics;
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.Interfaces.ResourceManagement;
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components.Renderable;
|
using Robust.Shared.GameObjects.Components.Renderable;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -26,7 +28,13 @@ namespace Content.Client.GameObjects
|
|||||||
public string EquippedPrefix
|
public string EquippedPrefix
|
||||||
{
|
{
|
||||||
get => _equippedPrefix;
|
get => _equippedPrefix;
|
||||||
set => _equippedPrefix = value;
|
set
|
||||||
|
{
|
||||||
|
_equippedPrefix = value;
|
||||||
|
if (!ContainerHelpers.TryGetContainer(Owner, out IContainer container)) return;
|
||||||
|
if(container.Owner.TryGetComponent(out HandsComponent hands))
|
||||||
|
hands.RefreshInHands();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public (RSI rsi, RSI.StateId stateId)? GetInHandStateInfo(string hand)
|
public (RSI rsi, RSI.StateId stateId)? GetInHandStateInfo(string hand)
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using System;
|
||||||
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Microsoft.CodeAnalysis.Completion;
|
||||||
|
using Robust.Client.Animations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.GameObjects.Components.Animations;
|
||||||
using Robust.Client.Interfaces.GameObjects.Components;
|
using Robust.Client.Interfaces.GameObjects.Components;
|
||||||
|
using Robust.Shared.Animations;
|
||||||
using Robust.Shared.Maths;
|
using Robust.Shared.Maths;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components.Mobs
|
namespace Content.Client.GameObjects.Components.Mobs
|
||||||
@@ -11,19 +16,51 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
{
|
{
|
||||||
base.OnChangeData(component);
|
base.OnChangeData(component);
|
||||||
|
|
||||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
|
||||||
if (component.TryGetData<SharedSpeciesComponent.MobState>(SharedSpeciesComponent.MobVisuals.RotationState, out var state))
|
if (component.TryGetData<SharedSpeciesComponent.MobState>(SharedSpeciesComponent.MobVisuals.RotationState, out var state))
|
||||||
{
|
{
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case SharedSpeciesComponent.MobState.Stand:
|
case SharedSpeciesComponent.MobState.Standing:
|
||||||
sprite.Rotation = 0;
|
SetRotation(component, 0);
|
||||||
break;
|
break;
|
||||||
case SharedSpeciesComponent.MobState.Down:
|
case SharedSpeciesComponent.MobState.Down:
|
||||||
sprite.Rotation = Angle.FromDegrees(90);
|
SetRotation(component, Angle.FromDegrees(90));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetRotation(AppearanceComponent component, Angle rotation)
|
||||||
|
{
|
||||||
|
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||||
|
|
||||||
|
if (!sprite.Owner.TryGetComponent(out AnimationPlayerComponent animation))
|
||||||
|
{
|
||||||
|
sprite.Rotation = rotation;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (animation.HasRunningAnimation("rotate"))
|
||||||
|
animation.Stop("rotate");
|
||||||
|
|
||||||
|
animation.Play(new Animation
|
||||||
|
{
|
||||||
|
Length = TimeSpan.FromSeconds(0.125),
|
||||||
|
AnimationTracks =
|
||||||
|
{
|
||||||
|
new AnimationTrackComponentProperty
|
||||||
|
{
|
||||||
|
ComponentType = typeof(ISpriteComponent),
|
||||||
|
Property = nameof(ISpriteComponent.Rotation),
|
||||||
|
InterpolationMode = AnimationInterpolationMode.Linear,
|
||||||
|
KeyFrames =
|
||||||
|
{
|
||||||
|
new AnimationTrackProperty.KeyFrame(sprite.Rotation, 0),
|
||||||
|
new AnimationTrackProperty.KeyFrame(rotation, 0.125f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, "rotate");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,6 @@ namespace Content.Client.Interfaces.GameObjects
|
|||||||
void AttackByInHand(string index);
|
void AttackByInHand(string index);
|
||||||
void UseActiveHand();
|
void UseActiveHand();
|
||||||
void ActivateItemInHand(string handIndex);
|
void ActivateItemInHand(string handIndex);
|
||||||
|
void RefreshInHands();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks.Dataflow;
|
||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.Container;
|
using Robust.Server.GameObjects.Components.Container;
|
||||||
@@ -129,6 +130,9 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
var pass = false;
|
var pass = false;
|
||||||
|
|
||||||
|
if (!ActionBlockerSystem.CanEquip(Owner))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (item is ClothingComponent clothing)
|
if (item is ClothingComponent clothing)
|
||||||
{
|
{
|
||||||
if (clothing.SlotFlags != SlotFlags.PREVENTEQUIP && (clothing.SlotFlags & SlotMasks[slot]) != 0)
|
if (clothing.SlotFlags != SlotFlags.PREVENTEQUIP && (clothing.SlotFlags & SlotMasks[slot]) != 0)
|
||||||
@@ -185,6 +189,9 @@ namespace Content.Server.GameObjects
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
public bool CanUnequip(Slots slot)
|
public bool CanUnequip(Slots slot)
|
||||||
{
|
{
|
||||||
|
if (!ActionBlockerSystem.CanUnequip(Owner))
|
||||||
|
return false;
|
||||||
|
|
||||||
var InventorySlot = SlotContainers[slot];
|
var InventorySlot = SlotContainers[slot];
|
||||||
return InventorySlot.ContainedEntity != null && InventorySlot.CanRemove(InventorySlot.ContainedEntity);
|
return InventorySlot.ContainedEntity != null && InventorySlot.CanRemove(InventorySlot.ContainedEntity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using Robust.Shared.Containers;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.Map;
|
using Robust.Shared.Interfaces.Map;
|
||||||
using Robust.Shared.Interfaces.Physics;
|
using Robust.Shared.Interfaces.Physics;
|
||||||
using Robust.Shared.Interfaces.Random;
|
using Robust.Shared.Interfaces.Random;
|
||||||
@@ -48,8 +49,8 @@ namespace Content.Server.GameObjects
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
Dirty();
|
|
||||||
_equippedPrefix = value;
|
_equippedPrefix = value;
|
||||||
|
Dirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
using Content.Server.GameObjects.EntitySystems;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Server.Mobs;
|
||||||
|
using Content.Shared.Audio;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects
|
namespace Content.Server.GameObjects
|
||||||
{
|
{
|
||||||
@@ -77,6 +83,21 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEquip()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanUnequip()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanChangeDirection()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -86,10 +107,15 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
public void EnterState(IEntity entity)
|
public void EnterState(IEntity entity)
|
||||||
{
|
{
|
||||||
|
if(entity.TryGetComponent(out StunnableComponent stun))
|
||||||
|
stun.CancelAll();
|
||||||
|
|
||||||
|
StandingStateHelper.Down(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExitState(IEntity entity)
|
public void ExitState(IEntity entity)
|
||||||
{
|
{
|
||||||
|
StandingStateHelper.Standing(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsConscious => false;
|
public bool IsConscious => false;
|
||||||
@@ -138,6 +164,21 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEquip()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanUnequip()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanChangeDirection()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -147,11 +188,10 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
public void EnterState(IEntity entity)
|
public void EnterState(IEntity entity)
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out AppearanceComponent appearance))
|
if(entity.TryGetComponent(out StunnableComponent stun))
|
||||||
{
|
stun.CancelAll();
|
||||||
var newState = SharedSpeciesComponent.MobState.Down;
|
|
||||||
appearance.SetData(SharedSpeciesComponent.MobVisuals.RotationState, newState);
|
StandingStateHelper.Down(entity, playSound:false);
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidable))
|
if (entity.TryGetComponent(out CollidableComponent collidable))
|
||||||
{
|
{
|
||||||
@@ -161,11 +201,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
public void ExitState(IEntity entity)
|
public void ExitState(IEntity entity)
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out AppearanceComponent appearance))
|
StandingStateHelper.Standing(entity);
|
||||||
{
|
|
||||||
var newState = SharedSpeciesComponent.MobState.Stand;
|
|
||||||
appearance.SetData(SharedSpeciesComponent.MobVisuals.RotationState, newState);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidable))
|
if (entity.TryGetComponent(out CollidableComponent collidable))
|
||||||
{
|
{
|
||||||
@@ -219,5 +255,20 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEquip()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanUnequip()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanChangeDirection()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
332
Content.Server/GameObjects/Components/Mobs/StunnableComponent.cs
Normal file
@@ -0,0 +1,332 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Server.Interfaces.GameObjects;
|
||||||
|
using Content.Server.Mobs;
|
||||||
|
using Content.Shared.Audio;
|
||||||
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Timers;
|
||||||
|
using Robust.Shared.Interfaces.Timing;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Maths;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
using Timer = Robust.Shared.Timers.Timer;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Mobs
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class StunnableComponent : Component, IActionBlocker, IAttackHand, IMoveSpeedModifier
|
||||||
|
{
|
||||||
|
public override string Name => "Stunnable";
|
||||||
|
|
||||||
|
#pragma warning disable 649
|
||||||
|
[Dependency] private IEntitySystemManager _entitySystemManager;
|
||||||
|
[Dependency] private IGameTiming _gameTiming;
|
||||||
|
#pragma warning restore 649
|
||||||
|
|
||||||
|
private TimeSpan? _lastStun;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public TimeSpan? StunStart => _lastStun;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public TimeSpan? StunEnd => _lastStun == null
|
||||||
|
? (TimeSpan?) null
|
||||||
|
: _gameTiming.CurTime + TimeSpan.FromSeconds(_stunnedTimer + _knockdownTimer + _slowdownTimer);
|
||||||
|
|
||||||
|
private const int StunLevels = 8;
|
||||||
|
|
||||||
|
private bool _canHelp = true;
|
||||||
|
private float _stunCap = 20f;
|
||||||
|
private float _knockdownCap = 20f;
|
||||||
|
private float _slowdownCap = 20f;
|
||||||
|
private float _helpKnockdownRemove = 1f;
|
||||||
|
private float _helpInterval = 1f;
|
||||||
|
|
||||||
|
private float _stunnedTimer = 0f;
|
||||||
|
private float _knockdownTimer = 0f;
|
||||||
|
private float _slowdownTimer = 0f;
|
||||||
|
|
||||||
|
private float _walkModifierOverride = 0f;
|
||||||
|
private float _runModifierOverride = 0f;
|
||||||
|
private readonly string[] _texturesStunOverlay = new string[StunLevels];
|
||||||
|
|
||||||
|
[ViewVariables] public bool Stunned => _stunnedTimer > 0f;
|
||||||
|
[ViewVariables] public bool KnockedDown => _knockdownTimer > 0f;
|
||||||
|
[ViewVariables] public bool SlowedDown => _slowdownTimer > 0f;
|
||||||
|
[ViewVariables] public float StunCap => _stunCap;
|
||||||
|
[ViewVariables] public float KnockdownCap => _knockdownCap;
|
||||||
|
[ViewVariables] public float SlowdownCap => _slowdownCap;
|
||||||
|
|
||||||
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
base.ExposeData(serializer);
|
||||||
|
serializer.DataField(ref _stunCap, "stunCap", 20f);
|
||||||
|
serializer.DataField(ref _knockdownCap, "knockdownCap", 20f);
|
||||||
|
serializer.DataField(ref _slowdownCap, "slowdownCap", 20f);
|
||||||
|
serializer.DataField(ref _helpInterval, "helpInterval", 1f);
|
||||||
|
serializer.DataField(ref _helpKnockdownRemove, "helpKnockdownRemove", 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
for (var i = 0; i < StunLevels; i++)
|
||||||
|
{
|
||||||
|
_texturesStunOverlay[i] = $"/Textures/UserInterface/Inventory/cooldown-{i}.png";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Stuns the entity, disallowing it from doing many interactions temporarily.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seconds">How many seconds the mob will stay stunned</param>
|
||||||
|
public void Stun(float seconds)
|
||||||
|
{
|
||||||
|
seconds = MathF.Min(_stunnedTimer + (seconds * StunTimeModifier), _stunCap);
|
||||||
|
|
||||||
|
if (seconds <= 0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StandingStateHelper.DropAllItemsInHands(Owner);
|
||||||
|
|
||||||
|
_stunnedTimer = seconds;
|
||||||
|
_lastStun = _gameTiming.CurTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Knocks down the mob, making it fall to the ground.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seconds">How many seconds the mob will stay on the ground</param>
|
||||||
|
public void Knockdown(float seconds)
|
||||||
|
{
|
||||||
|
seconds = MathF.Min(_knockdownTimer + (seconds * KnockdownTimeModifier), _knockdownCap);
|
||||||
|
|
||||||
|
if (seconds <= 0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
StandingStateHelper.Down(Owner);
|
||||||
|
|
||||||
|
_knockdownTimer = seconds;
|
||||||
|
_lastStun = _gameTiming.CurTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies knockdown and stun to the mob temporarily
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seconds">How many seconds the mob will be paralyzed</param>
|
||||||
|
public void Paralyze(float seconds)
|
||||||
|
{
|
||||||
|
Stun(seconds);
|
||||||
|
Knockdown(seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Slows down the mob's walking/running speed temporarily
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="seconds">How many seconds the mob will be slowed down</param>
|
||||||
|
/// <param name="walkModifierOverride">Walk speed modifier. Set to 0 or negative for default value. (0.5f)</param>
|
||||||
|
/// <param name="runModifierOverride">Run speed modifier. Set to 0 or negative for default value. (0.5f)</param>
|
||||||
|
public void Slowdown(float seconds, float walkModifierOverride = 0f, float runModifierOverride = 0f)
|
||||||
|
{
|
||||||
|
seconds = MathF.Min(_slowdownTimer + (seconds * SlowdownTimeModifier), _slowdownCap);
|
||||||
|
|
||||||
|
if (seconds <= 0f)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_walkModifierOverride = walkModifierOverride;
|
||||||
|
_runModifierOverride = runModifierOverride;
|
||||||
|
|
||||||
|
_slowdownTimer = seconds;
|
||||||
|
_lastStun = _gameTiming.CurTime;
|
||||||
|
|
||||||
|
if(Owner.TryGetComponent(out MovementSpeedModifierComponent movement))
|
||||||
|
movement.RefreshMovementSpeedModifiers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used when
|
||||||
|
/// </summary>
|
||||||
|
public void CancelAll()
|
||||||
|
{
|
||||||
|
_knockdownTimer = 0f;
|
||||||
|
_stunnedTimer = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AttackHand(AttackHandEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
if (!_canHelp || !KnockedDown)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_canHelp = false;
|
||||||
|
Timer.Spawn(((int)_helpInterval*1000), () => _canHelp = true);
|
||||||
|
|
||||||
|
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
||||||
|
.Play("/Audio/effects/thudswoosh.ogg", Owner, AudioHelpers.WithVariation(0.25f));
|
||||||
|
|
||||||
|
_knockdownTimer -= _helpKnockdownRemove;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(float delta)
|
||||||
|
{
|
||||||
|
if (Stunned)
|
||||||
|
{
|
||||||
|
_stunnedTimer -= delta;
|
||||||
|
|
||||||
|
if (_stunnedTimer <= 0)
|
||||||
|
{
|
||||||
|
_stunnedTimer = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (KnockedDown)
|
||||||
|
{
|
||||||
|
_knockdownTimer -= delta;
|
||||||
|
|
||||||
|
if (_knockdownTimer <= 0f)
|
||||||
|
{
|
||||||
|
StandingStateHelper.Standing(Owner);
|
||||||
|
|
||||||
|
_knockdownTimer = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SlowedDown)
|
||||||
|
{
|
||||||
|
_slowdownTimer -= delta;
|
||||||
|
|
||||||
|
if (_slowdownTimer <= 0f)
|
||||||
|
{
|
||||||
|
_slowdownTimer = 0f;
|
||||||
|
|
||||||
|
if(Owner.TryGetComponent(out MovementSpeedModifierComponent movement))
|
||||||
|
movement.RefreshMovementSpeedModifiers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_lastStun.HasValue || !StunEnd.HasValue || !Owner.TryGetComponent(out ServerStatusEffectsComponent status))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var start = _lastStun.Value;
|
||||||
|
var end = StunEnd.Value;
|
||||||
|
|
||||||
|
var length = (end - start).TotalSeconds;
|
||||||
|
var progress = (_gameTiming.CurTime - start).TotalSeconds;
|
||||||
|
var ratio = (float)(progress / length);
|
||||||
|
|
||||||
|
var textureIndex = CalculateStunLevel(ratio);
|
||||||
|
if (textureIndex == StunLevels)
|
||||||
|
{
|
||||||
|
_lastStun = null;
|
||||||
|
status.RemoveStatus(StatusEffect.Stun);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status.ChangeStatus(StatusEffect.Stun, _texturesStunOverlay[textureIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int CalculateStunLevel(float stunValue)
|
||||||
|
{
|
||||||
|
var val = stunValue.Clamp(0, 1);
|
||||||
|
val *= StunLevels;
|
||||||
|
return (int)Math.Floor(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ActionBlockers
|
||||||
|
public bool CanMove() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanInteract() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanUse() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanThrow() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanSpeak() => true;
|
||||||
|
|
||||||
|
public bool CanDrop() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanPickup() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanEmote() => true;
|
||||||
|
|
||||||
|
public bool CanAttack() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanEquip() => (!Stunned);
|
||||||
|
|
||||||
|
public bool CanUnequip() => (!Stunned);
|
||||||
|
public bool CanChangeDirection() => true;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public float StunTimeModifier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var modifier = 1.0f;
|
||||||
|
var components = Owner.GetAllComponents<IStunModifier>();
|
||||||
|
|
||||||
|
foreach (var component in components)
|
||||||
|
{
|
||||||
|
modifier *= component.StunTimeModifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float KnockdownTimeModifier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var modifier = 1.0f;
|
||||||
|
var components = Owner.GetAllComponents<IStunModifier>();
|
||||||
|
|
||||||
|
foreach (var component in components)
|
||||||
|
{
|
||||||
|
modifier *= component.KnockdownTimeModifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float SlowdownTimeModifier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var modifier = 1.0f;
|
||||||
|
var components = Owner.GetAllComponents<IStunModifier>();
|
||||||
|
|
||||||
|
foreach (var component in components)
|
||||||
|
{
|
||||||
|
modifier *= component.SlowdownTimeModifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public float WalkSpeedModifier => (SlowedDown ? (_walkModifierOverride <= 0f ? 0.5f : _walkModifierOverride) : 1f);
|
||||||
|
public float SprintSpeedModifier => (SlowedDown ? (_runModifierOverride <= 0f ? 0.5f : _runModifierOverride) : 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This interface allows components to multiply the time in seconds of various stuns by a number.
|
||||||
|
/// </summary>
|
||||||
|
public interface IStunModifier
|
||||||
|
{
|
||||||
|
float StunTimeModifier => 1.0f;
|
||||||
|
float KnockdownTimeModifier => 1.0f;
|
||||||
|
float SlowdownTimeModifier => 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,6 +75,11 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
serializer.DataField(ref _cooldownTime, "cooldownTime", 1f);
|
serializer.DataField(ref _cooldownTime, "cooldownTime", 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool OnHitEntities(IReadOnlyList<IEntity> entities)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void IAttack.Attack(AttackEventArgs eventArgs)
|
void IAttack.Attack(AttackEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
var curTime = IoCManager.Resolve<IGameTiming>().CurTime;
|
||||||
@@ -101,6 +106,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Melee
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(OnHitEntities(hitEntities)) return;
|
||||||
|
|
||||||
var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
var audioSystem = _entitySystemManager.GetEntitySystem<AudioSystem>();
|
||||||
var emitter = hitEntities.Count == 0 ? eventArgs.User : hitEntities[0];
|
var emitter = hitEntities.Count == 0 ? eventArgs.User : hitEntities[0];
|
||||||
audioSystem.Play(hitEntities.Count > 0 ? _hitSound : "/Audio/weapons/punchmiss.ogg", emitter);
|
audioSystem.Play(hitEntities.Count > 0 ? _hitSound : "/Audio/weapons/punchmiss.ogg", emitter);
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
|
using Content.Server.GameObjects.EntitySystems;
|
||||||
|
using Content.Shared.Audio;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Random;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Weapon.Melee
|
||||||
|
{
|
||||||
|
[RegisterComponent]
|
||||||
|
public class StunbatonComponent : MeleeWeaponComponent, IUse
|
||||||
|
{
|
||||||
|
[Dependency] private IRobustRandom _robustRandom;
|
||||||
|
[Dependency] private IEntitySystemManager _entitySystemManager;
|
||||||
|
|
||||||
|
public override string Name => "Stunbaton";
|
||||||
|
|
||||||
|
private bool _activated = false;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
private float _paralyzeChance = 0.25f;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
private float _paralyzeTime = 10f;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
private float _slowdownTime = 5f;
|
||||||
|
|
||||||
|
[ViewVariables]
|
||||||
|
public bool Activated => _activated;
|
||||||
|
|
||||||
|
public override void ExposeData(ObjectSerializer serializer)
|
||||||
|
{
|
||||||
|
base.ExposeData(serializer);
|
||||||
|
|
||||||
|
serializer.DataField(ref _paralyzeChance, "paralyzeChance", 0.25f);
|
||||||
|
serializer.DataField(ref _paralyzeTime, "paralyzeTime", 10f);
|
||||||
|
serializer.DataField(ref _slowdownTime, "slowdownTime", 5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool OnHitEntities(IReadOnlyList<IEntity> entities)
|
||||||
|
{
|
||||||
|
if (!Activated || entities.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
||||||
|
.Play("/Audio/weapons/egloves.ogg", Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
|
||||||
|
|
||||||
|
foreach (var entity in entities)
|
||||||
|
{
|
||||||
|
if (!entity.TryGetComponent(out StunnableComponent stunnable)) continue;
|
||||||
|
|
||||||
|
if(_robustRandom.Prob(_paralyzeChance))
|
||||||
|
stunnable.Paralyze(_paralyzeTime);
|
||||||
|
else
|
||||||
|
stunnable.Slowdown(_slowdownTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UseEntity(UseEntityEventArgs eventArgs)
|
||||||
|
{
|
||||||
|
var sprite = Owner.GetComponent<SpriteComponent>();
|
||||||
|
var item = Owner.GetComponent<ItemComponent>();
|
||||||
|
|
||||||
|
if (_activated)
|
||||||
|
{
|
||||||
|
item.EquippedPrefix = "off";
|
||||||
|
sprite.LayerSetState(0, "stunbaton_off");
|
||||||
|
_activated = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_entitySystemManager.GetEntitySystem<AudioSystem>()
|
||||||
|
.Play(AudioHelpers.GetRandomFileFromSoundCollection("sparks"), Owner.Transform.GridPosition, AudioHelpers.WithVariation(0.25f));
|
||||||
|
|
||||||
|
item.EquippedPrefix = "on";
|
||||||
|
sprite.LayerSetState(0, "stunbaton_on");
|
||||||
|
_activated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
bool CanEmote() => true;
|
bool CanEmote() => true;
|
||||||
|
|
||||||
bool CanAttack() => true;
|
bool CanAttack() => true;
|
||||||
|
bool CanEquip() => true;
|
||||||
|
bool CanUnequip() => true;
|
||||||
|
bool CanChangeDirection() => true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionBlockerSystem : EntitySystem
|
public class ActionBlockerSystem : EntitySystem
|
||||||
@@ -119,5 +122,41 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
return canattack;
|
return canattack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CanEquip(IEntity entity)
|
||||||
|
{
|
||||||
|
bool canequip = true;
|
||||||
|
|
||||||
|
foreach (var actionblockercomponents in entity.GetAllComponents<IActionBlocker>())
|
||||||
|
{
|
||||||
|
canequip &= actionblockercomponents.CanEquip();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canequip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CanUnequip(IEntity entity)
|
||||||
|
{
|
||||||
|
bool canunequip = true;
|
||||||
|
|
||||||
|
foreach (var actionblockercomponents in entity.GetAllComponents<IActionBlocker>())
|
||||||
|
{
|
||||||
|
canunequip &= actionblockercomponents.CanUnequip();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canunequip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CanChangeDirection(IEntity entity)
|
||||||
|
{
|
||||||
|
bool canchangedirection = true;
|
||||||
|
|
||||||
|
foreach (var actionblockercomponents in entity.GetAllComponents<IActionBlocker>())
|
||||||
|
{
|
||||||
|
canchangedirection &= actionblockercomponents.CanChangeDirection();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canchangedirection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,13 +451,14 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
|
|
||||||
var item = hands.GetActiveHand?.Owner;
|
var item = hands.GetActiveHand?.Owner;
|
||||||
|
|
||||||
|
if(ActionBlockerSystem.CanChangeDirection(player))
|
||||||
|
playerTransform.LocalRotation = new Angle(coordinates.ToMapPos(_mapManager) - playerTransform.MapPosition.Position);
|
||||||
|
|
||||||
if (!ActionBlockerSystem.CanInteract(player))
|
if (!ActionBlockerSystem.CanInteract(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerTransform.LocalRotation = new Angle(coordinates.ToMapPos(_mapManager) - playerTransform.MapPosition.Position);
|
|
||||||
|
|
||||||
// TODO: Check if client should be able to see that object to click on it in the first place
|
// TODO: Check if client should be able to see that object to click on it in the first place
|
||||||
|
|
||||||
// Clicked on empty space behavior, try using ranged attack
|
// Clicked on empty space behavior, try using ranged attack
|
||||||
|
|||||||
28
Content.Server/GameObjects/EntitySystems/StunSystem.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
|
{
|
||||||
|
public class StunSystem : EntitySystem
|
||||||
|
{
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
EntityQuery = new TypeEntityQuery(typeof(StunnableComponent));
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
base.Update(frameTime);
|
||||||
|
|
||||||
|
foreach (var entity in RelevantEntities)
|
||||||
|
{
|
||||||
|
entity.GetComponent<StunnableComponent>().Update(frameTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
74
Content.Server/Mobs/StandingStateHelper.cs
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
using Content.Server.Interfaces.GameObjects;
|
||||||
|
using Content.Shared.Audio;
|
||||||
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.Random;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
|
namespace Content.Server.Mobs
|
||||||
|
{
|
||||||
|
public static class StandingStateHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Set's the mob standing state to down.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The mob in question</param>
|
||||||
|
/// <param name="playSound">Whether to play a sound when falling down or not</param>
|
||||||
|
/// <param name="dropItems">Whether to make the mob drop all the items on his hands</param>
|
||||||
|
/// <returns>False if the mob was already downed or couldn't set the state</returns>
|
||||||
|
public static bool Down(IEntity entity, bool playSound = true, bool dropItems = true)
|
||||||
|
{
|
||||||
|
if (!entity.TryGetComponent(out AppearanceComponent appearance)) return false;
|
||||||
|
|
||||||
|
appearance.TryGetData<SharedSpeciesComponent.MobState>(SharedSpeciesComponent.MobVisuals.RotationState, out var oldState);
|
||||||
|
|
||||||
|
var newState = SharedSpeciesComponent.MobState.Down;
|
||||||
|
if (newState == oldState)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
appearance.SetData(SharedSpeciesComponent.MobVisuals.RotationState, newState);
|
||||||
|
|
||||||
|
if (playSound)
|
||||||
|
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AudioSystem>()
|
||||||
|
.Play(AudioHelpers.GetRandomFileFromSoundCollection("bodyfall"), entity, AudioHelpers.WithVariation(0.25f));
|
||||||
|
|
||||||
|
if(dropItems)
|
||||||
|
DropAllItemsInHands(entity);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the mob's standing state to standing.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">The mob in question.</param>
|
||||||
|
/// <returns>False if the mob was already standing or couldn't set the state</returns>
|
||||||
|
public static bool Standing(IEntity entity)
|
||||||
|
{
|
||||||
|
if (!entity.TryGetComponent(out AppearanceComponent appearance)) return false;
|
||||||
|
appearance.TryGetData<SharedSpeciesComponent.MobState>(SharedSpeciesComponent.MobVisuals.RotationState, out var oldState);
|
||||||
|
var newState = SharedSpeciesComponent.MobState.Standing;
|
||||||
|
if (newState == oldState)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
appearance.SetData(SharedSpeciesComponent.MobVisuals.RotationState, newState);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DropAllItemsInHands(IEntity entity)
|
||||||
|
{
|
||||||
|
if (!entity.TryGetComponent(out IHandsComponent hands)) return;
|
||||||
|
|
||||||
|
foreach (var heldItem in hands.GetAllHeldItems())
|
||||||
|
{
|
||||||
|
hands.Drop(heldItem.Owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,9 +2,12 @@ using System;
|
|||||||
using Content.Shared.GameObjects.Components.Sound;
|
using Content.Shared.GameObjects.Components.Sound;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
using Robust.Shared.Interfaces.Random;
|
using Robust.Shared.Interfaces.Random;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Log;
|
using Robust.Shared.Log;
|
||||||
|
using Robust.Shared.Map;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Shared.Audio
|
namespace Content.Shared.Audio
|
||||||
@@ -18,5 +21,11 @@ namespace Content.Shared.Audio
|
|||||||
var scale = (float)(IoCManager.Resolve<IRobustRandom>().NextGaussian(1, amplitude));
|
var scale = (float)(IoCManager.Resolve<IRobustRandom>().NextGaussian(1, amplitude));
|
||||||
return AudioParams.Default.WithPitchScale(scale);
|
return AudioParams.Default.WithPitchScale(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetRandomFileFromSoundCollection(string name)
|
||||||
|
{
|
||||||
|
var soundCollection = IoCManager.Resolve<IPrototypeManager>().Index<SoundCollectionPrototype>(name);
|
||||||
|
return IoCManager.Resolve<IRobustRandom>().Pick(soundCollection.PickFiles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mob is standing up
|
/// Mob is standing up
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Stand,
|
Standing,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mob is laying down
|
/// Mob is laying down
|
||||||
|
|||||||
@@ -32,5 +32,6 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
|||||||
Health,
|
Health,
|
||||||
Hunger,
|
Hunger,
|
||||||
Thirst,
|
Thirst,
|
||||||
|
Stun,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Resources/Audio/effects/Egloves.ogg
Normal file
BIN
Resources/Audio/effects/bodyfall1.ogg
Normal file
BIN
Resources/Audio/effects/bodyfall2.ogg
Normal file
BIN
Resources/Audio/effects/bodyfall3.ogg
Normal file
BIN
Resources/Audio/effects/bodyfall4.ogg
Normal file
BIN
Resources/Audio/effects/sparks1.ogg
Normal file
BIN
Resources/Audio/effects/sparks2.ogg
Normal file
BIN
Resources/Audio/effects/sparks3.ogg
Normal file
BIN
Resources/Audio/effects/sparks4.ogg
Normal file
BIN
Resources/Audio/effects/thudswoosh.ogg
Normal file
BIN
Resources/Audio/weapons/egloves.ogg
Normal file
25
Resources/Prototypes/Entities/Items/Weapons/security.yml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
- type: entity
|
||||||
|
name: Stun baton
|
||||||
|
parent: BaseItem
|
||||||
|
id: Stunbaton
|
||||||
|
components:
|
||||||
|
- type: Sprite
|
||||||
|
sprite: Objects/Melee/stunbaton.rsi
|
||||||
|
state: stunbaton_off
|
||||||
|
|
||||||
|
- type: Icon
|
||||||
|
sprite: Objects/Melee/stunbaton.rsi
|
||||||
|
state: stunbaton_off
|
||||||
|
|
||||||
|
- type: Stunbaton
|
||||||
|
damage: 1
|
||||||
|
range: 0.75
|
||||||
|
arcwidth: 0
|
||||||
|
arc: default
|
||||||
|
|
||||||
|
- type: Item
|
||||||
|
Size: 10
|
||||||
|
sprite: Objects/Melee/stunbaton.rsi
|
||||||
|
HeldPrefix: off
|
||||||
|
|
||||||
|
- type: ItemCooldown
|
||||||
@@ -131,6 +131,8 @@
|
|||||||
- type: FootstepSound
|
- type: FootstepSound
|
||||||
- type: HumanoidAppearance
|
- type: HumanoidAppearance
|
||||||
- type: HumanInventoryController
|
- type: HumanInventoryController
|
||||||
|
- type: Stunnable
|
||||||
|
- type: AnimationPlayer
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
save: false
|
save: false
|
||||||
|
|||||||
7
Resources/Prototypes/SoundCollections/body_fall.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
- type: sound_collection
|
||||||
|
id: bodyfall
|
||||||
|
files:
|
||||||
|
- /Audio/effects/bodyfall1.ogg
|
||||||
|
- /Audio/effects/bodyfall2.ogg
|
||||||
|
- /Audio/effects/bodyfall3.ogg
|
||||||
|
- /Audio/effects/bodyfall4.ogg
|
||||||
7
Resources/Prototypes/SoundCollections/sparks.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
- type: sound_collection
|
||||||
|
id: sparks
|
||||||
|
files:
|
||||||
|
- /Audio/effects/sparks1.ogg
|
||||||
|
- /Audio/effects/sparks2.ogg
|
||||||
|
- /Audio/effects/sparks3.ogg
|
||||||
|
- /Audio/effects/sparks4.ogg
|
||||||
143
Resources/Textures/Objects/Melee/stunbaton.rsi/meta.json
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"license": "CC BY-SA 3.0",
|
||||||
|
"copyright": "Taken from https://github.com/vgstation-coders/vgstation13 at b8758256b31013946fdbd320ca043a663c399656",
|
||||||
|
"states":
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "off-inhand-left",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "off-inhand-right",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
],
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "on-inhand-left",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "on-inhand-right",
|
||||||
|
"directions": 4,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stunbaton_off",
|
||||||
|
"directions": 1,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stunbaton_nocell",
|
||||||
|
"directions": 1,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
1.0
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stunbaton_on",
|
||||||
|
"directions": 1,
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
0.1,
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
After Width: | Height: | Size: 259 B |
|
After Width: | Height: | Size: 261 B |
|
After Width: | Height: | Size: 807 B |
|
After Width: | Height: | Size: 789 B |
|
After Width: | Height: | Size: 431 B |
BIN
Resources/Textures/Objects/Melee/stunbaton.rsi/stunbaton_off.png
Normal file
|
After Width: | Height: | Size: 362 B |
BIN
Resources/Textures/Objects/Melee/stunbaton.rsi/stunbaton_on.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
@@ -55,4 +55,5 @@
|
|||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=prefs/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=prefs/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=soundfonts/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=soundfonts/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Stunnable/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
|
|||||||