|
27 | 27 | using Intersect.Utilities; |
28 | 28 | using Microsoft.Extensions.Logging; |
29 | 29 | using Newtonsoft.Json; |
| 30 | +using Intersect.Framework.Core.GameObjects.Resources; |
30 | 31 |
|
31 | 32 | namespace Intersect.Client.Maps; |
32 | 33 |
|
@@ -668,6 +669,59 @@ private void UpdateMapAttributes() |
668 | 669 | mAttributeCritterInstances[mapAttribute].Update(); |
669 | 670 | break; |
670 | 671 | } |
| 672 | + case MapAttributeType.Resource: |
| 673 | + { |
| 674 | + var resource = Globals.Entities.Values |
| 675 | + .Where(e => |
| 676 | + e.Type == EntityType.Resource && |
| 677 | + e.X == x && e.Y == y && |
| 678 | + e.MapInstance?.Id == Id |
| 679 | + ).FirstOrDefault() as Resource; |
| 680 | + |
| 681 | + if (resource?.CurrentGraphicState is not { } graphicState) |
| 682 | + { |
| 683 | + continue; |
| 684 | + } |
| 685 | + |
| 686 | + if (graphicState.GraphicType != ResourceGraphicType.Animation) |
| 687 | + { |
| 688 | + continue; |
| 689 | + } |
| 690 | + |
| 691 | + if (!AnimationDescriptor.TryGet(graphicState.AnimationId, out var animation)) |
| 692 | + { |
| 693 | + continue; |
| 694 | + } |
| 695 | + |
| 696 | + if (!mAttributeAnimInstances.ContainsKey(mapAttribute)) |
| 697 | + { |
| 698 | + var animInstance = new Animation(animation, true); |
| 699 | + animInstance.SetPosition( |
| 700 | + X + x * _tileWidth + _tileHalfWidth, |
| 701 | + Y + y * _tileHeight + _tileHalfHeight, x, y, Id, 0 |
| 702 | + ); |
| 703 | + |
| 704 | + mAttributeAnimInstances.Add(mapAttribute, animInstance); |
| 705 | + } |
| 706 | + else |
| 707 | + { |
| 708 | + var currentResourceAnimation = mAttributeAnimInstances[mapAttribute]; |
| 709 | + if (currentResourceAnimation.Descriptor?.Id != animation.Id) |
| 710 | + { |
| 711 | + currentResourceAnimation.Dispose(); |
| 712 | + mAttributeAnimInstances.Remove(mapAttribute); |
| 713 | + var animInstance = new Animation(animation, true); |
| 714 | + animInstance.SetPosition( |
| 715 | + X + x * _tileWidth + _tileHalfWidth, |
| 716 | + Y + y * _tileHeight + _tileHalfHeight, x, y, Id, 0 |
| 717 | + ); |
| 718 | + mAttributeAnimInstances.Add(mapAttribute, animInstance); |
| 719 | + } |
| 720 | + } |
| 721 | + |
| 722 | + mAttributeAnimInstances[mapAttribute].Update(); |
| 723 | + } |
| 724 | + break; |
671 | 725 | } |
672 | 726 | } |
673 | 727 | } |
|
0 commit comments