Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Mass Bug Fix #130

Merged
merged 10 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Content.Client/Arcade/BlockGameMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ private Control SetupGameGrid(Texture panelTex)
{
PanelOverride = back,
HorizontalExpand = true,
SizeFlagsStretchRatio = 60
SizeFlagsStretchRatio = 34.25f
};
var backgroundPanel = new PanelContainer
{
Expand Down
49 changes: 33 additions & 16 deletions Content.Client/Buckle/BuckleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,41 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BuckleComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<BuckleComponent, AppearanceChangeEvent>(OnAppearanceChange);
SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
SubscribeLocalEvent<BuckleComponent, BuckledEvent>(OnBuckledEvent);
SubscribeLocalEvent<BuckleComponent, UnbuckledEvent>(OnUnbuckledEvent);
}

/// <summary>
/// Is the strap entity already rotated north? Lower the draw depth of the buckled entity.
/// </summary>
private void OnBuckledEvent(Entity<BuckleComponent> ent, ref BuckledEvent args)
{
if (!TryComp<SpriteComponent>(args.Strap, out var strapSprite) ||
!TryComp<SpriteComponent>(ent.Owner, out var buckledSprite))
return;

if (Transform(args.Strap.Owner).LocalRotation.GetCardinalDir() == Direction.North)
{
ent.Comp.OriginalDrawDepth ??= buckledSprite.DrawDepth;
buckledSprite.DrawDepth = strapSprite.DrawDepth - 1;
}
}

/// <summary>
/// Was the draw depth of the buckled entity lowered? Reset it upon unbuckling.
/// </summary>
private void OnUnbuckledEvent(Entity<BuckleComponent> ent, ref UnbuckledEvent args)
{
if (!TryComp<SpriteComponent>(ent.Owner, out var buckledSprite))
return;

if (ent.Comp.OriginalDrawDepth.HasValue)
{
buckledSprite.DrawDepth = ent.Comp.OriginalDrawDepth.Value;
ent.Comp.OriginalDrawDepth = null;
}
}

private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveEvent args)
Expand Down Expand Up @@ -57,21 +89,6 @@ private void OnStrapMoveEvent(EntityUid uid, StrapComponent component, ref MoveE
}
}

private void OnHandleState(Entity<BuckleComponent> ent, ref ComponentHandleState args)
{
if (args.Current is not BuckleState state)
return;

ent.Comp.DontCollide = state.DontCollide;
ent.Comp.BuckleTime = state.BuckleTime;
var strapUid = EnsureEntity<BuckleComponent>(state.BuckledTo, ent);

SetBuckledTo(ent, strapUid == null ? null : new (strapUid.Value, null));

var (uid, component) = ent;

}

