about summary refs log tree commit diff stats
path: root/AnodyneArchipelago/ArchipelagoTreasure.cs
blob: b160f0d7e095b80ead24774f4b96146b84883378 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using AnodyneSharp.Entities;
using AnodyneSharp.Entities.Gadget.Treasures;
using AnodyneSharp.Registry;
using Archipelago.MultiClient.Net.Models;
using Microsoft.Xna.Framework;

namespace AnodyneArchipelago
{
    internal class ArchipelagoTreasure : Treasure
    {
        private string _location;

        private static (string, int) GetSprite(string location)
        {
            NetworkItem? item = Plugin.ArchipelagoManager.GetScoutedLocation(location);
            if (item == null)
            {
                return ("archipelago", 0);
            }

            if (item?.Player != Plugin.ArchipelagoManager.GetPlayer())
            {
                return ("archipelago", 0);
            }

            string itemName = Plugin.ArchipelagoManager.GetItemName(item?.Item ?? 0);
            if (itemName.StartsWith("Small Key"))
            {
                return ("key", 0);
            }
            else if (itemName == "Green Key")
            {
                return ("key_green", 0);
            }
            else if (itemName == "Blue Key")
            {
                return ("key_green", 4);
            }
            else if (itemName == "Red Key")
            {
                return ("key_green", 2);
            }
            else if (itemName == "Jump Shoes")
            {
                return ("item_jump_shoes", 0);
            }
            else if (itemName == "Health Cicada")
            {
                return ("life_cicada", 0);
            }
            else if (itemName == "Heal")
            {
                return ("small_health_pickup", 0);
            }
            else if (itemName == "Swap")
            {
                return ("item_tranformer", 0);
            }
            else if (itemName == "Extend")
            {
                return ("item_long_attack", 0);
            }
            else if (itemName == "Widen")
            {
                return ("item_wide_attack", 0);
            }
            else if (itemName == "Cardboard Box")
            {
                return ("fields_npcs", 31);
            }
            else if (itemName == "Biking Shoes")
            {
                return ("item_jump_shoes", 0);
            }

            return ("archipelago", 0);
        }

        public static ArchipelagoTreasure Create(string location, Vector2 pos)
        {
            (string textureName, int frame) = GetSprite(location);

            return new(location, pos, textureName, frame);
        }

        private ArchipelagoTreasure(string location, Vector2 pos, string textureName, int frame) : base(textureName, pos, frame, -1)
        {
            _location = location;
        }

        public override void GetTreasure()
        {
            if (_location == "Street - Broom Chest")
            {
                BroomTreasure broomTreasure = new("broom-icon", this.Position, BroomType.Normal);
                broomTreasure.GetTreasure();
                GlobalState.SpawnEntity(broomTreasure);
            }
            else if (_location == "Street - Key Chest")
            {
                KeyTreasure keyTreasure = new(this.Position);
                keyTreasure.GetTreasure();
                GlobalState.SpawnEntity(keyTreasure);
            }
            else
            {
                base.GetTreasure();
            }
            
            Plugin.ArchipelagoManager.SendLocation(_location);
        }
    }
}