Skip to content

Commit 86eb99f

Browse files
committed
fix(2120): send animation source information and use it to cancel spell cast animations
1 parent 954a496 commit 86eb99f

File tree

12 files changed

+270
-73
lines changed

12 files changed

+270
-73
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using Intersect.GameObjects.Animations;
2+
3+
namespace Intersect.Framework.Core.GameObjects.Animations;
4+
5+
public record struct AnimationSource(AnimationSourceType Type, Guid Id);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Intersect.GameObjects.Animations;
2+
3+
public enum AnimationSourceType
4+
{
5+
Any,
6+
SpellCast,
7+
}

Intersect (Core)/Network/Packets/Server/PlayAnimationPacket.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using MessagePack;
22
using Intersect.Enums;
3+
using Intersect.GameObjects.Animations;
34

45
namespace Intersect.Network.Packets.Server;
56

@@ -18,7 +19,9 @@ public PlayAnimationPacket(
1819
Guid mapId,
1920
int x,
2021
int y,
21-
Direction direction
22+
Direction direction,
23+
AnimationSourceType sourceType = AnimationSourceType.Any,
24+
Guid sourceId = default
2225
)
2326
{
2427
AnimationId = animId;
@@ -28,6 +31,8 @@ Direction direction
2831
X = x;
2932
Y = y;
3033
Direction = direction;
34+
SourceType = sourceType;
35+
SourceId = sourceId;
3136
}
3237

3338
[Key(0)]
@@ -51,4 +56,10 @@ Direction direction
5156
[Key(6)]
5257
public Direction Direction { get; set; }
5358

59+
[Key(7)]
60+
public AnimationSourceType SourceType { get; set; }
61+
62+
[Key(8)]
63+
public Guid SourceId { get; set; }
64+
5465
}

Intersect.Client.Core/Entities/Animation.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using Intersect.Client.Framework.Graphics;
66
using Intersect.Client.General;
77
using Intersect.Enums;
8+
using Intersect.Framework.Core.GameObjects.Animations;
89
using Intersect.GameObjects;
10+
using Intersect.GameObjects.Animations;
911
using Intersect.Utilities;
1012

1113
namespace Intersect.Client.Entities;
@@ -26,7 +28,7 @@ public partial class Animation : IAnimation
2628

2729
private readonly int mLowerLoop;
2830

29-
private readonly Entity? mParent;
31+
private readonly IEntity? mParent;
3032

3133
private Direction mRenderDir;
3234

@@ -52,6 +54,8 @@ public partial class Animation : IAnimation
5254

5355
public AnimationBase? MyBase { get; set; }
5456

57+
public AnimationSource Source { get; }
58+
5559
public Point Size => CalculateAnimationSize();
5660

5761
private int mZDimension = -1;
@@ -61,10 +65,12 @@ public Animation(
6165
bool loopForever,
6266
bool autoRotate = false,
6367
int zDimension = -1,
64-
Entity? parent = null
68+
IEntity? parent = null,
69+
AnimationSource source = default
6570
)
6671
{
6772
MyBase = animBase;
73+
Source = source;
6874
mParent = parent;
6975
if (MyBase != null)
7076
{

Intersect.Client.Core/Entities/Entity.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
using Intersect.Client.Spells;
1515
using Intersect.Core;
1616
using Intersect.Enums;
17+
using Intersect.Framework.Core.GameObjects.Animations;
1718
using Intersect.GameObjects;
19+
using Intersect.GameObjects.Animations;
1820
using Intersect.GameObjects.Maps;
1921
using Intersect.Network.Packets.Server;
2022
using Intersect.Utilities;
@@ -27,7 +29,9 @@ public partial class Entity : IEntity
2729
public int AnimationFrame { get; set; }
2830

2931
//Entity Animations
30-
public List<Animation> Animations { get; set; } = [];
32+
public readonly List<Animation> Animations = [];
33+
34+
public readonly Dictionary<AnimationSource, Animation> AnimationsBySource = [];
3135

3236
//Animation Timer (for animated sprites)
3337
public long AnimationTimer { get; set; }

Intersect.Client.Core/Maps/MapAnimation.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using Intersect.Client.Entities;
2+
using Intersect.Client.Framework.Entities;
23
using Intersect.Client.Framework.Maps;
34
using Intersect.GameObjects;
45
using Intersect.Enums;
6+
using Intersect.Framework.Core.GameObjects.Animations;
57

68
namespace Intersect.Client.Maps;
79

@@ -16,12 +18,24 @@ public partial class MapAnimation : Animation, IMapAnimation
1618

1719
private int mTileY;
1820

19-
20-
public MapAnimation(AnimationBase animBase, int tileX, int tileY, Direction dir, Entity owner = null) : base(animBase, false, false, -1, owner)
21+
public MapAnimation(
22+
AnimationBase animBase,
23+
int tileX,
24+
int tileY,
25+
Direction dir,
26+
IEntity? owner = null,
27+
AnimationSource source = default
28+
) : base(
29+
animBase,
30+
false,
31+
false,
32+
-1,
33+
owner,
34+
source: source
35+
)
2136
{
2237
mTileX = tileX;
2338
mTileY = tileY;
2439
mDir = dir;
2540
}
26-
2741
}

Intersect.Client.Core/Maps/MapInstance.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Intersect.Compression;
1616
using Intersect.Core;
1717
using Intersect.Enums;
18+
using Intersect.Framework.Core.GameObjects.Animations;
1819
using Intersect.Framework.Core.Serialization;
1920
using Intersect.GameObjects;
2021
using Intersect.GameObjects.Maps;
@@ -720,19 +721,37 @@ private void ClearAttributeSounds()
720721
}
721722

722723
//Animations
723-
public void AddTileAnimation(Guid animId, int tileX, int tileY, Direction dir = Direction.None, IEntity owner = null)
724+
public void AddTileAnimation(
725+
Guid animId,
726+
int tileX,
727+
int tileY,
728+
Direction dir = Direction.None,
729+
IEntity? owner = null,
730+
AnimationSource source = default
731+
)
724732
{
725733
var animBase = AnimationBase.Get(animId);
726734
if (animBase == null)
727735
{
728736
return;
729737
}
730738

731-
var anim = new MapAnimation(animBase, tileX, tileY, dir, owner as Entity);
739+
var anim = new MapAnimation(
740+
animBase,
741+
tileX,
742+
tileY,
743+
dir,
744+
owner as Entity,
745+
source: source
746+
);
732747
LocalAnimations.TryAdd(anim.Id, anim);
733748
anim.SetPosition(
734749
X + tileX * _tileWidth + _tileHalfWidth,
735-
Y + tileY * _tileHeight + _tileHalfHeight, tileX, tileY, Id, dir
750+
Y + tileY * _tileHeight + _tileHalfHeight,
751+
tileX,
752+
tileY,
753+
Id,
754+
dir
736755
);
737756
}
738757

0 commit comments

Comments
 (0)