private void OnAppearanceChange(EntityUid uid, BuckleComponent component, ref AppearanceChangeEvent args)
{
if (!TryComp<RotationVisualsComponent>(uid, out var rotVisuals)
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Jittering/JitteringSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ private void OnAnimationCompleted(EntityUid uid, JitteringComponent jittering, A
if(args.Key != _jitterAnimationKey)
return;

if (!args.Finished)
return;

if (TryComp(uid, out AnimationPlayerComponent? animationPlayer)
&& TryComp(uid, out SpriteComponent? sprite))
_animationPlayer.Play(uid, animationPlayer, GetAnimation(jittering, sprite), _jitterAnimationKey);
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Light/EntitySystems/LightBehaviorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public override void Initialize()

private void OnBehaviorAnimationCompleted(EntityUid uid, LightBehaviourComponent component, AnimationCompletedEvent args)
{
if (!args.Finished)
return;

var container = component.Animations.FirstOrDefault(x => x.FullKey == args.Key);

if (container == null)
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Light/EntitySystems/RotatingLightSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ private void OnAfterAutoHandleState(EntityUid uid, RotatingLightComponent comp,

private void OnAnimationComplete(EntityUid uid, RotatingLightComponent comp, AnimationCompletedEvent args)
{
if (!args.Finished)
return;

PlayAnimation(uid, comp);
}

Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Salvage/UI/SalvageMagnetBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public SalvageMagnetBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner
protected override void Open()
{
base.Open();
_window = new OfferingWindow();

_window = this.CreateWindow<OfferingWindow>(); // WD EDIT
_window.Title = Loc.GetString("salvage-magnet-window-title");
_window.OnClose += Close;
_window.OpenCenteredLeft();
}

Expand Down
37 changes: 6 additions & 31 deletions Content.Client/_White/Animations/WaddleAnimationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public sealed class WaddleAnimationSystem : SharedWaddleAnimationSystem

public override void Initialize()
{
SubscribeLocalEvent<WaddleAnimationComponent, AnimationCompletedEvent>(OnAnimationCompleted);

SubscribeAllEvent<StartedWaddlingEvent>(ev => PlayAnimation(GetEntity(ev.User)));
SubscribeAllEvent<StoppedWaddlingEvent>(ev => StopAnimation(GetEntity(ev.User)));
}

protected override void PlayAnimation(EntityUid uid)
Expand All @@ -40,7 +37,6 @@ protected override void PlayAnimation(EntityUid uid)
var len = mover.Sprinting ? component.AnimationLength * component.RunAnimationLengthMultiplier : component.AnimationLength;

component.LastStep = !component.LastStep;
component.IsCurrentlyWaddling = true;

var animation = new Animation()
{
Expand All @@ -54,9 +50,9 @@ protected override void PlayAnimation(EntityUid uid)
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), 0),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(tumbleIntensity), len/3),
new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), len/3),
new(Angle.FromDegrees(0), 0),
new(Angle.FromDegrees(tumbleIntensity), len/3),
new(Angle.FromDegrees(0), len/3),
}
},
new AnimationTrackComponentProperty()
Expand All @@ -66,35 +62,14 @@ protected override void PlayAnimation(EntityUid uid)
InterpolationMode = AnimationInterpolationMode.Linear,
KeyFrames =
{
new AnimationTrackProperty.KeyFrame(new Vector2(), 0),
new AnimationTrackProperty.KeyFrame(component.HopIntensity, len/3),
new AnimationTrackProperty.KeyFrame(new Vector2(), len/3),
new(new Vector2(), 0),
new(component.HopIntensity, len/3),
new(new Vector2(), len/3),
}
}
}
};

_animation.Play(uid, animation, component.KeyName);
}

protected override void StopAnimation(EntityUid uid)
{
if (!TryComp<WaddleAnimationComponent>(uid, out var component)
|| !TryComp<SpriteComponent>(uid, out var sprite))
return;

_animation.Stop(uid, component.KeyName);

sprite.Offset = new Vector2();
sprite.Rotation = Angle.FromDegrees(0);
component.IsCurrentlyWaddling = false;
}

private void OnAnimationCompleted(EntityUid uid, WaddleAnimationComponent component, AnimationCompletedEvent args)
{
if (args.Key != component.KeyName)
return;

PlayAnimation(uid);
}
}
4 changes: 2 additions & 2 deletions Content.Server/Arcade/BlockGame/BlockGame.Ui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void InputTick(float frameTime)
/// <param name="message">The message to broadcase to all players/spectators.</param>
private void SendMessage(BoundUserInterfaceMessage message)
{
_uiSystem.ServerSendUiMessage(_entityManager.GetEntity(message.Entity), BlockGameUiKey.Key, message);
_uiSystem.ServerSendUiMessage(_owner, BlockGameUiKey.Key, message);
}

