-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Плач и крики при получении урона. (#50)
* фикс спонсорских лоадаутов * paws * чейнжлог
- Loading branch information
Showing
4 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Content.Shared.FixedPoint; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; | ||
|
||
namespace Content.Server.Sunrise.Paws | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class PawsComponent : Component | ||
{ | ||
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField("screamInterval")] | ||
public float ScreamInterval = 3; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField("coughInterval")] | ||
public float CoughInterval = 5; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField("thresholdDamage")] | ||
public FixedPoint2 ThresholdDamage = 5; | ||
|
||
public List<string> EmotesTakeDamage = new() | ||
{ | ||
"Scream", | ||
"Crying" | ||
}; | ||
|
||
[DataField("nextChargeTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan NextScreamTime = TimeSpan.FromSeconds(0); | ||
|
||
[DataField("nextCoughTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan NextCoughTime = TimeSpan.FromSeconds(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using Content.Server.Chat.Systems; | ||
using Content.Shared.Damage; | ||
using Content.Shared.Mobs; | ||
using Content.Shared.Mobs.Components; | ||
using Content.Shared.Mobs.Systems; | ||
using Robust.Shared.Random; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Server.Sunrise.Paws | ||
{ | ||
public sealed class PawsSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!; | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
[Dependency] private readonly ChatSystem _chatSystem = default!; | ||
[Dependency] private readonly IRobustRandom _random = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
// SubscribeLocalEvent<PawsComponent, MobStateChangedEvent>(OnMobStateChanged); | ||
SubscribeLocalEvent<PawsComponent, DamageChangedEvent>(OnDamaged); | ||
} | ||
|
||
// private void OnMobStateChanged(EntityUid uid, PawsComponent component, MobStateChangedEvent args) | ||
// { | ||
// if (args.NewMobState == MobState.Dead) | ||
// _audioSystem.PlayPvs(component.DeadSound, uid, component.DeadSound.Params); | ||
// } | ||
|
||
private void OnDamaged(EntityUid uid, PawsComponent component, DamageChangedEvent args) | ||
{ | ||
if (!_mobStateSystem.IsAlive(uid)) | ||
return; | ||
|
||
if (!args.DamageIncreased) | ||
return; | ||
|
||
var curTime = _timing.CurTime; | ||
|
||
if (curTime < component.NextScreamTime) | ||
return; | ||
|
||
if (args.DamageDelta!.GetTotal() < component.ThresholdDamage) | ||
return; | ||
|
||
component.NextScreamTime = curTime + TimeSpan.FromSeconds(component.ScreamInterval); | ||
_chatSystem.TryEmoteWithChat(uid, _random.Pick(component.EmotesTakeDamage)); | ||
} | ||
|
||
public override void Update(float frameTime) | ||
{ | ||
base.Update(frameTime); | ||
var curTime = _timing.CurTime; | ||
|
||
var query = EntityQueryEnumerator<PawsComponent, MobStateComponent>(); | ||
while (query.MoveNext(out var uid, out var comp, out var state)) | ||
{ | ||
if (state.CurrentState != MobState.Critical) | ||
continue; | ||
|
||
if (curTime < comp.NextCoughTime) | ||
return; | ||
|
||
comp.NextCoughTime = curTime + TimeSpan.FromSeconds(comp.CoughInterval); | ||
_chatSystem.TryEmoteWithChat(uid, "Cough", ignoreActionBlocker: true); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters