forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sprite Movement working with AI movement (space-wizards#33494)
* FINALLY * Update animals.yml
- Loading branch information
Showing
10 changed files
with
181 additions
and
114 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
Content.Client/Movement/Systems/ClientSpriteMovementSystem.cs
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,46 @@ | ||
using Content.Shared.Movement.Components; | ||
using Content.Shared.Movement.Systems; | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.Movement.Systems; | ||
|
||
/// <summary> | ||
/// Controls the switching of motion and standing still animation | ||
/// </summary> | ||
public sealed class ClientSpriteMovementSystem : SharedSpriteMovementSystem | ||
{ | ||
[Dependency] private readonly IGameTiming _timing = default!; | ||
|
||
private EntityQuery<SpriteComponent> _spriteQuery; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
_spriteQuery = GetEntityQuery<SpriteComponent>(); | ||
|
||
SubscribeLocalEvent<SpriteMovementComponent, AfterAutoHandleStateEvent>(OnAfterAutoHandleState); | ||
} | ||
|
||
private void OnAfterAutoHandleState(Entity<SpriteMovementComponent> ent, ref AfterAutoHandleStateEvent args) | ||
{ | ||
if (!_spriteQuery.TryGetComponent(ent, out var sprite)) | ||
return; | ||
|
||
if (ent.Comp.IsMoving) | ||
{ | ||
foreach (var (layer, state) in ent.Comp.MovementLayers) | ||
{ | ||
sprite.LayerSetData(layer, state); | ||
} | ||
} | ||
else | ||
{ | ||
foreach (var (layer, state) in ent.Comp.NoMovementLayers) | ||
{ | ||
sprite.LayerSetData(layer, state); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
using Content.Shared.Movement.Systems; | ||
|
||
namespace Content.Server.Movement.Systems; | ||
|
||
public sealed class SpriteMovementSystem : SharedSpriteMovementSystem | ||
{ | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Content.Shared.Movement.Events; | ||
|
||
/// <summary> | ||
/// Raised on an entity whenever it should change movement sprite | ||
/// </summary> | ||
[ByRefEvent] | ||
public readonly struct SpriteMoveEvent | ||
{ | ||
public readonly bool IsMoving = false; | ||
|
||
public SpriteMoveEvent(bool isMoving) | ||
{ | ||
IsMoving = isMoving; | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
Content.Shared/Movement/Systems/SharedSpriteMovementSystem.cs
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,23 @@ | ||
using Content.Shared.Movement.Components; | ||
using Content.Shared.Movement.Events; | ||
|
||
namespace Content.Shared.Movement.Systems; | ||
|
||
public abstract class SharedSpriteMovementSystem : EntitySystem | ||
{ | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<SpriteMovementComponent, SpriteMoveEvent>(OnSpriteMoveInput); | ||
} | ||
|
||
private void OnSpriteMoveInput(Entity<SpriteMovementComponent> ent, ref SpriteMoveEvent args) | ||
{ | ||
if (ent.Comp.IsMoving == args.IsMoving) | ||
return; | ||
|
||
ent.Comp.IsMoving = args.IsMoving; | ||
Dirty(ent); | ||
} | ||
} |
Oops, something went wrong.