/// <summary>
Expand All @@ -167,7 +167,7 @@ private void SendMessage(BoundUserInterfaceMessage message)
/// <param name="actor">The target recipient.</param>
private void SendMessage(BoundUserInterfaceMessage message, EntityUid actor)
{
_uiSystem.ServerSendUiMessage(_entityManager.GetEntity(message.Entity), BlockGameUiKey.Key, message, actor);
_uiSystem.ServerSendUiMessage(_owner, BlockGameUiKey.Key, message, actor);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed partial class WelderRefinableComponent : Component
public float RefineTime = 2f;

[DataField]
public float RefineFuel;
public float RefineFuel = 1f; // WD EDIT

[DataField]
public ProtoId<ToolQualityPrototype> QualityNeeded = "Welding";
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Disposal/Tube/DisposalTubeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,15 @@ private void UpdateAnchored(EntityUid uid, DisposalTubeComponent component, bool
{
if (!Resolve(target, ref targetTube))
return null;

var oppositeDirection = nextDirection.GetOpposite();

var xform = Transform(target);
if (!TryComp<MapGridComponent>(xform.GridUid, out var grid))
return null;

var position = xform.Coordinates;
var entities = _mapSystem.GetInDir(target, grid, position, nextDirection);
var entities = _mapSystem.GetInDir((EntityUid) xform.GridUid, grid, position, nextDirection);

foreach (var entity in entities)
{
Expand Down
15 changes: 6 additions & 9 deletions Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ public void ExitDisposals(EntityUid uid, DisposalHolderComponent? holder = null,

if (!Resolve(uid, ref holder, ref holderTransform))
return;

if (holder.IsExitingDisposals)
{
Log.Error("Tried exiting disposals twice. This should never happen.");
return;
}

holder.IsExitingDisposals = true;

// Check for a disposal unit to throw them into and then eject them from it.
Expand Down Expand Up @@ -164,11 +166,13 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderCompon
{
if (!Resolve(holderUid, ref holder, ref holderTransform))
return false;

if (holder.IsExitingDisposals)
{
Log.Error("Tried entering tube after exiting disposals. This should never happen.");
return false;
}

if (!Resolve(toUid, ref to, ref toTransform))
{
ExitDisposals(holderUid, holder, holderTransform);
Expand All @@ -193,6 +197,7 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderCompon
holder.PreviousTube = holder.CurrentTube;
holder.PreviousDirection = holder.CurrentDirection;
}

holder.CurrentTube = toUid;
var ev = new GetDisposalsNextDirectionEvent(holder);
RaiseLocalEvent(toUid, ref ev);
Expand All @@ -212,9 +217,7 @@ public bool EnterTube(EntityUid holderUid, EntityUid toUid, DisposalHolderCompon
if (holder.CurrentDirection != holder.PreviousDirection)
{
foreach (var ent in holder.Container.ContainedEntities)
{
_damageable.TryChangeDamage(ent, to.DamageOnTurn);
}
_audio.PlayPvs(to.ClangSound, toUid);
}

Expand All @@ -225,9 +228,7 @@ public override void Update(float frameTime)
{
var query = EntityQueryEnumerator<DisposalHolderComponent>();
while (query.MoveNext(out var uid, out var holder))
{
UpdateComp(uid, holder, frameTime);
}
}

private void UpdateComp(EntityUid uid, DisposalHolderComponent holder, float frameTime)
Expand All @@ -236,9 +237,7 @@ private void UpdateComp(EntityUid uid, DisposalHolderComponent holder, float fra
{
var time = frameTime;
if (time > holder.TimeLeft)
{
time = holder.TimeLeft;
}

holder.TimeLeft -= time;
frameTime -= time;
Expand Down Expand Up @@ -268,17 +267,15 @@ private void UpdateComp(EntityUid uid, DisposalHolderComponent holder, float fra

// Find next tube
var nextTube = _disposalTubeSystem.NextTubeFor(currentTube, holder.CurrentDirection);
if (!EntityManager.EntityExists(nextTube))
if (!EntityManager.EntityExists(nextTube))
{
ExitDisposals(uid, holder);
break;
}

// Perform remainder of entry process
if (!EnterTube(uid, nextTube!.Value, holder))
{
break;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ public bool TryFlush(EntityUid uid, SharedDisposalUnitComponent component)
return false;

var coords = xform.Coordinates;
var entry = _sharedMapSystem.GetLocal(uid, grid, coords)
var entry = _sharedMapSystem.GetLocal((EntityUid) xform.GridUid, grid, coords)
.FirstOrDefault(HasComp<DisposalEntryComponent>);

if (entry == default || component is not DisposalUnitComponent sDisposals)
Expand Down
Loading
Loading