Skip to content

Commit a23ea89

Browse files
committed
fix and cleanup crafting window AscensionGameDev#2541
formatting for previous commit
1 parent 9477d08 commit a23ea89

File tree

14 files changed

+340
-277
lines changed

14 files changed

+340
-277
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using Intersect.Collections;
3+
4+
namespace Intersect.Models;
5+
6+
public partial class DbList<T> : List<Guid> where T : IDatabaseObject
7+
{
8+
public List<T> GetAll()
9+
{
10+
var list = new List<T>();
11+
foreach (var l in ToArray())
12+
{
13+
list.Add((T)DatabaseObjectLookup.LookupMap[typeof(T)].Get(l));
14+
}
15+
16+
return list;
17+
}
18+
19+
public T Get(Guid id)
20+
{
21+
return (T)DatabaseObjectLookup.LookupMap[typeof(T)].Get(id);
22+
}
23+
24+
public bool TryGet(Guid id, [NotNullWhen(true)] out T? value)
25+
{
26+
if (DatabaseObjectLookup.LookupMap.TryGetValue(typeof(T), out var lookupMap))
27+
{
28+
return lookupMap.TryGetValue<T>(id, out value);
29+
}
30+
31+
value = default;
32+
return false;
33+
}
34+
}
Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Intersect.Collections;
2-
using Intersect.Enums;
1+
using Intersect.Enums;
32
using Newtonsoft.Json;
43

54
namespace Intersect.Models;
@@ -27,25 +26,4 @@ public interface IDatabaseObject : INamedObject
2726

2827
void Delete();
2928

30-
}
31-
32-
public partial class DbList<T> : List<Guid>
33-
{
34-
35-
public List<T> GetAll()
36-
{
37-
var list = new List<T>();
38-
foreach (var l in ToArray())
39-
{
40-
list.Add((T) DatabaseObjectLookup.LookupMap[typeof(T)].Get(l));
41-
}
42-
43-
return list;
44-
}
45-
46-
public T Get(Guid id)
47-
{
48-
return (T) DatabaseObjectLookup.LookupMap[typeof(T)].Get(id);
49-
}
50-
51-
}
29+
}

Intersect.Client.Core/Entities/Entity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Guid[] Equipment
106106
public Guid Id { get; set; }
107107

108108
//Inventory/Spells/Equipment
109-
public IItem[] Inventory { get; set; } = new IItem[Options.Instance.Player.MaxInventory];
109+
public IItem[] Inventory { get; } = new IItem[Options.Instance.Player.MaxInventory];
110110

111111
IReadOnlyList<IItem> IEntity.Items => [.. Inventory];
112112

Intersect.Client.Core/Entities/Player.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace Intersect.Client.Entities;
3333

3434
public partial class Player : Entity, IPlayer
3535
{
36-
public delegate void InventoryUpdated();
36+
public delegate void InventoryUpdatedEventHandler(Player player, int slotIndex);
3737

3838
private Guid _class;
3939

@@ -66,7 +66,19 @@ public Guid Class
6666

6767
public HotbarInstance[] Hotbar { get; set; } = new HotbarInstance[Options.Instance.Player.HotbarSlotCount];
6868

69-
public InventoryUpdated? InventoryUpdatedDelegate { get; set; }
69+
public event InventoryUpdatedEventHandler? InventoryUpdated;
70+
71+
public void UpdateInventory(
72+
int slotIndex,
73+
Guid descriptorId,
74+
int quantity,
75+
Guid? bagId,
76+
ItemProperties itemProperties
77+
)
78+
{
79+
Inventory[slotIndex].Load(id: descriptorId, quantity: quantity, bagId: bagId, itemProperties: itemProperties);
80+
InventoryUpdated?.Invoke(this, slotIndex);
81+
}
7082

7183
IReadOnlyDictionary<Guid, long> IPlayer.ItemCooldowns => ItemCooldowns;
7284

Intersect.Client.Core/Interface/Game/Chat/Chatbox.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ private void SetChannelToTab(ChatboxTab tab)
353353
}
354354

355355
//Update
356-
public void Update()
356+
private void Update()
357357
{
358358
var vScrollBar = mChatboxMessages.GetVerticalScrollBar();
359359
var scrollAmount = vScrollBar.ScrollAmount;

0 commit comments

Comments
 (0)