Skip to content

Commit

Permalink
Merge pull request AdventureTimeSS14#510 from FaDeOkno/bark
Browse files Browse the repository at this point in the history
Исправил наитупейший баг одного из прошлых ПРов.
  • Loading branch information
PyotrIgn authored Mar 20, 2024
2 parents 58b1914 + d96ca3a commit eb240c4
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 186 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using Content.Server.GameTicking;
using Content.Server.Mind;
using Content.Server.Roles.Jobs;
using Content.Shared.Actions;
Expand All @@ -17,19 +16,7 @@ namespace Content.Server.Changeling;

public sealed class LingHallucinationSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly JobSystem _jobs = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;

Expand All @@ -45,16 +32,8 @@ private void OnMapInit(EntityUid uid, LingHallucinationComponent component, MapI
// Allow this entity to be seen by other ghosts.
var visibility = EnsureComp<VisibilityComponent>(uid);

if (_ticker.RunLevel != GameRunLevel.PostRound)
{
_visibilitySystem.AddLayer(uid, visibility, (int) VisibilityFlags.LingToxin, false);
_visibilitySystem.RemoveLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
if (!_entityManager.TryGetComponent<EyeComponent>(uid, out var eye))
return;

_eye.SetVisibilityMask(uid, eye.VisibilityMask | (int) VisibilityFlags.LingToxin, eye);
}
_visibilitySystem.RemoveLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
}

private void OnShutdown(EntityUid uid, LingHallucinationComponent component, ComponentShutdown args)
Expand All @@ -66,13 +45,42 @@ private void OnShutdown(EntityUid uid, LingHallucinationComponent component, Com
// Entity can't be seen by ghosts anymore.
if (TryComp(uid, out VisibilityComponent? visibility))
{
_visibilitySystem.RemoveLayer(uid, visibility, (int) VisibilityFlags.LingToxin, false);
_visibilitySystem.RemoveLayer(uid, visibility, component.Layer, false);
_visibilitySystem.AddLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
if (!_entityManager.TryGetComponent<EyeComponent>(uid, out var eye))
return;

_eye.SetVisibilityMask(uid, eye.VisibilityMask & ~(int) VisibilityFlags.LingToxin, eye);
_eye.SetVisibilityMask(uid, eye.VisibilityMask & ~component.Layer, eye);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
}
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<LingHallucinationComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var stat, out var xform))
{
TryComp<VisibilityComponent>(uid, out var curVisibility);
if (curVisibility != null)
{
if (stat.Layer == curVisibility.Layer)
return;
}
// Allow this entity to be seen by other ghosts.
var visibility = EnsureComp<VisibilityComponent>(uid);

_visibilitySystem.AddLayer(uid, visibility, stat.Layer, false);
_visibilitySystem.RemoveLayer(uid, visibility, (int) VisibilityFlags.Normal, false);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
if (!_entityManager.TryGetComponent<EyeComponent>(uid, out var eye))
return;

_eye.SetVisibilityMask(uid, eye.VisibilityMask | stat.Layer, eye);
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,22 @@
using Robust.Shared.Timing;
using Content.Shared.Eye;
using Content.Shared.Movement.Systems;
using Content.Shared.Damage.Systems;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Changeling.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Random;
using Content.Server.Mind;
using Content.Shared.Administration.Logs;

namespace Content.Server.Changeling.EntitySystems;

public sealed partial class LingHallucinationsSystem : EntitySystem
{
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly StoreSystem _store = default!;
[Dependency] private readonly ActionsSystem _action = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly PolymorphSystem _polymorph = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly StatusEffectsSystem _status = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
[Dependency] private readonly StaminaSystem _stamina = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IRobustRandom _random = default!;
Expand All @@ -62,16 +47,22 @@ public override void Initialize()

private void OnHallucinationsInit(EntityUid uid, LingHallucinationsComponent component, MapInitEvent args)
{
component.Layer = _random.Next(50, 500);
if (!_entityManager.TryGetComponent<EyeComponent>(uid, out var eye))
return;
_eye.SetVisibilityMask(uid, eye.VisibilityMask | (int) VisibilityFlags.LingToxin, eye);
_eye.SetVisibilityMask(uid, eye.VisibilityMask | component.Layer, eye);

_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(uid):player} began to hallucinate.");
}

private void OnHallucinationsShutdown(EntityUid uid, LingHallucinationsComponent component, ComponentShutdown args)
{
if (!_entityManager.TryGetComponent<EyeComponent>(uid, out var eye))
return;
_eye.SetVisibilityMask(uid, eye.VisibilityMask & ~(int) VisibilityFlags.LingToxin, eye);
_eye.SetVisibilityMask(uid, eye.VisibilityMask & ~component.Layer, eye);
_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(uid):player} stopped hallucinating.");
}

