about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-05-26 12:50:11 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2024-05-26 12:50:11 -0400
commitc6d7af45fa044bbc3749c8012beb5bcc022e41a2 (patch)
tree38139b9bafe04bef05317f34a55b1fc87616088e
parentba2a395da7026de4be32733fc27011e161ead255 (diff)
downloadanodyne-archipelago-c6d7af45fa044bbc3749c8012beb5bcc022e41a2.tar.gz
anodyne-archipelago-c6d7af45fa044bbc3749c8012beb5bcc022e41a2.tar.bz2
anodyne-archipelago-c6d7af45fa044bbc3749c8012beb5bcc022e41a2.zip
Scout locations for personal chest icons
-rw-r--r--AnodyneArchipelago/ArchipelagoManager.cs32
-rw-r--r--AnodyneArchipelago/ArchipelagoTreasure.cs76
-rw-r--r--AnodyneArchipelago/Patches/GameplayPatches.cs2
3 files changed, 108 insertions, 2 deletions
diff --git a/AnodyneArchipelago/ArchipelagoManager.cs b/AnodyneArchipelago/ArchipelagoManager.cs index e4ccf36..94085f0 100644 --- a/AnodyneArchipelago/ArchipelagoManager.cs +++ b/AnodyneArchipelago/ArchipelagoManager.cs
@@ -25,6 +25,8 @@ namespace AnodyneArchipelago
25 private readonly Queue<NetworkItem> _itemsToCollect = new(); 25 private readonly Queue<NetworkItem> _itemsToCollect = new();
26 private readonly Queue<string> _messages = new(); 26 private readonly Queue<string> _messages = new();
27 27
28 private Task<Dictionary<string, NetworkItem>> _scoutTask;
29
28 public long EndgameCardRequirement => _endgameCardRequirement; 30 public long EndgameCardRequirement => _endgameCardRequirement;
29 31
30 public async Task<LoginResult> Connect(string url, string slotName, string password) 32 public async Task<LoginResult> Connect(string url, string slotName, string password)
@@ -54,6 +56,8 @@ namespace AnodyneArchipelago
54 _endgameCardRequirement = (long)login.SlotData["endgame_card_requirement"]; 56 _endgameCardRequirement = (long)login.SlotData["endgame_card_requirement"];
55 } 57 }
56 58
59 _scoutTask = Task.Run(() => ScoutAllLocations());
60
57 return result; 61 return result;
58 } 62 }
59 63
@@ -73,6 +77,34 @@ namespace AnodyneArchipelago
73 _session = null; 77 _session = null;
74 } 78 }
75 79
80 private async Task<Dictionary<string, NetworkItem>> ScoutAllLocations()
81 {
82 LocationInfoPacket locationInfo = await _session.Locations.ScoutLocationsAsync(_session.Locations.AllLocations.ToArray());
83
84 Dictionary<string, NetworkItem> result = new();
85 foreach (NetworkItem networkItem in locationInfo.Locations)
86 {
87 result[_session.Locations.GetLocationNameFromId(networkItem.Location)] = networkItem;
88 }
89
90 return result;
91 }
92
93 public NetworkItem? GetScoutedLocation(string locationName)
94 {
95 if (_scoutTask == null || !_scoutTask.IsCompleted || !_scoutTask.Result.ContainsKey(locationName))
96 {
97 return null;
98 }
99
100 return _scoutTask.Result[locationName];
101 }
102
103 public string GetItemName(long id)
104 {
105 return _session.Items.GetItemName(id);
106 }
107
76 public string GetSeed() 108 public string GetSeed()
77 { 109 {
78 return _seedName; 110 return _seedName;
diff --git a/AnodyneArchipelago/ArchipelagoTreasure.cs b/AnodyneArchipelago/ArchipelagoTreasure.cs index 9074108..b160f0d 100644 --- a/AnodyneArchipelago/ArchipelagoTreasure.cs +++ b/AnodyneArchipelago/ArchipelagoTreasure.cs
@@ -1,6 +1,7 @@
1using AnodyneSharp.Entities; 1using AnodyneSharp.Entities;
2using AnodyneSharp.Entities.Gadget.Treasures; 2using AnodyneSharp.Entities.Gadget.Treasures;
3using AnodyneSharp.Registry; 3using AnodyneSharp.Registry;
4using Archipelago.MultiClient.Net.Models;
4using Microsoft.Xna.Framework; 5using Microsoft.Xna.Framework;
5 6
6namespace AnodyneArchipelago 7namespace AnodyneArchipelago
@@ -9,7 +10,80 @@ namespace AnodyneArchipelago
9 { 10 {
10 private string _location; 11 private string _location;
11 12
12 public ArchipelagoTreasure(string location, Vector2 pos) : base("archipelago", pos, 0, -1) 13 private static (string, int) GetSprite(string location)
14 {
15 NetworkItem? item = Plugin.ArchipelagoManager.GetScoutedLocation(location);
16 if (item == null)
17 {
18 return ("archipelago", 0);
19 }
20
21 if (item?.Player != Plugin.ArchipelagoManager.GetPlayer())
22 {
23 return ("archipelago", 0);
24 }
25
26 string itemName = Plugin.ArchipelagoManager.GetItemName(item?.Item ?? 0);
27 if (itemName.StartsWith("Small Key"))
28 {
29 return ("key", 0);
30 }
31 else if (itemName == "Green Key")
32 {
33 return ("key_green", 0);
34 }
35 else if (itemName == "Blue Key")
36 {
37 return ("key_green", 4);
38 }
39 else if (itemName == "Red Key")
40 {
41 return ("key_green", 2);
42 }
43 else if (itemName == "Jump Shoes")
44 {
45 return ("item_jump_shoes", 0);
46 }
47 else if (itemName == "Health Cicada")
48 {
49 return ("life_cicada", 0);
50 }
51 else if (itemName == "Heal")
52 {
53 return ("small_health_pickup", 0);
54 }
55 else if (itemName == "Swap")
56 {
57 return ("item_tranformer", 0);
58 }
59 else if (itemName == "Extend")
60 {
61 return ("item_long_attack", 0);
62 }
63 else if (itemName == "Widen")
64 {
65 return ("item_wide_attack", 0);
66 }
67 else if (itemName == "Cardboard Box")
68 {
69 return ("fields_npcs", 31);
70 }
71 else if (itemName == "Biking Shoes")
72 {
73 return ("item_jump_shoes", 0);
74 }
75
76 return ("archipelago", 0);
77 }
78
79 public static ArchipelagoTreasure Create(string location, Vector2 pos)
80 {
81 (string textureName, int frame) = GetSprite(location);
82
83 return new(location, pos, textureName, frame);
84 }
85
86 private ArchipelagoTreasure(string location, Vector2 pos, string textureName, int frame) : base(textureName, pos, frame, -1)
13 { 87 {
14 _location = location; 88 _location = location;
15 } 89 }
diff --git a/AnodyneArchipelago/Patches/GameplayPatches.cs b/AnodyneArchipelago/Patches/GameplayPatches.cs index 056a855..6a7b621 100644 --- a/AnodyneArchipelago/Patches/GameplayPatches.cs +++ b/AnodyneArchipelago/Patches/GameplayPatches.cs
@@ -37,7 +37,7 @@ namespace AnodyneArchipelago.Patches
37 Guid entityId = PatchHelper.GetEntityPreset(typeof(TreasureChest), __instance).EntityID; 37 Guid entityId = PatchHelper.GetEntityPreset(typeof(TreasureChest), __instance).EntityID;
38 if (Locations.LocationsByGuid.ContainsKey(entityId)) 38 if (Locations.LocationsByGuid.ContainsKey(entityId))
39 { 39 {
40 BaseTreasure treasure = new ArchipelagoTreasure(Locations.LocationsByGuid[entityId], __instance.Position); 40 BaseTreasure treasure = ArchipelagoTreasure.Create(Locations.LocationsByGuid[entityId], __instance.Position);
41 41
42 FieldInfo treasureField = typeof(TreasureChest).GetField("_treasure", BindingFlags.NonPublic | BindingFlags.Instance); 42 FieldInfo treasureField = typeof(TreasureChest).GetField("_treasure", BindingFlags.NonPublic | BindingFlags.Instance);
43 treasureField.SetValue(__instance, treasure); 43 treasureField.SetValue(__instance, treasure);