Re-organize all projects (#4166)
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using Content.Server.Stunnable.Components;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Damage.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class DamageOnHighSpeedImpactComponent : Component, IStartCollide
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override string Name => "DamageOnHighSpeedImpact";
|
||||
|
||||
[DataField("damage")]
|
||||
public DamageType Damage { get; set; } = DamageType.Blunt;
|
||||
[DataField("minimumSpeed")]
|
||||
public float MinimumSpeed { get; set; } = 20f;
|
||||
[DataField("baseDamage")]
|
||||
public int BaseDamage { get; set; } = 5;
|
||||
[DataField("factor")]
|
||||
public float Factor { get; set; } = 1f;
|
||||
[DataField("soundHit")]
|
||||
public string SoundHit { get; set; } = "";
|
||||
[DataField("stunChance")]
|
||||
public float StunChance { get; set; } = 0.25f;
|
||||
[DataField("stunMinimumDamage")]
|
||||
public int StunMinimumDamage { get; set; } = 10;
|
||||
[DataField("stunSeconds")]
|
||||
public float StunSeconds { get; set; } = 1f;
|
||||
[DataField("damageCooldown")]
|
||||
public float DamageCooldown { get; set; } = 2f;
|
||||
private TimeSpan _lastHit = TimeSpan.Zero;
|
||||
|
||||
void IStartCollide.CollideWith(Fixture ourFixture, Fixture otherFixture, in Manifold manifold)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IDamageableComponent? damageable)) return;
|
||||
|
||||
var speed = ourFixture.Body.LinearVelocity.Length;
|
||||
|
||||
if (speed < MinimumSpeed) return;
|
||||
|
||||
if (!string.IsNullOrEmpty(SoundHit))
|
||||
SoundSystem.Play(Filter.Pvs(otherFixture.Body.Owner), SoundHit, otherFixture.Body.Owner, AudioHelpers.WithVariation(0.125f).WithVolume(-0.125f));
|
||||
|
||||
if ((_gameTiming.CurTime - _lastHit).TotalSeconds < DamageCooldown)
|
||||
return;
|
||||
|
||||
_lastHit = _gameTiming.CurTime;
|
||||
|
||||
var damage = (int) (BaseDamage * (speed / MinimumSpeed) * Factor);
|
||||
|
||||
if (Owner.TryGetComponent(out StunnableComponent? stun) && _robustRandom.Prob(StunChance))
|
||||
stun.Stun(StunSeconds);
|
||||
|
||||
damageable.ChangeDamage(Damage, damage, false, otherFixture.Body.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Content.Server/Damage/Components/DamageOnLandComponent.cs
Normal file
30
Content.Server/Damage/Components/DamageOnLandComponent.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Damage.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class DamageOnLandComponent : Component, ILand
|
||||
{
|
||||
public override string Name => "DamageOnLand";
|
||||
|
||||
[DataField("damageType")]
|
||||
private DamageType _damageType = DamageType.Blunt;
|
||||
|
||||
[DataField("amount")]
|
||||
private int _amount = 1;
|
||||
|
||||
[DataField("ignoreResistances")]
|
||||
private bool _ignoreResistances;
|
||||
|
||||
void ILand.Land(LandEventArgs eventArgs)
|
||||
{
|
||||
if (!Owner.TryGetComponent(out IDamageableComponent? damageable)) return;
|
||||
|
||||
damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Tool;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Damage.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class DamageOnToolInteractComponent : Component, IInteractUsing
|
||||
{
|
||||
public override string Name => "DamageOnToolInteract";
|
||||
|
||||
[DataField("damage")]
|
||||
protected int Damage;
|
||||
|
||||
[DataField("tools")]
|
||||
private List<ToolQuality> _tools = new();
|
||||
|
||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (eventArgs.Using.TryGetComponent<ToolComponent>(out var tool))
|
||||
{
|
||||
foreach (var toolQuality in _tools)
|
||||
{
|
||||
if (tool.HasQuality(ToolQuality.Welding) && toolQuality == ToolQuality.Welding)
|
||||
{
|
||||
if (eventArgs.Using.TryGetComponent(out WelderComponent? welder))
|
||||
{
|
||||
if (welder.WelderLit) return CallDamage(eventArgs, tool);
|
||||
}
|
||||
break; //If the tool quality is welding and its not lit or its not actually a welder that can be lit then its pointless to continue.
|
||||
}
|
||||
|
||||
if (tool.HasQuality(toolQuality)) return CallDamage(eventArgs, tool);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected bool CallDamage(InteractUsingEventArgs eventArgs, ToolComponent tool)
|
||||
{
|
||||
if (eventArgs.Target.TryGetComponent<IDamageableComponent>(out var damageable))
|
||||
{
|
||||
damageable.ChangeDamage(tool.HasQuality(ToolQuality.Welding)
|
||||
? DamageType.Heat
|
||||
: DamageType.Blunt,
|
||||
Damage, false, eventArgs.User);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Damage.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class DamageOtherOnHitComponent : Component, IThrowCollide
|
||||
{
|
||||
public override string Name => "DamageOtherOnHit";
|
||||
|
||||
[DataField("damageType")]
|
||||
private DamageType _damageType = DamageType.Blunt;
|
||||
[DataField("amount")]
|
||||
private int _amount = 1;
|
||||
[DataField("ignoreResistances")]
|
||||
private bool _ignoreResistances;
|
||||
|
||||
void IThrowCollide.DoHit(ThrowCollideEventArgs eventArgs)
|
||||
{
|
||||
if (!eventArgs.Target.TryGetComponent(out IDamageableComponent? damageable)) return;
|
||||
|
||||
damageable.ChangeDamage(_damageType, _amount, _ignoreResistances, eventArgs.User);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user