public override void Update(float frameTime)
Expand All @@ -95,8 +86,16 @@ public override void Update(float frameTime)
{
var newCoords = Transform(ent).MapPosition.Offset(_random.NextVector2(stat.Range));

Spawn(_random.Pick(stat.Spawns), newCoords);
var hallucination = Spawn(_random.Pick(stat.Spawns), newCoords);
EnsureComp<LingHallucinationComponent>(hallucination, out var visibility);
visibility.Layer = stat.Layer;
}

var uidnewCoords = Transform(uid).MapPosition.Offset(_random.NextVector2(stat.Range));

var uidhallucination = Spawn(_random.Pick(stat.Spawns), uidnewCoords);
EnsureComp<LingHallucinationComponent>(uidhallucination, out var uidvisibility);
uidvisibility.Layer = stat.Layer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public sealed partial class ChangelingComponent : Component
/// How fast the changeling will turn visible from movement when using chameleon skin.
/// </summary>
[DataField]
public float ChameleonSkinMovementVisibilityRate = 0.30f;
public float ChameleonSkinMovementVisibilityRate = 0.60f;
#endregion

#region Dissonant Shriek Ability
Expand Down Expand Up @@ -406,7 +406,7 @@ public sealed partial class ChangelingComponent : Component
public float MuteAmount = 20f;

[ViewVariables(VVAccess.ReadWrite), DataField("drugAmount")]
public float SpaceDrugsAmount = 35f;
public float SpaceDrugsAmount = 50f;

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ namespace Content.Shared.Changeling.Components;
[RegisterComponent]
public sealed partial class LingHallucinationComponent : Component
{
[DataField]
public int Layer = 50;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
using Content.Shared.DoAfter;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.Random;

namespace Content.Shared.Changeling.Components;

[RegisterComponent]
public sealed partial class LingHallucinationsComponent : Component
{
[Dependency] private readonly IRobustRandom _random = default!;

[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
public TimeSpan NextSecond = TimeSpan.Zero;

Expand All @@ -18,11 +21,14 @@ public sealed partial class LingHallucinationsComponent : Component
public float SpawnRate = 15f;

[DataField, ViewVariables(VVAccess.ReadWrite)]
public float Chance = 0.65f;
public float Chance = 0.8f;
public List<EntProtoId> Spawns = new List<EntProtoId> { "ADTHallucinationMobSpider", "ADTHallucinationMobSlime", "ADTHallucinationMobBehonker", "ADTHallucinationRod" };

[DataField]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/ADT/ling-drugs.ogg")
{
};

[DataField]
public int Layer = 50;
}
2 changes: 0 additions & 2 deletions Content.Shared/Eye/VisibilityFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ public enum VisibilityFlags : int
Normal = 1 << 0,
Ghost = 1 << 1,
Narcotic = 1 << 2,
Schizo = 1 << 3,
LingToxin = 1 << 4,
}
}
Loading

0 comments on commit eb240c4

Please sign in to comment.