Skip to content

Commit ef2d59d

Browse files
committed
Added ESE_Queue and ESE_DynamicQueue types, removed scripts/Core/ESE_CoreTypes.c,
1 parent 98db2f7 commit ef2d59d

File tree

9 files changed

+359
-78
lines changed

9 files changed

+359
-78
lines changed

resourceDatabase.rdb

0 Bytes
Binary file not shown.

scripts/Core/proto/ESE_CoreTypes.c

Lines changed: 0 additions & 63 deletions
This file was deleted.

scripts/Game/!ESE_CORE.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#define ESE_INSTALLED // Always keep this enabled to ensure mod compatiblity with additional aliases
22
#define ESE_VERSION_MAJOR_0
3+
#define ESE_MAINFUNC
34

45
bool ESE_IS_INITIALIZED = ESE.Init();

scripts/Game/ESE.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ESE
2222
{
2323
static const int VERSION_MAJOR = 0;
2424
static const int VERSION_MINOR = 1;
25-
static const int VERSION_PATCH = 2;
25+
static const int VERSION_PATCH = 3;
2626
// initialize ese on startup, called in !ESE_CORE.c
2727
static bool Init()
2828
{

scripts/Game/ESE_Entities.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@ class ESE_Entities
1515
/**
1616
Creates new entity from prefab at a given position vector
1717
@code
18-
vector pos = someEntity.GetOrigin();
18+
vector mat = someEntity.GetTransform();
1919
ResourceName resName = "{3E413771E1834D2F}Prefabs/Weapons/Rifles/M16/Rifle_M16A2.et";
2020
21-
IEntity newEntity = ESE.SpawnPrefab(pos, resource);
21+
IEntity newEntity = ESE.SpawnPrefab(mat, resource);
2222
@endcode
2323
*/
24-
static IEntity SpawnPrefab(vector origin, ResourceName prefabName)
24+
// #ESE_UPDATE_DOCUMENTATION - changed from using origin to transform
25+
static IEntity SpawnPrefab(vector transform[4], ResourceName prefabName)
2526
{
2627
if (!prefabName)
2728
{
2829
Print("Missing Prefab: " + prefabName, LogLevel.ERROR);
2930
return null;
3031
}
31-
if (!origin)
32+
if (!transform)
3233
{
33-
origin = Vector(0,0,0);
34+
Print("No valid transform! Using default transform instead.", LogLevel.WARNING);
35+
Math3D.MatrixIdentity4(transform)
3436
}
3537
Resource prefab = Resource.Load(prefabName);
36-
EntitySpawnParams spawnParams;
38+
EntitySpawnParams spawnParams = new EntitySpawnParams();
3739
spawnParams.TransformMode = ETransformMode.WORLD;
38-
spawnParams.Transform[3] = origin;
40+
spawnParams.Transform = transform;
3941

4042
return GetGame().SpawnEntityPrefab(prefab, GetGame().GetWorld(), spawnParams);
4143
}

scripts/Game/ESE_IO.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,36 @@
44
// Message me @narcoleptic marshmallow #1188 on discord to give feedback or go to https://github.com/NarcoMarshDev
55
// -----------------------------------------------------------------------------------------------------------
66
class ESE_IO
7-
{
7+
{
88
static int ReadFileAsArray(string path, inout array<string> arr, int length)
99
{
1010
FileHandle f = FileIO.OpenFile(path, FileMode.READ);
1111
int readLen = f.ReadFile(arr, length);
1212
f.CloseFile();
1313
return readLen;
1414
}
15+
16+
// #ESE_ADD_DOCUMENTATION
17+
// Works like csv reader but using space delimiters instead of commas
18+
static int ReadSpaceDelimitedFileAsArray(string path, inout array<array<string>> output)
19+
{
20+
output.Clear();
21+
ParseHandle file = FileIO.BeginParse(path);
22+
int lineNumber = 0;
23+
int charNum = 0;
24+
while (true)
25+
{
26+
array<string> line = {};
27+
charNum = file.ParseLine(lineNumber, line);
28+
if (charNum == -1) {break;} // if end of file, break and dont push line to output
29+
30+
output.Insert(line);
31+
lineNumber++;
32+
}
33+
file.EndParse();
34+
return lineNumber;
35+
}
36+
1537
// -----------------------------------------------------------------------------------------------------------
1638
#ifdef ESE_ENABLE_WIP
1739
static string ReadFileAsString(string path)

scripts/Game/ESE_Types.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@
44
// Message me @narcoleptic marshmallow #1188 on discord to give feedback or go to https://github.com/NarcoMarshDev
55
// -----------------------------------------------------------------------------------------------------------
66

7-
#ifdef ESE_EXPERIMENTAL
8-
class HierarchyMap<Class T>
9-
{
10-
11-
}
12-
#endif
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// -----------------------------------------------------------------------------------------------------------
2+
// Enforce Script Extensions - By NarcoMarshmallow
3+
//
4+
// Message me @narcoleptic marshmallow #1188 on discord to give feedback or go to https://github.com/NarcoMarshDev
5+
// -----------------------------------------------------------------------------------------------------------
6+
/**
7+
ESE_DynamicQueue Class
8+
9+
Template class for first-in, first-out array of objects. Unlike ESE_Queue, this class is dynamically sized and will expand
10+
whenever a new object is enqueued, and old objects are never automatically dequeued.
11+
12+
For full documentation check the wiki @ https://github.com/NarcoMarshDev/Enforce-Script-Extensions/wiki/ESE_DynamicQueue-Class
13+
14+
Code example:
15+
@code
16+
// See ESE_Queue
17+
@endcode
18+
*/
19+
20+
class ESE_DynamicQueue<Class T>
21+
{
22+
ref array<T> Raw = {};
23+
T nullValue = null;
24+
25+
// ----------------------------------------------------------------------------------------------------------- //
26+
void Enqueue(T value)
27+
{
28+
Raw.InsertAt(value, 0);
29+
}
30+
// ----------------------------------------------------------------------------------------------------------- //
31+
T Dequeue()
32+
{
33+
int lastIndex = Raw.Count() - 1;
34+
if (lastIndex < 0)
35+
{
36+
#ifdef ESE_VERBOSE
37+
Print("" + this + ": Attempted to dequeue index out of range ["+lastIndex+"]", LogLevel.ERROR);
38+
#endif
39+
return nullValue;
40+
}
41+
T value = Raw.Get(lastIndex);
42+
Raw.Remove(lastIndex);
43+
return value;
44+
}
45+
// ----------------------------------------------------------------------------------------------------------- //
46+
T Peek()
47+
{
48+
int lastIndex = Raw.Count() - 1;
49+
if (lastIndex < 0)
50+
{
51+
#ifdef ESE_VERBOSE
52+
Print("" + this + ": Attempted to peek index out of range ["+lastIndex+"]", LogLevel.ERROR);
53+
#endif
54+
return nullValue;
55+
}
56+
T value = Raw.Get(lastIndex);
57+
return value;
58+
}
59+
// ----------------------------------------------------------------------------------------------------------- //
60+
bool TryDequeue(T output)
61+
{
62+
int lastIndex = Raw.Count() - 1;
63+
if (lastIndex < 0)
64+
{
65+
#ifdef ESE_VERBOSE
66+
Print("" + this + ": Attempted to dequeue index out of range ["+lastIndex+"]", LogLevel.ERROR);
67+
#endif
68+
output = nullValue;
69+
return false;
70+
}
71+
output = Raw.Get(lastIndex);
72+
Raw.Remove(lastIndex);
73+
return true;
74+
}
75+
// ----------------------------------------------------------------------------------------------------------- //
76+
bool TryPeek(T output)
77+
{
78+
int lastIndex = Raw.Count() - 1;
79+
if (lastIndex < 0)
80+
{
81+
#ifdef ESE_VERBOSE
82+
Print("" + this + ": Attempted to peek index out of range ["+lastIndex+"]", LogLevel.ERROR);
83+
#endif
84+
output = nullValue;
85+
return false;
86+
}
87+
output = Raw.Get(lastIndex);
88+
return true;
89+
}
90+
// ----------------------------------------------------------------------------------------------------------- //
91+
bool Contains(T value)
92+
{
93+
return Raw.Contains(value);
94+
}
95+
// ----------------------------------------------------------------------------------------------------------- //
96+
void Clear()
97+
{
98+
Raw.Clear();
99+
}
100+
// ----------------------------------------------------------------------------------------------------------- //
101+
int Count()
102+
{
103+
return Raw.Count();
104+
}
105+
// ----------------------------------------------------------------------------------------------------------- //
106+
void TrimTo(int size)
107+
{
108+
int sizeDifference = Raw.Count() - size;
109+
if (sizeDifference < 0) {
110+
return;
111+
}
112+
Raw.Resize(size);
113+
Raw.Compact();
114+
}
115+
// ----------------------------------------------------------------------------------------------------------- //
116+
typename GetDataType()
117+
{
118+
return T;
119+
}
120+
// ----------------------------------------------------------------------------------------------------------- //
121+
void CopyToArray(notnull inout array<T> newArray)
122+
{
123+
newArray.Copy(Raw);
124+
}
125+
// ----------------------------------------------------------------------------------------------------------- //
126+
void CopyToStaticQueue(notnull inout ESE_Queue<T> newQueue)
127+
{
128+
newQueue.Raw.Copy(this.Raw);
129+
newQueue.Resize(this.Raw.Count());
130+
}
131+
// ----------------------------------------------------------------------------------------------------------- //
132+
void CopyFromArray(notnull array<T> oldArray)
133+
{
134+
Raw.Copy(oldArray);
135+
TrimTo(oldArray.Count());
136+
}
137+
// ----------------------------------------------------------------------------------------------------------- //
138+
void ESE_DynamicQueue()
139+
{
140+
}
141+
// ----------------------------------------------------------------------------------------------------------- //
142+
void ~ESE_DynamicQueue()
143+
{
144+
delete Raw;
145+
}
146+
}

0 commit comments

Comments
 (0)