Skip to content

Commit 82f3e0c

Browse files
committed
Added ESE_GetComponent<T>, ESE_InventoryHelper. Added TryEnqueue() to ESE_Queue<T>
1 parent 2d7972f commit 82f3e0c

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

resourceDatabase.rdb

100 Bytes
Binary file not shown.

scripts/Game/Collections/ESE_Queue.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ class ESE_Queue<Class T>: Managed
7575
return value;
7676
}
7777
// ----------------------------------------------------------------------------------------------------------- //
78+
bool TryEnqueue(T value)
79+
{
80+
if (Raw.Count() >= MaxSize)
81+
{
82+
return false;
83+
}
84+
Raw.InsertAt(value, 0);
85+
return true;
86+
}
87+
// ----------------------------------------------------------------------------------------------------------- //
7888
bool TryDequeue(out T output)
7989
{
8090
int lastIndex = Raw.Count() - 1;

scripts/Game/Helpers/ESE_Helpers.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
class ESE_GetComponent<Class T>
2+
{
3+
static T FindFirst(IEntity ent)
4+
{
5+
return T.Cast(ent.FindComponent(T));
6+
}
7+
8+
static array<T> FindAll(IEntity ent)
9+
{
10+
array<Managed> managedArray = {};
11+
ent.FindComponents(T, managedArray);
12+
13+
array<T> castedArray = {};
14+
foreach (Managed item: managedArray)
15+
{
16+
castedArray.Insert(T.Cast(item));
17+
}
18+
return castedArray;
19+
}
20+
}
21+
//------------------------------------------------------------------------------------------------
22+
23+
class ESE_InventoryHelper
24+
{
25+
static SCR_InventoryStorageManagerComponent GetInventoryStorageManager(IEntity ent)
26+
{
27+
return SCR_InventoryStorageManagerComponent.Cast(ent.FindComponent(SCR_InventoryStorageManagerComponent));
28+
}
29+
30+
static array<ResourceName> GetItemResources(SCR_InventoryStorageManagerComponent manager)
31+
{
32+
if (!manager)
33+
return null;
34+
35+
array<IEntity> entities = {};
36+
array<ResourceName> resources = {};
37+
if (manager.GetItems(entities) > 0)
38+
{
39+
foreach (IEntity item: entities)
40+
{
41+
resources.Insert(item.GetPrefabData().GetPrefabName());
42+
}
43+
}
44+
return resources;
45+
}
46+
}
47+
//------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)