From 44c4da63082960c6d9a2a8c42d56b16b3564bfef Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Mon, 29 Dec 2025 20:14:42 -0700 Subject: [PATCH 01/19] feat: Implemented first iteration of the EntityList custom array type. --- entities/entitylist.as | 125 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 entities/entitylist.as diff --git a/entities/entitylist.as b/entities/entitylist.as new file mode 100644 index 0000000..6592888 --- /dev/null +++ b/entities/entitylist.as @@ -0,0 +1,125 @@ +/** +* @brief EntityList is custom array type that stores specificly added sets of Entities and information about them. +* @details +* @authors Orsell +* +* @license Distributed under the MIT license - Copyright (c) 2025 Project Collapse Studios +*/ + +// Tags that can be appended to various EntityInfo's in the +// EntityArray array type to find certain specific entities in the array. +//? Maybe we could have a way to implement custom tags that can be made and applied in special cases. +enum EntityTag +{ + NONE = 0, // Entity has no tags. + LOGIC, // Ex. logic_relay + MODEL, // Ex. prop_dynamic + NPC, // Ex. npc_barney + FRIENDLY, // Ex. Rebels + ENEMY, // Ex. Combine + CUSTOM, // A custom AngelScript entity. + LAST_TAG // To count how many tags exist. +} +typedef uint8 EntityTags; + +// Struct you contain the information about an entity in the EntityArray. +class EntityInfo +{ + CBaseEntity@ entRef; + EntityTags tags; +} + +// Custom array type that stores specificly added sets of Entities and information about them. +class EntityArray +{ + array entArr; + + /** + * @brief Clear the contents of the EntityArray. + */ + void Clear() + { + entArr.removeRange(0, entArr.length() - 1); + } + + /** + * @brief Add a entity to the EntityArray by its entity name. + * @param entName Entity name of the entity to add. + * @param tags (optional) What tags should be added with the entity. + * @TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + */ + void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE ) + { + for (CBaseEntity@ ent = null; ent = EntityList().FindByName(null, entName);) + { + EntityInfo newEntInfo; + newEntInfo.entRef = ent; + newEntInfo.tags = tags; + + entArr.insertLast(newEntInfo); + DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\""); + } + } + + /** + * @brief Add a entity to the EntityArray by its class name. + * @param className Class name of the entity to add. + * @param tags (optional) What tags should be added with the entity. + * @TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + */ + void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE ) + { + for (CBaseEntity@ ent = null; ent = EntityList().FindByClassname(null, className);) + { + EntityInfo newEntInfo; + newEntInfo.entRef = ent; + newEntInfo.tags = tags; + + entArr.insertLast(newEntInfo); + DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\""); + } + } + + /** + * @brief Add a entity to the EntityArray by its handle. + * @param entHandle Handle of the entity to add. + * @param tags (optional) What tags should be added with the entity. + * @TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + */ + void AddByHandle( const CBaseEntity@ entHandle, const EntityTags tags = EntityTag::NONE ) + { + if (entHandle == null) + { + Warningl("Invalid handle passed to AddByHandle!"); + return; + } + + EntityInfo newEntInfo; + newEntInfo.entRef = entHandle; + newEntInfo.tags = tags; + + entArr.insertLast(newEntInfo); + DevMsgl("Added entity \"" + entHandle.GetEntityName() + "\" with entindex \"" + entHandle.GetEntityIndex() + "\""); + } + + /** + * @brief Remove entities from the EntityArray by a entity's name. + * @param entName Name of entity to remove from the array. + * @param rmAmt (optional) How many of the entity by it's name should be removed. + */ + void RemoveByEntityName( const string&in entName, int rmAmt = 1 ) + { + // TODO-FIXME: I believe there is better way to do this, this will work for now. + for (int i = 0; i < entArr.length(); i++) + { + EntityInfo entInfo = entArr[i]; + if ((entInfo.entRef != null) && (entInfo.entRef.GetEntityName() == entName)) + { + entArr.removeAt(i); + rmAmt--; + if (rmAmt <= 0) + return; + } + } + } +} From c73626b412d12cb9176bd125b45b10e03655c37c Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Mon, 29 Dec 2025 22:51:24 -0700 Subject: [PATCH 02/19] fix: Tags were not bit shifted. --- entities/entitylist.as | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/entities/entitylist.as b/entities/entitylist.as index 6592888..f19be6c 100644 --- a/entities/entitylist.as +++ b/entities/entitylist.as @@ -11,18 +11,20 @@ //? Maybe we could have a way to implement custom tags that can be made and applied in special cases. enum EntityTag { - NONE = 0, // Entity has no tags. - LOGIC, // Ex. logic_relay - MODEL, // Ex. prop_dynamic - NPC, // Ex. npc_barney - FRIENDLY, // Ex. Rebels - ENEMY, // Ex. Combine - CUSTOM, // A custom AngelScript entity. - LAST_TAG // To count how many tags exist. + NONE = 0, // Entity has no tags. + LOGIC = 1 << 0, // Ex. logic_relay + MODEL = 1 << 1, // Ex. prop_dynamic + PUZZLE_ELEMENT = 1 << 2, // Ex. prop_weighted_cube + NPC = 1 << 3, // Ex. npc_barney + FRIENDLY = 1 << 4, // Ex. Rebels + ENEMY = 1 << 5, // Ex. Combine + CUSTOM = 1 << 6, // A custom AngelScript entity. + + LAST_TAG = 1 << 7 // To indicate how many tags exist. } -typedef uint8 EntityTags; +typedef uint16 EntityTags; // Max allowed amount of tags currently is 1 << 15, this can easily be changed later. -// Struct you contain the information about an entity in the EntityArray. +// Struct to contain the information about an entity in the EntityArray. class EntityInfo { CBaseEntity@ entRef; From 026bd35ba2ed4ff535c2b2fb457541dadefee625 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Mon, 29 Dec 2025 22:57:43 -0700 Subject: [PATCH 03/19] tidy: Tidied how new EntityInfo structs are created and added another DevMsgl for what tags the entity was added with --- entities/entitylist.as | 44 ++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/entities/entitylist.as b/entities/entitylist.as index f19be6c..24aaee4 100644 --- a/entities/entitylist.as +++ b/entities/entitylist.as @@ -27,8 +27,20 @@ typedef uint16 EntityTags; // Max allowed amount of tags currently is 1 << 15, t // Struct to contain the information about an entity in the EntityArray. class EntityInfo { - CBaseEntity@ entRef; + CBaseEntity@ entHandle; EntityTags tags; + + EntityInfo() + { + @entHandle = null; + tags = EntityTag::NONE; + } + + EntityInfo( CBaseEntity@ handle, EntityTags tags = EntityTag::NONE ) + { + @entHandle = handle; + tags = tags; + } } // Custom array type that stores specificly added sets of Entities and information about them. @@ -52,14 +64,12 @@ class EntityArray */ void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE ) { - for (CBaseEntity@ ent = null; ent = EntityList().FindByName(null, entName);) + for (CBaseEntity@ ent = null; ent = EntityList().FindByName(ent, entName);) { - EntityInfo newEntInfo; - newEntInfo.entRef = ent; - newEntInfo.tags = tags; - - entArr.insertLast(newEntInfo); - DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\""); + entArr.insertLast(EntityInfo(ent, tags)); + DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\"."); + if (tags > 0) + DevMsgl("Entity tag value is: \"" + tags + "\""); } } @@ -71,14 +81,12 @@ class EntityArray */ void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE ) { - for (CBaseEntity@ ent = null; ent = EntityList().FindByClassname(null, className);) + for (CBaseEntity@ ent = null; ent = EntityList().FindByClassname(ent, className);) { - EntityInfo newEntInfo; - newEntInfo.entRef = ent; - newEntInfo.tags = tags; - - entArr.insertLast(newEntInfo); + entArr.insertLast(EntityInfo(ent, tags)); DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\""); + if (tags > 0) + DevMsgl("Entity tag value is: \"" + tags + "\""); } } @@ -96,12 +104,10 @@ class EntityArray return; } - EntityInfo newEntInfo; - newEntInfo.entRef = entHandle; - newEntInfo.tags = tags; - - entArr.insertLast(newEntInfo); + entArr.insertLast(EntityInfo(entHandle, tags)); DevMsgl("Added entity \"" + entHandle.GetEntityName() + "\" with entindex \"" + entHandle.GetEntityIndex() + "\""); + if (tags > 0) + DevMsgl("Entity tag value is: \"" + tags + "\""); } /** From a75130c80157f44e49f97c6d12195fd0cf53f57c Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Mon, 29 Dec 2025 22:59:06 -0700 Subject: [PATCH 04/19] feat: Added operator overloads for supporting foreach statements, except the AS VSCode extention I have says its invalid? --- entities/entitylist.as | 79 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 7 deletions(-) diff --git a/entities/entitylist.as b/entities/entitylist.as index 24aaee4..a31fc09 100644 --- a/entities/entitylist.as +++ b/entities/entitylist.as @@ -44,17 +44,30 @@ class EntityInfo } // Custom array type that stores specificly added sets of Entities and information about them. +// TODO: Should try and take advantage of using the array's "findByRef" functions for CBaseEntity handles, +// TODO: however the issue is that the array type used is EntityInfo so CBaseEntity can't be used. class EntityArray { + // The underlying array that holds all the EntityInfo "structs". array entArr; /** - * @brief Clear the contents of the EntityArray. + * @brief Access a entity from the array by index. */ - void Clear() - { - entArr.removeRange(0, entArr.length() - 1); - } + EntityInfo& opIndex(uint index) { return entArr[index]; } + const EntityInfo& opIndex(uint index) const { return entArr[index]; } + + /** + * @brief For statement operator overloads for usage with foreach as indexes. + */ + uint opForBegin() const { return 0; } + bool opForEnd(uint index) const { return index >= entArr.length(); } + uint opForNext(uint index) const { return index + 1; } + + /** + * @brief Clear all the entities from the EntityArray. + */ + void Clear() { entArr.removeRange(0, entArr.length() - 1); } /** * @brief Add a entity to the EntityArray by its entity name. @@ -117,17 +130,69 @@ class EntityArray */ void RemoveByEntityName( const string&in entName, int rmAmt = 1 ) { - // TODO-FIXME: I believe there is better way to do this, this will work for now. + // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? + for (int i = 0; i < entArr.length(); i++) + { + EntityInfo entInfo = entArr[i]; + if ((entInfo.entHandle != null) && (entInfo.entHandle.GetEntityName() == entName)) + { + entArr.removeAt(i); + DevMsgl("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\""); + rmAmt--; + if (rmAmt <= 0) + return; + } + } + } + + /** + * @brief Remove entities from the EntityArray by a entity's class name. + * @param className Class name of entity to remove from the array. + * @param rmAmt (optional) How many of the entity by it's class name should be removed. + */ + void RemoveByClassname( const string&in className, int rmAmt = 1 ) + { + // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? for (int i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; - if ((entInfo.entRef != null) && (entInfo.entRef.GetEntityName() == entName)) + if ((entInfo.entHandle != null) && (entInfo.entHandle.GetClassname() == className)) { entArr.removeAt(i); + DevMsgl("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\""); rmAmt--; if (rmAmt <= 0) return; } } } + + /** + * @brief Remove entity from the EntityArray by a CBaseEntity handle. + * @param entHandle Handle of the entity to remove from the array. + */ + void RemoveByHandle( const CBaseEntity@ entHandle) + { + // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? + for (int i = 0; i < entArr.length(); i++) + { + EntityInfo entInfo = entArr[i]; + if ((entInfo.entHandle != null) && (entInfo.entHandle == entHandle)) + { + DevMsgl("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\""); + entArr.removeAt(i); + return; + } + } + } + + // TODO: Implement + void SortByTagsAsc() + { + + } + void SortByTagsDesc() + { + + } } From 5bf4b71b64a9d53b42fca52e625e26ea1bb223eb Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Mon, 29 Dec 2025 23:13:29 -0700 Subject: [PATCH 05/19] rename: Renamed EntityArray class file to the right name --- entities/{entitylist.as => entityarray.as} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename entities/{entitylist.as => entityarray.as} (100%) diff --git a/entities/entitylist.as b/entities/entityarray.as similarity index 100% rename from entities/entitylist.as rename to entities/entityarray.as From 7dc3691a99ad812df39a6253539a43d0308e6bfe Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Mon, 29 Dec 2025 23:18:31 -0700 Subject: [PATCH 06/19] docs: Bumped copyright year up --- entities/entityarray.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index a31fc09..25c5ab3 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -3,7 +3,7 @@ * @details * @authors Orsell * -* @license Distributed under the MIT license - Copyright (c) 2025 Project Collapse Studios +* @license Distributed under the MIT license - Copyright (c) 2026 Project Collapse Studios */ // Tags that can be appended to various EntityInfo's in the From 10d6f7c89dc861f12444ab5e8880d7bb20f28391 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Tue, 30 Dec 2025 16:17:12 -0700 Subject: [PATCH 07/19] feat: Added new sorting functions, that wont work, and added some more operator overloads --- entities/entityarray.as | 130 +++++++++++++++++++++++++++++++++------- 1 file changed, 110 insertions(+), 20 deletions(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index 25c5ab3..bbe4dab 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -6,9 +6,9 @@ * @license Distributed under the MIT license - Copyright (c) 2026 Project Collapse Studios */ -// Tags that can be appended to various EntityInfo's in the -// EntityArray array type to find certain specific entities in the array. -//? Maybe we could have a way to implement custom tags that can be made and applied in special cases. +// Tags that can be appended to various EntityInfo's in the EntityArray to find certain specific entities in the array. +//? Maybe we could have a way to implement custom tags that can be made and applied in special cases at runtime? +// TODO: Currently these were just examples of tags we could have, these can be changed out or changed with whatever. enum EntityTag { NONE = 0, // Entity has no tags. @@ -25,26 +25,56 @@ enum EntityTag typedef uint16 EntityTags; // Max allowed amount of tags currently is 1 << 15, this can easily be changed later. // Struct to contain the information about an entity in the EntityArray. -class EntityInfo +final class EntityInfo { - CBaseEntity@ entHandle; - EntityTags tags; + CBaseEntity@ entHandle; // Handle for the entity. + EntityTags tags; // unint16 number that holds a bit + /** + * @brief Default constructor. + */ EntityInfo() { @entHandle = null; tags = EntityTag::NONE; } - EntityInfo( CBaseEntity@ handle, EntityTags tags = EntityTag::NONE ) + /** + * @brief Constructor with arguments. + * @param newEntHandle A CBaseEntity handle to pass to the EntityInfo to store. + * @param tags What tags should be assosiated with the entity. + */ + EntityInfo( CBaseEntity@ newEntHandle, EntityTags tags = EntityTag::NONE ) { - @entHandle = handle; + @entHandle = newEntHandle; tags = tags; } + + /** + * @brief Assign the contents of one EntityInfo's to another. + * @param rhs EntityInfo on the right hand side. + */ + EntityInfo& opAssign(const EntityInfo& rhs) + { + this.entHandle = rhs.entHandle; + this.tags = rhs.tags; + } + + /** + * @brief Check if two EntityInfo's are equal. + * @param rhs EntityInfo on the right hand side. + */ + bool opEquals( const EntityInfo&in rhs ) const + { + if ((this.entHandle != rhs.entHandle) || (this.tags != rhs.tags)) + return false; + + return true; + } } // Custom array type that stores specificly added sets of Entities and information about them. -// TODO: Should try and take advantage of using the array's "findByRef" functions for CBaseEntity handles, +// TODO: Should try and take advantage of using the array's find functions for CBaseEntity handles, // TODO: however the issue is that the array type used is EntityInfo so CBaseEntity can't be used. class EntityArray { @@ -52,17 +82,47 @@ class EntityArray array entArr; /** - * @brief Access a entity from the array by index. + * @brief Assign the contents of one EntityArray array to another EntityArray. + * @param rhs EntityArray on the right hand side. */ - EntityInfo& opIndex(uint index) { return entArr[index]; } - const EntityInfo& opIndex(uint index) const { return entArr[index]; } + EntityArray& opAssign(const EntityArray& rhs) + { + this.entArr = rhs.entArr; + } + + /** + * @brief Check if two EntityArray's are equal. + * @param rhs EntityArray on the right hand side. + * @note Order of EntityInfo's in the array matters, and for each index the inside items match. + */ + bool opEquals( const EntityArray&in rhs ) const + { + // Checking if the length is different. + if (this.entArr.length() != rhs.entArr.length()) + return false; + + // Checking individual items of the array. + for (int i = 0; i < this.entArr.length(); i++) + { + if (this.entArr[i] != rhs.entArr[i]) + return false; + } + + return true; + } + + /** + * @brief Access a EntityInfo by index from the array. + */ + EntityInfo& opIndex( uint index ) { return entArr[index]; } + const EntityInfo& opIndex( uint index ) const { return entArr[index]; } /** * @brief For statement operator overloads for usage with foreach as indexes. */ uint opForBegin() const { return 0; } - bool opForEnd(uint index) const { return index >= entArr.length(); } - uint opForNext(uint index) const { return index + 1; } + bool opForEnd( uint index ) const { return index >= entArr.length(); } + uint opForNext( uint index ) const { return index + 1; } /** * @brief Clear all the entities from the EntityArray. @@ -73,7 +133,7 @@ class EntityArray * @brief Add a entity to the EntityArray by its entity name. * @param entName Entity name of the entity to add. * @param tags (optional) What tags should be added with the entity. - * @TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + * @// TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. */ void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE ) { @@ -90,7 +150,7 @@ class EntityArray * @brief Add a entity to the EntityArray by its class name. * @param className Class name of the entity to add. * @param tags (optional) What tags should be added with the entity. - * @TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + * @// TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. */ void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE ) { @@ -107,7 +167,7 @@ class EntityArray * @brief Add a entity to the EntityArray by its handle. * @param entHandle Handle of the entity to add. * @param tags (optional) What tags should be added with the entity. - * @TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + * @// TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. */ void AddByHandle( const CBaseEntity@ entHandle, const EntityTags tags = EntityTag::NONE ) { @@ -186,13 +246,43 @@ class EntityArray } } - // TODO: Implement - void SortByTagsAsc() + /** + * @brief Compare tags of entities for sorting assendingly. + * @param A Entity A. + * @param B Entity B. + */ + bool SortByTagsAsc(const EntityInfo@ A, const EntityInfo@ B) { + if (A.tags < B.tags) + return true; + return false; } - void SortByTagsDesc() + + /** + * @brief Compare tags of entities for sorting descendingly. + * @param A Entity A. + * @param B Entity B. + */ + bool SortByTagsDesc(const EntityInfo@ A, const EntityInfo@ B) { + if (A.tags < B.tags) + return false; + return true; + } + + /** + * @brief Sort entities in the EntityArray by their tag value. + * @param assending Whether to sort assendingly or decendingly. + */ + void SortEntitiesByTags(bool assending = true) + { + // TODO: Forgot this was a issue, normal sort function is incomplete by the dump so this is my assumptional take on what "T[]::less" actually is. + // TODO: Guess we have to wait till the dump is fixed or think of something else. + if (assending) + entArr.sort(SortByTagsAsc); + else + entArr.sort(SortByTagsDesc); } } From b5dc6da03b7be61a4097561f69069d41089e14c9 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Wed, 7 Jan 2026 23:47:19 -0800 Subject: [PATCH 08/19] feat: Added find functions for EntityArray --- entities/entityarray.as | 116 ++++++++++++++++++++++++++++++++++------ 1 file changed, 99 insertions(+), 17 deletions(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index bbe4dab..778f569 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -1,5 +1,5 @@ /** -* @brief EntityList is custom array type that stores specificly added sets of Entities and information about them. +* @brief EntityList is custom array type that stores specifically added sets of Entities and information about them. * @details * @authors Orsell * @@ -24,11 +24,11 @@ enum EntityTag } typedef uint16 EntityTags; // Max allowed amount of tags currently is 1 << 15, this can easily be changed later. -// Struct to contain the information about an entity in the EntityArray. +// "Struct" to contain the information about an entity in the EntityArray. final class EntityInfo { CBaseEntity@ entHandle; // Handle for the entity. - EntityTags tags; // unint16 number that holds a bit + EntityTags tags; // unint16 number that holds bits. /** * @brief Default constructor. @@ -42,7 +42,7 @@ final class EntityInfo /** * @brief Constructor with arguments. * @param newEntHandle A CBaseEntity handle to pass to the EntityInfo to store. - * @param tags What tags should be assosiated with the entity. + * @param tags What tags should be associated with the entity. */ EntityInfo( CBaseEntity@ newEntHandle, EntityTags tags = EntityTag::NONE ) { @@ -54,7 +54,7 @@ final class EntityInfo * @brief Assign the contents of one EntityInfo's to another. * @param rhs EntityInfo on the right hand side. */ - EntityInfo& opAssign(const EntityInfo& rhs) + EntityInfo& opAssign( const EntityInfo& rhs ) { this.entHandle = rhs.entHandle; this.tags = rhs.tags; @@ -73,9 +73,7 @@ final class EntityInfo } } -// Custom array type that stores specificly added sets of Entities and information about them. -// TODO: Should try and take advantage of using the array's find functions for CBaseEntity handles, -// TODO: however the issue is that the array type used is EntityInfo so CBaseEntity can't be used. +// Custom array type that stores specifically added sets of Entities and information about them. class EntityArray { // The underlying array that holds all the EntityInfo "structs". @@ -85,7 +83,7 @@ class EntityArray * @brief Assign the contents of one EntityArray array to another EntityArray. * @param rhs EntityArray on the right hand side. */ - EntityArray& opAssign(const EntityArray& rhs) + EntityArray& opAssign( const EntityArray& rhs ) { this.entArr = rhs.entArr; } @@ -129,6 +127,9 @@ class EntityArray */ void Clear() { entArr.removeRange(0, entArr.length() - 1); } + + // ---------------- ADDING FUNCTIONS ---------------- \\ + /** * @brief Add a entity to the EntityArray by its entity name. * @param entName Entity name of the entity to add. @@ -183,6 +184,9 @@ class EntityArray DevMsgl("Entity tag value is: \"" + tags + "\""); } + + // ---------------- REMOVING FUNCTIONS ---------------- \\ + /** * @brief Remove entities from the EntityArray by a entity's name. * @param entName Name of entity to remove from the array. @@ -231,7 +235,7 @@ class EntityArray * @brief Remove entity from the EntityArray by a CBaseEntity handle. * @param entHandle Handle of the entity to remove from the array. */ - void RemoveByHandle( const CBaseEntity@ entHandle) + void RemoveByHandle( const CBaseEntity@ entHandle ) { // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? for (int i = 0; i < entArr.length(); i++) @@ -246,12 +250,15 @@ class EntityArray } } + + // ---------------- SORTING FUNCTIONS ---------------- \\ + /** - * @brief Compare tags of entities for sorting assendingly. + * @brief Compare tags of entities for sorting ascendingly. * @param A Entity A. * @param B Entity B. */ - bool SortByTagsAsc(const EntityInfo@ A, const EntityInfo@ B) + bool SortByTagsAsc( const EntityInfo@ A, const EntityInfo@ B ) { if (A.tags < B.tags) return true; @@ -264,7 +271,7 @@ class EntityArray * @param A Entity A. * @param B Entity B. */ - bool SortByTagsDesc(const EntityInfo@ A, const EntityInfo@ B) + bool SortByTagsDesc( const EntityInfo@ A, const EntityInfo@ B ) { if (A.tags < B.tags) return false; @@ -274,15 +281,90 @@ class EntityArray /** * @brief Sort entities in the EntityArray by their tag value. - * @param assending Whether to sort assendingly or decendingly. + * @param ascending Whether to sort ascendingly or decendingly. */ - void SortEntitiesByTags(bool assending = true) + void SortEntitiesByTags( bool ascending = true ) { - // TODO: Forgot this was a issue, normal sort function is incomplete by the dump so this is my assumptional take on what "T[]::less" actually is. + // TODO: Forgot this was a issue, normal sort function is incomplete by the dump so this is my assumption take on what "T[]::less" actually is. // TODO: Guess we have to wait till the dump is fixed or think of something else. - if (assending) + if (ascending) entArr.sort(SortByTagsAsc); else entArr.sort(SortByTagsDesc); } + + + // ---------------- FIND FUNCTIONS ---------------- \\ + // TODO: Should try and take advantage of using the array's find functions for CBaseEntity handles, + // TODO: however the issue is that the array type used is EntityInfo so CBaseEntity can't be used. + + /** + * @brief Find entities in the EntityArray by a CBaseEntity handle. + * @param handle Handle to search for in the array. + * @return Simple array of EntityInfo with the given handle. + */ + array FindByHandle( const CBaseEntity@ handle ) + { + array results; + for (int i = 0; i < entArr.length(); i++) + { + if (entArr[i].entHandle == handle) + results.insertLast(entArr[i]); + } + + return results; + } + + /** + * @brief Find entities in the EntityArray by an entity name. + * @param entName Name of entity to search for in the array. + * @return Simple array of EntityInfo with the given name. + */ + array FindByName( const string&in entName ) + { + array results; + for (int i = 0; i < entArr.length(); i++) + { + if (entArr[i].entHandle.GetEntityName() == entName) + results.insertLast(entArr[i]); + } + + return results; + } + + /** + * @brief Find entities in the EntityArray by a class name. + * @param className Class name of entity to search for in the array. + * @return Simple array of EntityInfo with the given class name. + */ + array FindByClassname( const string&in className ) + { + array results; + for (int i = 0; i < entArr.length(); i++) + { + if (entArr[i].entHandle.GetClassname() == className) + results.insertLast(entArr[i]); + } + + return results; + } + + /** + * @brief Find entities in the EntityArray by EntityTags. + * @param tag Tags to search for in the array. + * @return Array of entities with the given tags. + */ + array FindByTag( const EntityTags tag ) + { + array results; + for (int i = 0; i < entArr.length(); i++) + { + if (entArr[i].tags & tag) + { + results.insertLast(entArr[i]); + } + } + + return results; + } } From d4b4eb415c332a1047ff77c42a21c58c1a03b578 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Fri, 9 Jan 2026 02:38:57 -0800 Subject: [PATCH 09/19] feat: Added assert function --- misc/assert.as | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 misc/assert.as diff --git a/misc/assert.as b/misc/assert.as new file mode 100644 index 0000000..44bd0a5 --- /dev/null +++ b/misc/assert.as @@ -0,0 +1,18 @@ +/** +* @brief assert function implementation. +* @details There is no proper assert function for AngelScript, so this is a small implementation that will throw then there is a error. +* @authors Orsell +* +* @license Distributed under the MIT license - Copyright (c) 2026 Project Collapse Studios +*/ + +/** +* @brief Assertion function to test statements. Will print out if a exception occurs and the error involved. +* Very limited to what line the assert was called on however. +* @param Statement to pass in that should be true, if false, then a throw call will be passed. +*/ +void assert( const bool testStatement ) +{ + if (!testStatement) + throw("Assertion hit! Statement failed!"); +} From 33d188af4dcf554f72918d274ca3a6af8c1746d2 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Fri, 9 Jan 2026 02:39:27 -0800 Subject: [PATCH 10/19] fix: Trying to fix some compiling issues with EntityArray --- entities/entityarray.as | 55 ++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index 778f569..611a506 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -44,9 +44,9 @@ final class EntityInfo * @param newEntHandle A CBaseEntity handle to pass to the EntityInfo to store. * @param tags What tags should be associated with the entity. */ - EntityInfo( CBaseEntity@ newEntHandle, EntityTags tags = EntityTag::NONE ) + EntityInfo( const CBaseEntity@ newEntHandle, EntityTags tags = EntityTag::NONE ) { - @entHandle = newEntHandle; + @entHandle = @newEntHandle; tags = tags; } @@ -56,8 +56,13 @@ final class EntityInfo */ EntityInfo& opAssign( const EntityInfo& rhs ) { + if (this == rhs) + return this; + this.entHandle = rhs.entHandle; this.tags = rhs.tags; + + return this; } /** @@ -77,7 +82,7 @@ final class EntityInfo class EntityArray { // The underlying array that holds all the EntityInfo "structs". - array entArr; + array entArr; /** * @brief Assign the contents of one EntityArray array to another EntityArray. @@ -85,7 +90,12 @@ class EntityArray */ EntityArray& opAssign( const EntityArray& rhs ) { + if (this == rhs) + return this; + this.entArr = rhs.entArr; + + return this; } /** @@ -125,8 +135,23 @@ class EntityArray /** * @brief Clear all the entities from the EntityArray. */ - void Clear() { entArr.removeRange(0, entArr.length() - 1); } + void Clear() { entArr.removeRange(0, entArr.length()); } + + /** + * @brief Get length of the EntityArray. + */ + int Length() { return entArr.length(); } + void Print() + { + for (int i = 0; i < entArr.length(); i++) + { + Msg("Array Position: " + i + " | "); + Msg("EntityHandle->GetEntityName: " + entArr[i].entHandle.GetEntityName() + " | "); + Msg("EntityHandle->GetEntityIndex: " + entArr[i].entHandle.GetEntityIndex() + " | "); + Msg("Tags: " + entArr[i].tags + "\n"); + } + } // ---------------- ADDING FUNCTIONS ---------------- \\ @@ -254,7 +279,7 @@ class EntityArray // ---------------- SORTING FUNCTIONS ---------------- \\ /** - * @brief Compare tags of entities for sorting ascendingly. + * @brief Compare tags of entities for sorting ascending. * @param A Entity A. * @param B Entity B. */ @@ -267,7 +292,7 @@ class EntityArray } /** - * @brief Compare tags of entities for sorting descendingly. + * @brief Compare tags of entities for sorting descending. * @param A Entity A. * @param B Entity B. */ @@ -281,7 +306,7 @@ class EntityArray /** * @brief Sort entities in the EntityArray by their tag value. - * @param ascending Whether to sort ascendingly or decendingly. + * @param ascending Whether to sort ascending or descending. */ void SortEntitiesByTags( bool ascending = true ) { @@ -303,9 +328,9 @@ class EntityArray * @param handle Handle to search for in the array. * @return Simple array of EntityInfo with the given handle. */ - array FindByHandle( const CBaseEntity@ handle ) + array@ FindByHandle( const CBaseEntity@ handle ) { - array results; + array results; for (int i = 0; i < entArr.length(); i++) { if (entArr[i].entHandle == handle) @@ -320,9 +345,9 @@ class EntityArray * @param entName Name of entity to search for in the array. * @return Simple array of EntityInfo with the given name. */ - array FindByName( const string&in entName ) + array@ FindByEntityName( const string&in entName ) { - array results; + array results; for (int i = 0; i < entArr.length(); i++) { if (entArr[i].entHandle.GetEntityName() == entName) @@ -337,9 +362,9 @@ class EntityArray * @param className Class name of entity to search for in the array. * @return Simple array of EntityInfo with the given class name. */ - array FindByClassname( const string&in className ) + array@ FindByClassname( const string&in className ) { - array results; + array results; for (int i = 0; i < entArr.length(); i++) { if (entArr[i].entHandle.GetClassname() == className) @@ -354,9 +379,9 @@ class EntityArray * @param tag Tags to search for in the array. * @return Array of entities with the given tags. */ - array FindByTag( const EntityTags tag ) + array@ FindByTag( const EntityTags tag ) { - array results; + array results; for (int i = 0; i < entArr.length(); i++) { if (entArr[i].tags & tag) From f40a6994519ef3319fc9c3e2fe9efdc64da068ed Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sat, 10 Jan 2026 00:50:25 -0800 Subject: [PATCH 11/19] feat: Added assertion test and added logger test to tests/load_all.as --- misc/assert.as | 7 +-- tests/load_all.as | 4 +- tests/test_assert.as | 121 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 tests/test_assert.as diff --git a/misc/assert.as b/misc/assert.as index 44bd0a5..059703e 100644 --- a/misc/assert.as +++ b/misc/assert.as @@ -9,10 +9,11 @@ /** * @brief Assertion function to test statements. Will print out if a exception occurs and the error involved. * Very limited to what line the assert was called on however. -* @param Statement to pass in that should be true, if false, then a throw call will be passed. +* @param testStatement Statement to pass in that should be true, if false, then a throw call will be passed. +* @param errMsg Error message that throw should pass when the statement to test fails. */ -void assert( const bool testStatement ) +void assert( const bool testStatement, const string&in errMsg = "Passed statement was false!" ) { if (!testStatement) - throw("Assertion hit! Statement failed!"); + throw("Assertion hit! Error: " + errMsg); } diff --git a/tests/load_all.as b/tests/load_all.as index 7e6d18d..d97e77c 100644 --- a/tests/load_all.as +++ b/tests/load_all.as @@ -2,4 +2,6 @@ // Purpose: Convenience object to load all tests at once. // -------------------------------- -#include "test_CuboidVolumeSimple.as" \ No newline at end of file +#include "test_assert.as" +#include "test_CuboidVolumeSimple.as" +#include "test_logger.as" diff --git a/tests/test_assert.as b/tests/test_assert.as new file mode 100644 index 0000000..432bc5d --- /dev/null +++ b/tests/test_assert.as @@ -0,0 +1,121 @@ +/** +* @brief Testing the assert function implementation. +* @details There is no proper assert function for AngelScript, so this is a small implementation that will throw then there is a error. +* @authors Orsell +* +* @license Distributed under the MIT license - Copyright (c) 2026 Project Collapse Studios +*/ + +#include "../misc/logger.as" +#include "../misc/assert.as" + +[ServerCommand("as_test_assert", "Testing assert function functionality.")] +void TestAssertions(const CommandArgs@ args) +{ + Logger log("AssertTest_Logger");; + + log.Info("----------------------------------------"); + log.Info("Testing assert function functionality!"); + log.Info("\n"); + + log.Info("// ---------- TEST 1: Testing Ideal Functionality"); + + // Test ideal functionality (should pass). + try + { + assert(true, "TEST 1-1: Pass test failed!"); + assert(1 + 1 == 2, "TEST 1-2: Pass test failed!"); + assert(10 > 3, "TEST 1-3: Pass test failed!"); + log.Info("[PASS] Ideal functionality test."); + } + catch + { + log.Warn("[FAIL] Ideal functionality threw unexpectedly: " + getExceptionInfo()); + } + + log.Info("\n"); + log.Info("// ---------- TEST 2: Testing Harder Logic Functionality"); + // Throw in something harder to work with, complex expressions and logic chains. + try + { + int a = 5; + int b = 10; + bool complexCheck = (a * 2 == b) && (b / a == 2) && !(a > b); + + assert(complexCheck); + + array values = { 1, 2, 3, 4, 5 }; + assert(values.length() == 5, "TEST 2-1: Pass test failed!"); + assert(values[2] == 3, "TEST 2-2: Pass test failed!"); + + log.Info("[PASS] Complex logic test."); + } + catch + { + log.Warn("[FAIL] Complex logic test failed: " + getExceptionInfo()); + } + + log.Info("\n"); + log.Info("// ---------- TEST 3: Testing For Error Cases"); + // Test error cases (should fail). + try + { + assert(false, "TEST 3-1: Error test pass!"); + log.Warn("[FAIL] Error case did NOT throw as expected!"); + } + catch + { + log.Info("[PASS] Error case threw correctly: " + getExceptionInfo()); + } + + try + { + int x = 3; + assert(x > 100, "TEST 3-2: Error test pass!"); // intentional failure + log.Warn("[FAIL] Invalid comparison did NOT throw!"); + } + catch + { + log.Info("[PASS] Invalid comparison threw correctly: " + getExceptionInfo()); + } + + log.Info("\n"); + log.Info("// ---------- TEST 4: Testing Stress Test Functionality"); + // Stress test, repeated calls, mixture of pass/fail. + int failureCount = 0; + int iterations = 10000; + + for (int i = 0; i < iterations; i++) + { + try + { + assert(i >= 0, "TEST 4-1: Pass test failed!"); // always true + assert((i % 2 == 0) || (i % 2 == 1)); // always true + } + catch + { + failureCount++; + } + } + + // Intentional stress failures + for (int i = 0; i < 100; i++) + { + try + { + assert(i < 0); // always false + } + catch + { + failureCount++; + } + } + + log.Info("Stress test iterations: " + iterations); + log.Info("Stress test caught failures: (" + failureCount + "/100)"); + log.Info("If caught failures is greater or less than 100, then test failed!"); + + log.Info("\n"); + log.Info("Assert function functionality testing completed!"); + log.Info("----------------------------------------\n"); +} \ No newline at end of file From 9bbc98a771d5c7c859dfa7d3ca556cf3b74dcf4b Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sat, 10 Jan 2026 17:32:22 -0800 Subject: [PATCH 12/19] feat: Added addAmt to add functions and changed returned arrays by find functions to an array of EntitiInfo --- entities/entityarray.as | 56 ++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index 611a506..6849484 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -76,6 +76,13 @@ final class EntityInfo return true; } + + void Print() + { + Msg("EntityHandle->GetEntityName: " + this.entHandle.GetEntityName() + " | "); + Msg("EntityHandle->GetEntityIndex: " + this.entHandle.GetEntityIndex() + " | "); + Msg("Tags: " + this.tags + "\n"); + } } // Custom array type that stores specifically added sets of Entities and information about them. @@ -142,14 +149,15 @@ class EntityArray */ int Length() { return entArr.length(); } - void Print() + /** + * @brief Print all the contents of the array. + */ + void PrintArray() { for (int i = 0; i < entArr.length(); i++) { Msg("Array Position: " + i + " | "); - Msg("EntityHandle->GetEntityName: " + entArr[i].entHandle.GetEntityName() + " | "); - Msg("EntityHandle->GetEntityIndex: " + entArr[i].entHandle.GetEntityIndex() + " | "); - Msg("Tags: " + entArr[i].tags + "\n"); + entArr[i].Print(); } } @@ -159,16 +167,22 @@ class EntityArray * @brief Add a entity to the EntityArray by its entity name. * @param entName Entity name of the entity to add. * @param tags (optional) What tags should be added with the entity. - * @// TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + * @param addAmt (optional) How many of the entities by entity name should be added. */ - void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE ) + void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE, const int addAmt = 1 ) { - for (CBaseEntity@ ent = null; ent = EntityList().FindByName(ent, entName);) + CBaseEntity@ ent = null; + for (int i = 0; i < addAmt; ent = EntityList().FindByName(ent, entName)) { + if (i == addAmt) + return; + entArr.insertLast(EntityInfo(ent, tags)); DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\"."); if (tags > 0) DevMsgl("Entity tag value is: \"" + tags + "\""); + + i++; } } @@ -176,16 +190,22 @@ class EntityArray * @brief Add a entity to the EntityArray by its class name. * @param className Class name of the entity to add. * @param tags (optional) What tags should be added with the entity. - * @// TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. + * @param addAmt (optional) How many of the entities by class name should be added. */ - void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE ) + void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE, const int addAmt = 1 ) { - for (CBaseEntity@ ent = null; ent = EntityList().FindByClassname(ent, className);) + CBaseEntity@ ent = null; + for (int i = 0; i < addAmt; ent = EntityList().FindByClassname(ent, className)) { + if (i == addAmt) + return; + entArr.insertLast(EntityInfo(ent, tags)); DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\""); if (tags > 0) DevMsgl("Entity tag value is: \"" + tags + "\""); + + i++; } } @@ -193,13 +213,12 @@ class EntityArray * @brief Add a entity to the EntityArray by its handle. * @param entHandle Handle of the entity to add. * @param tags (optional) What tags should be added with the entity. - * @// TODO Maybe a "addAmt" like the "rmAmt" that "RemoveByEntityName" does could help. */ void AddByHandle( const CBaseEntity@ entHandle, const EntityTags tags = EntityTag::NONE ) { if (entHandle == null) { - Warningl("Invalid handle passed to AddByHandle!"); + Warningl("[EntityHandle] Invalid handle passed to AddByHandle!"); return; } @@ -219,7 +238,6 @@ class EntityArray */ void RemoveByEntityName( const string&in entName, int rmAmt = 1 ) { - // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? for (int i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; @@ -241,7 +259,6 @@ class EntityArray */ void RemoveByClassname( const string&in className, int rmAmt = 1 ) { - // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? for (int i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; @@ -262,7 +279,6 @@ class EntityArray */ void RemoveByHandle( const CBaseEntity@ entHandle ) { - // TODO-FIXME: foreach would work better here, but for some reason the AS extension is saying it's invalid and doesn't exist? for (int i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; @@ -328,7 +344,7 @@ class EntityArray * @param handle Handle to search for in the array. * @return Simple array of EntityInfo with the given handle. */ - array@ FindByHandle( const CBaseEntity@ handle ) + array@ FindByHandle( const CBaseEntity@ handle ) { array results; for (int i = 0; i < entArr.length(); i++) @@ -345,7 +361,7 @@ class EntityArray * @param entName Name of entity to search for in the array. * @return Simple array of EntityInfo with the given name. */ - array@ FindByEntityName( const string&in entName ) + array@ FindByEntityName( const string&in entName ) { array results; for (int i = 0; i < entArr.length(); i++) @@ -362,7 +378,7 @@ class EntityArray * @param className Class name of entity to search for in the array. * @return Simple array of EntityInfo with the given class name. */ - array@ FindByClassname( const string&in className ) + array@ FindByClassname( const string&in className ) { array results; for (int i = 0; i < entArr.length(); i++) @@ -379,7 +395,7 @@ class EntityArray * @param tag Tags to search for in the array. * @return Array of entities with the given tags. */ - array@ FindByTag( const EntityTags tag ) + array@ FindByTag( const EntityTags tag ) { array results; for (int i = 0; i < entArr.length(); i++) @@ -389,7 +405,7 @@ class EntityArray results.insertLast(entArr[i]); } } - + return results; } } From 112a267d8ab23e6a42bd1553bac8c1975bad44a0 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sat, 17 Jan 2026 12:51:11 -0800 Subject: [PATCH 13/19] lsp: Updated LSP dump from P2:CE and added launch.json for working with the AS Debugger --- .vscode/launch.json | 14 + README.md | 2 +- as.predefined | 712 ++++++++++++++++++++++---------------------- 3 files changed, 373 insertions(+), 355 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..639a842 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,14 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Attach", + "type": "asdbg", + "request": "attach", + "debugServer": 4711 + } + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 691cebb..015e5a9 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Common library for Strata's Angel Script implementation. Every script can be imported by both client and the server side. -However, functionality will be limited for either of them, thus our documentation shall contain information about what functionality is available where. \ No newline at end of file +However, functionality will be limited for either of them, thus our documentation shall contain information about what functionality is available where. diff --git a/as.predefined b/as.predefined index 968ea7a..d546587 100644 --- a/as.predefined +++ b/as.predefined @@ -107,9 +107,9 @@ enum EFieldType { FIELD_TYPECOUNT } class array{ - T[]@ array(int&in); - T[]@ array(int&in, uint length); - T[]@ array(int&in, uint length, const T&in value); + array(int&in); + array(int&in, uint length); + array(int&in, uint length, const T&in value); T& opIndex(uint index); const T& opIndex(uint index) const; uint opForBegin() const; @@ -117,9 +117,9 @@ class array{ uint opForNext(uint) const; const T& opForValue0(uint index) const; uint opForValue1(uint index) const; - T[]& opAssign(const T[]&in); + array& opAssign(const array&in); void insertAt(uint index, const T&in value); - void insertAt(uint index, const T[]&inout arr); + void insertAt(uint index, const array&inout arr); void insertLast(const T&in value); void removeAt(uint index); void removeLast(); @@ -136,9 +136,9 @@ class array{ int find(uint startAt, const T&in value) const; int findByRef(const T&in value) const; int findByRef(uint startAt, const T&in value) const; - bool opEquals(const T[]&in) const; + bool opEquals(const array&in) const; bool isEmpty() const; - void sort(T[]::less&in, uint startAt = 0, uint count = uint(-1)); + void sort(array::less&in, uint startAt = 0, uint count = uint(-1)); funcdef bool less(const T&in, const T&in); } class string{ @@ -181,7 +181,8 @@ class string{ string tolower() const; string toupper() const; string trim() const; - int64 toInt() const; + int64 toInt(int base = 10) const; + uint64 toUInt(int base = 10) const; float toFloat() const; uint locate(const string&in, const uint = 0) const; string substr(const int start, const int length) const; @@ -193,7 +194,7 @@ class string{ bool isNumerical() const; bool isNumeric() const; bool isAlphaNumerical() const; - string[]@ split(const string&in) const; + array@ split(const string&in) const; } class dictionaryValue{ ~dictionaryValue(); @@ -210,7 +211,7 @@ class dictionaryValue{ double opConv(); } class dictionary{ - dictionary@ dictionary(); + dictionary(); dictionary& opAssign(const dictionary&in); void set(const string&in, const ?&in); bool get(const string&in, ?&out) const; @@ -223,7 +224,7 @@ class dictionary{ uint getSize() const; bool delete(const string&in); void deleteAll(); - string[]@ getKeys() const; + array@ getKeys() const; dictionaryValue& opIndex(const string&in); const dictionaryValue& opIndex(const string&in) const; dictionaryIter@ opForBegin() const; @@ -235,9 +236,9 @@ class dictionary{ class dictionaryIter{ } class grid{ - grid@ grid(int&in); - grid@ grid(int&in, uint, uint); - grid@ grid(int&in, uint, uint, const T&in); + grid(int&in); + grid(int&in, uint, uint); + grid(int&in, uint, uint, const T&in); T& opIndex(uint, uint); const T& opIndex(uint, uint) const; void resize(uint width, uint height); @@ -245,10 +246,10 @@ class grid{ uint height() const; } class any{ - any@ any(); - any@ any(?&in); - any@ any(const int64&in); - any@ any(const double&in); + any(); + any(?&in); + any(const int64&in); + any(const double&in); any& opAssign(any&in); void store(?&in); void store(const int64&in); @@ -603,8 +604,10 @@ class Color{ uint raw; } class ConVar{ - ConVar(const string&in, const string&in, EConVarFlag); - ConVar(const ConVar&in); + ~ConVar(); + ConVar(const string&in name, const string&in value, EConVarFlag flags = FCVAR_NONE); + ConVar(const ConVar&in other); + ConVar(const string&in name, const string&in defValue, EConVarFlag flags, ConVar::ChangeCallback&in changeCallback); int GetInt() const; float GetFloat() const; bool GetBool() const; @@ -612,15 +615,16 @@ class ConVar{ string GetString() const; string GetStringFast() const; string GetDefault() const; - void SetValue(int); - void SetValue(float); - void SetValue(const string&in); - void SetValue(Color); + void SetValue(int value); + void SetValue(float value); + void SetValue(const string&in value); + void SetValue(Color value); void Reset(); + funcdef void ChangeCallback(ConVar&in, const string&in, float); } class ConVarRef{ ~ConVarRef(); - ConVarRef(const string&in); + ConVarRef(const string&in name); bool IsValid() const; float GetFloat() const; int GetInt() const; @@ -629,13 +633,13 @@ class ConVarRef{ string GetString() const; Vector GetVector() const; Vector4D GetVector4D() const; - bool SetValue(int); - bool SetValue(float); - bool SetValue(bool); - bool SetValue(const string&in); - bool SetValue(Color); - bool SetValue(Vector); - bool SetValue(Vector4D); + bool SetValue(int value); + bool SetValue(float value); + bool SetValue(bool value); + bool SetValue(const string&in value); + bool SetValue(Color value); + bool SetValue(Vector value); + bool SetValue(Vector4D value); EConVarFlag GetFlags() const; string GetDefault() const; float GetMin() const; @@ -653,37 +657,38 @@ class CollisionProperty{ int GetCollisionGroup() const; const Vector& GetCollisionOrigin() const; void SetCollisionBounds(const Vector&in, const Vector&in); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - bool IsPointInBounds(const Vector&in) const; + bool IsPointInBounds(const Vector&in pos) const; } class GameEvent{ string GetName() const; bool IsReliable() const; bool IsLocal() const; - bool IsEmpty(const string&in) const; - bool GetBool(const string&in name, bool def = false) const; - int GetInt(const string&in name, int def = 0) const; - int GetUint64(const string&in name, uint64 def = 0) const; - float GetFloat(const string&in name, float def = 0) const; - string GetString(const string&in name, string def = "") const; - void SetBool(const string&in, bool); - void SetInt(const string&in, int); - void SetUint64(const string&in, uint64); - void SetFloat(const string&in, float); - void SetString(const string&in, const string&in); + bool IsEmpty(const string&in key) const; + bool GetBool(const string&in key, bool def = false) const; + int GetInt(const string&in key, int def = 0) const; + uint64 GetUint64(const string&in key, uint64 def = 0) const; + float GetFloat(const string&in key, float def = 0) const; + string GetString(const string&in key, const string&in def = "") const; + void SetBool(const string&in key, bool val); + void SetInt(const string&in key, int val); + void SetUint64(const string&in key, uint64 val); + void SetFloat(const string&in key, float val); + void SetString(const string&in key, const string&in val); } class IGameEventManager{ GameEvent@ CreateEvent(const string&in name, bool force = false); bool FireEvent(GameEvent@ event, bool dontBoradast = false); - bool FireEventClientSide(GameEvent@); + bool FireEventClientSide(GameEvent@ event); } class CommandArgs{ int ArgC() const; string GetCommandString() const; - string Arg(int) const; + string Arg(int idx) const; + string opIndex(int idx) const; } -class cplane_t{ +class cplane_t : VPlane{ void Init(const Vector&in vNormal, float dist); void Init(const Vector&in vNormal, const Vector&in vPointOnPlane); float DistTo(const Vector&in vVec) const; @@ -698,17 +703,17 @@ class cplane_t{ } class StorageScope{ ~StorageScope(); - StorageScope(string); + StorageScope(const string&in name); void Clear(const string&in); void ClearAll(); - float GetFloat(const string&in); - int GetInt(const string&in); - Vector GetVector(const string&in); - string GetString(const string&in); - void SetFloat(const string&in, float); - void SetInt(const string&in, int); - void SetVector(const string&in, const Vector&in); - void SetString(const string&in, const string&in); + float GetFloat(const string&in key); + int GetInt(const string&in key); + Vector GetVector(const string&in key); + string GetString(const string&in key); + void SetFloat(const string&in key, float value); + void SetInt(const string&in key, int value); + void SetVector(const string&in key, const Vector&in value); + void SetString(const string&in key, const string&in value); } class trace_t{ ~trace_t(); @@ -760,74 +765,73 @@ class IPhysicsObject{ bool IsMotionEnabled() const; bool IsMoveable() const; bool IsAttachedToConstraint(bool&out) const; - void EnableCollisions(bool&out); - void EnableGravity(bool&out); - void EnableDrag(bool&out); - void EnableMotion(bool&out); + void EnableCollisions(bool&out enable); + void EnableGravity(bool&out enable); + void EnableDrag(bool&out enable); + void EnableMotion(bool&out enable); void Wake(); void Sleep(); - void SetMass(float&out); + void SetMass(float&out mass); float GetMass() const; float GetInvMass() const; Vector GetInertia() const; Vector GetInvInertia() const; - void SetInertia(const Vector&in); - void SetBuoyancyRatio(float&out); + void SetInertia(const Vector&in inertia); + void SetBuoyancyRatio(float&out ratio); int GetMaterialIndex() const; - void SetMaterialIndex(int&out); + void SetMaterialIndex(int&out index); uint GetContents() const; - void SetContents(uint&out); + void SetContents(uint&out contents); float GetSphereRadius() const; - void SetSphereRadius(float&out); + void SetSphereRadius(float&out radius); float GetEnergy() const; Vector GetMassCenterLocalSpace() const; - void SetPosition(const Vector&in, const QAngle&in, bool&out); - void SetPositionMatrix(const matrix3x4_t&in, bool&out); - void ApplyForceCenter(const Vector&in); - void ApplyForceOffset(const Vector&in, const Vector&in); - void ApplyTorqueCenter(const Vector&in); - float CalculateLinearDrag(const Vector&in) const; - float CalculateAngularDrag(const Vector&in) const; - void SetDamping(float, float); - void GetDamping(float&out, float&out) const; - void SetDragCoefficient(float, float); - void GetPosition(Vector&out, QAngle&out) const; - void GetPositionMatrix(matrix3x4_t&out) const; - void SetVelocity(const Vector&in, const Vector&in); - void SetVelocityInstantaneous(const Vector&in, const Vector&in); - void GetVelocity(Vector&out, Vector&out) const; - void AddVelocity(const Vector&in, const Vector&in); - Vector GetVelocityAtPoint(const Vector&in) const; - void GetImplicitVelocity(Vector&out, Vector&out) const; - void CalculateForceOffset(const Vector&in, const Vector&in, Vector&out, Vector&out) const; - void CalculateVelocityOffset(const Vector&in, const Vector&in, Vector&out, Vector&out) const; + void SetPosition(const Vector&in pos, const QAngle&in angles, bool&out teleport); + void SetPositionMatrix(const matrix3x4_t&in matrix, bool&out teleport); + void ApplyForceCenter(const Vector&in force); + void ApplyForceOffset(const Vector&in force, const Vector&in pos); + void ApplyTorqueCenter(const Vector&in torque); + float CalculateLinearDrag(const Vector&in direction) const; + float CalculateAngularDrag(const Vector&in axis) const; + void SetDamping(float speed, float rot); + void GetDamping(float&out speed, float&out rot) const; + void SetDragCoefficient(float drag, float angularDrag); + void GetPosition(Vector&out pos, QAngle&out angle) const; + void GetPositionMatrix(matrix3x4_t&out mat) const; + void SetVelocity(const Vector&in velocity, const Vector&in angularVelocity); + void SetVelocityInstantaneous(const Vector&in velocity, const Vector&in angularVelocity); + void GetVelocity(Vector&out velocity, Vector&out angularVelocity) const; + void AddVelocity(const Vector&in velocity, const Vector&in angularVelocity); + Vector GetVelocityAtPoint(const Vector&in pos) const; + void GetImplicitVelocity(Vector&out velocity, Vector&out angularVelocity) const; + void CalculateForceOffset(const Vector&in force, const Vector&in pos, Vector&out centerForce, Vector&out centerTorque) const; + void CalculateVelocityOffset(const Vector&in force, const Vector&in pos, Vector&out centerVelocity, Vector&out centerAngularVelocity) const; } - -class CBaseEntity { - CBaseEntity@ CBaseEntity(); +class CBaseEntity{ + CBaseEntity(); void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -838,64 +842,64 @@ class CBaseEntity { CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; } -class __CBaseEntityNative{ +class __CBaseEntityNative : CBaseEntity{ void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -906,38 +910,38 @@ class __CBaseEntityNative{ CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; } class Variant{ @@ -951,16 +955,16 @@ class Variant{ void Vector3D(Vector&out) const; void Angle3D(QAngle&out) const; Color Color32() const; - void SetBool(bool); - void SetInt(int); - void SetFloat(float); - void SetEntity(CBaseEntity@); - void SetVector3D(const Vector&in); - void SetPositionVector3D(const Vector&in); - void SetAngle3D(const QAngle&in); + void SetBool(bool b); + void SetInt(int i); + void SetFloat(float f); + void SetEntity(CBaseEntity@ ent); + void SetVector3D(const Vector&in vec); + void SetPositionVector3D(const Vector&in pos); + void SetAngle3D(const QAngle&in ang); void SetColor32(Color clr); - void SetColor32(int, int, int, int); - void SetString(const string&in); + void SetColor32(int r, int g, int b, int a); + void SetString(const string&in s); } class InputData{ ~InputData(); @@ -970,31 +974,31 @@ class InputData{ Variant value; int nOutputID; } -class CBaseAnimating{ - CBaseAnimating@ CBaseAnimating(); +class CBaseAnimating : CBaseEntity{ + CBaseAnimating(); void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -1005,96 +1009,96 @@ class CBaseAnimating{ CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; - int LookupAttachment(const string&in); - bool GetAttachment(const string&in, Vector&out, QAngle&out); - bool GetAttachment(int, Vector&out, QAngle&out); - int GetBodygroup(int); - int GetBodygroupCount(int); - string GetBodygroupName(int); - string GetBodygroupPartName(int, int); + int LookupAttachment(const string&in attachmentName); + bool GetAttachment(const string&in attachmentName, Vector&out pos, QAngle&out angle); + bool GetAttachment(int attachmentIdx, Vector&out pos, QAngle&out angle); + int GetBodygroup(int group); + int GetBodygroupCount(int group); + string GetBodygroupName(int group); + string GetBodygroupPartName(int group, int part); int GetBoneCount(); - void GetBonePosition(int, Vector&out, QAngle&out); - int GetBodygroupCount(); + void GetBonePosition(int bone, Vector&out pos, QAngle&out angle); + int GetNumBodyGroups(); int GetObjectScaleLevel(); - float GetPoseParameter(int); - bool GetPoseParameterRange(int, float&out, float&out); + float GetPoseParameter(int param); + bool GetPoseParameterRange(int param, float&out min, float&out max); int GetSequence(); - string GetSequenceActivityName(int); + string GetSequenceActivityName(int sequence); int GetSequenceCount(); - float GetSequenceCycleRate(int); - float GetSequenceDuration(int); - string GetSequenceName(int); + float GetSequenceCycleRate(int sequence); + float GetSequenceDuration(int sequence); + string GetSequenceName(int sequence); int GetSkin(); bool IsActivityFinished(); bool IsSequenceFinished(); - bool IsSequenceLooping(int); - bool IsValidSequence(int); - int LookupActivity(const string&in); - int LookupPoseParameter(const string&in); - int LookupSequence(const string&in); - void SetBodygroup(int, int); - void SetPlaybackRate(float); - float SetPoseParameter(int, float); - void SetSequence(int); - void SetSkin(int); + bool IsSequenceLooping(int sequence); + bool IsValidSequence(int sequence); + int LookupActivity(const string&in name); + int LookupPoseParameter(const string&in name); + int LookupSequence(const string&in name); + void SetBodygroup(int group, int value); + void SetPlaybackRate(float rate); + float SetPoseParameter(int param, float value); + void SetSequence(int sequence); + void SetSkin(int skin); } -class __CBaseAnimatingNative{ +class __CBaseAnimatingNative : CBaseAnimating{ void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -1105,97 +1109,97 @@ class __CBaseAnimatingNative{ CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; - int LookupAttachment(const string&in); - bool GetAttachment(const string&in, Vector&out, QAngle&out); - bool GetAttachment(int, Vector&out, QAngle&out); - int GetBodygroup(int); - int GetBodygroupCount(int); - string GetBodygroupName(int); - string GetBodygroupPartName(int, int); + int LookupAttachment(const string&in attachmentName); + bool GetAttachment(const string&in attachmentName, Vector&out pos, QAngle&out angle); + bool GetAttachment(int attachmentIdx, Vector&out pos, QAngle&out angle); + int GetBodygroup(int group); + int GetBodygroupCount(int group); + string GetBodygroupName(int group); + string GetBodygroupPartName(int group, int part); int GetBoneCount(); - void GetBonePosition(int, Vector&out, QAngle&out); - int GetBodygroupCount(); + void GetBonePosition(int bone, Vector&out pos, QAngle&out angle); + int GetNumBodyGroups(); int GetObjectScaleLevel(); - float GetPoseParameter(int); - bool GetPoseParameterRange(int, float&out, float&out); + float GetPoseParameter(int param); + bool GetPoseParameterRange(int param, float&out min, float&out max); int GetSequence(); - string GetSequenceActivityName(int); + string GetSequenceActivityName(int sequence); int GetSequenceCount(); - float GetSequenceCycleRate(int); - float GetSequenceDuration(int); - string GetSequenceName(int); + float GetSequenceCycleRate(int sequence); + float GetSequenceDuration(int sequence); + string GetSequenceName(int sequence); int GetSkin(); bool IsActivityFinished(); bool IsSequenceFinished(); - bool IsSequenceLooping(int); - bool IsValidSequence(int); - int LookupActivity(const string&in); - int LookupPoseParameter(const string&in); - int LookupSequence(const string&in); - void SetBodygroup(int, int); - void SetPlaybackRate(float); - float SetPoseParameter(int, float); - void SetSequence(int); - void SetSkin(int); + bool IsSequenceLooping(int sequence); + bool IsValidSequence(int sequence); + int LookupActivity(const string&in name); + int LookupPoseParameter(const string&in name); + int LookupSequence(const string&in name); + void SetBodygroup(int group, int value); + void SetPlaybackRate(float rate); + float SetPoseParameter(int param, float value); + void SetSequence(int sequence); + void SetSkin(int skin); } -class CBaseCombatWeapon { - CBaseCombatWeapon@ CBaseCombatWeapon(); +class CBaseCombatWeapon : CBaseEntity{ + CBaseCombatWeapon(); void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -1206,38 +1210,38 @@ class CBaseCombatWeapon { CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; void PrimaryAttack(); void SecondaryAttack(); @@ -1248,30 +1252,30 @@ class CBaseCombatWeapon { bool Holster(CBaseCombatWeapon@ switchingTo = null); CBaseEntity@ GetOwner() const; } -class __CBaseCombatWeaponNative{ +class __CBaseCombatWeaponNative : CBaseCombatWeapon{ void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -1282,38 +1286,38 @@ class __CBaseCombatWeaponNative{ CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; void PrimaryAttack(); void SecondaryAttack(); @@ -1324,31 +1328,31 @@ class __CBaseCombatWeaponNative{ bool Holster(CBaseCombatWeapon@ switchingTo = null); CBaseEntity@ GetOwner() const; } -class CLight{ - CLight@ CLight(); +class CLight : CBaseEntity{ + CLight(); void Spawn(); void Precache(); void SetModel(const string&in); - void PrecacheModel(const string&in); + void PrecacheModel(const string&in modelName); const Vector& GetAbsOrigin() const; - void SetAbsOrigin(const Vector&in); + void SetAbsOrigin(const Vector&in origin); const Vector& GetLocalOrigin() const; - void SetLocalOrigin(const Vector&in); + void SetLocalOrigin(const Vector&in origin); const QAngle& GetAbsAngles() const; - void SetAbsAngles(const QAngle&in); + void SetAbsAngles(const QAngle&in angles); const QAngle& GetLocalAngles() const; - void SetLocalAngles(const QAngle&in); + void SetLocalAngles(const QAngle&in angles); const Vector& GetAbsVelocity() const; - void SetAbsVelocity(const Vector&in); + void SetAbsVelocity(const Vector&in velocity); const Vector& GetLocalVelocity() const; - void SetLocalVelocity(const Vector&in); + void SetLocalVelocity(const Vector&in velocity); CBaseEntity@ GetOwnerEntity() const; - void SetOwnerEntity(CBaseEntity@); + void SetOwnerEntity(CBaseEntity@ owner); void SetOwnerEntity(CBaseEntity@ parent, int attachment = -1); - void SetParentAttachmentMaintainOffset(const string&in); - void SetParentAttachment(const string&in); + void SetParentAttachmentMaintainOffset(const string&in attachmentName); + void SetParentAttachment(const string&in attachmentName); int GetTeamNumber() const; - void ChangeTeam(int); + void ChangeTeam(int team); Vector EyePosition() const; const QAngle& EyeAngles() const; const QAngle& LocalEyeAngles() const; @@ -1359,38 +1363,38 @@ class CLight{ CollisionProperty@ CollisionProp(); void SetMoveType(EMoveType val, EMoveCollide moveCollide = MOVECOLLIDE_DEFAULT); EMoveType GetMoveType() const; - void SetMoveCollide(EMoveCollide); + void SetMoveCollide(EMoveCollide val); EMoveCollide GetMoveCollide() const; CBaseEntity@ GetMoveParent(); - void SetSolid(ESolidType); + void SetSolid(ESolidType val); ESolidType GetSolid() const; - void SetCollisionBounds(const Vector&in, const Vector&in); + void SetCollisionBounds(const Vector&in mins, const Vector&in maxs); void SetThink(ThinkFunc_t@ thinkFunc, float nextThinkTime = 0.0, const string&in context = ""); void SetNextThink(float thinkTime, const string&in context = ""); - void EmitSound(const string&in); - void StopSound(const string&in); + void EmitSound(const string&in soundName); + void StopSound(const string&in soundName); int GetHealth() const; int GetMaxHealth() const; - void SetHealth(int); - void SetMaxHealth(int); - void FireBullets(const FireBulletsInfo_t&in); + void SetHealth(int health); + void SetMaxHealth(int health); + void FireBullets(const FireBulletsInfo_t&in info); void Remove(); string GetEntityName(); string GetClassname() const; string GetDebugName(); int GetEntityIndex() const; - bool GetKeyValue(const string&in, string&out) const; + bool GetKeyValue(const string&in key, string&out value) const; string GetModelName() const; float GetElasticity() const; - void SetElasticity(float); + void SetElasticity(float elasticity); bool IsFloating(); bool IsBSPModel() const; float GetFriction() const; - void SetFriction(float); - void SetGravity(float); + void SetFriction(float friction); + void SetGravity(float gravity); float GetGravity() const; bool HasVPhysicsObject() const; - void PrecacheScriptSound(const string&in); + void PrecacheScriptSound(const string&in soundName); IPhysicsObject@ GetPhysicsObject() const; float GetInnerAngle() const; float GetOuterAngle() const; @@ -1399,38 +1403,38 @@ class CLight{ float GetClusteredRadius() const; int GetColorScale() const; int GetColorScaleHDR() const; - void SetColor(const Color&in, float); - void SetColorHDR(const Color&in, float); + void SetColor(const Color&in color, float lightScale); + void SetColorHDR(const Color&in color, float lightScale); float GetRadiusOverride() const; - void SetRadiusOverride(float); + void SetRadiusOverride(float radius); void Toggle(); void TurnOff(); void TurnOn(); - void SetShadowSize(int); + void SetShadowSize(int size); int GetShadowSize() const; - void SetPattern(const string&in); + void SetPattern(const string&in pattern); string GetPattern() const; - void SetOuterAngle(float); - void SetInnerAngle(float); + void SetOuterAngle(float angle); + void SetInnerAngle(float angle); bool GetState() const; - void SetLightFalloffCLQ(float, float, float); - void SetLightFalloffD50D0(float, float); - void GetLightFalloffCLQ(float&out, float&out, float&out); - void GetLightFalloffD50D0(float&out, float&out); + void SetLightFalloffCLQ(float constant, float linear, float quadratic); + void SetLightFalloffD50D0(float f50Pct, float f0Pct); + void GetLightFalloffCLQ(float&out constant, float&out linear, float&out quadratic); + void GetLightFalloffD50D0(float&out f50Pct, float&out f0Pct); bool IsHDR() const; } class CGlobalEntityList{ - CBaseEntity@ FindByClassname(CBaseEntity@, const string&in); - CBaseEntity@ FindByName(CBaseEntity@, const string&in); - CBaseEntity@ FindInSphere(CBaseEntity@, const Vector&in, float); - CBaseEntity@ Next(CBaseEntity@); + CBaseEntity@ FindByClassname(CBaseEntity@ start, const string&in className); + CBaseEntity@ FindByName(CBaseEntity@ start, const string&in name); + CBaseEntity@ FindInSphere(CBaseEntity@ start, const Vector&in center, float radius); + CBaseEntity@ Next(CBaseEntity@ current); CBaseEntity@ First(); - CBaseEntity@ FindByTarget(CBaseEntity@, const string&in); - CBaseEntity@ FindByModel(CBaseEntity@, const string&in); - CBaseEntity@ FindByNameNearest(const string&in, const Vector&in, float); - CBaseEntity@ FindByNameWithin(CBaseEntity@, const string&in, const Vector&in, float); - CBaseEntity@ FindByClassnameNearest(const string&in, const Vector&in, float); - CBaseEntity@ FindByClassnameWithin(CBaseEntity@, const string&in, const Vector&in, float); + CBaseEntity@ FindByTarget(CBaseEntity@ start, const string&in name); + CBaseEntity@ FindByModel(CBaseEntity@ start, const string&in modelName); + CBaseEntity@ FindByNameNearest(const string&in name, const Vector&in pos, float radius); + CBaseEntity@ FindByNameWithin(CBaseEntity@ start, const string&in name, const Vector&in center, float radius); + CBaseEntity@ FindByClassnameNearest(const string&in name, const Vector&in center, float radius); + CBaseEntity@ FindByClassnameWithin(CBaseEntity@ start, const string&in name, const Vector&in center, float radius); } float fpFromIEEE(uint); uint fpToIEEE(float); @@ -1457,7 +1461,7 @@ float abs(float); float floor(float); float fraction(float); float round(float); -string join(const string[]&in, const string&in); +string join(const array&in, const string&in); void throw(const string&in); string getExceptionInfo(); float BitsToFloat(uint i); @@ -1851,13 +1855,13 @@ namespace util { float GetCurrentTime(); } namespace util { float GetFrameTime(); } namespace util { int GetTickCount(); } CGlobalEntityList@ EntityList(); -namespace util { CBaseEntity@ CreateEntityByName(const string&in); } -namespace util { void TraceLine(const Vector&in, const Vector&in, uint, CBaseEntity@, int, trace_t&out); } -namespace util { void TraceHull(const Vector&in, const Vector&in, const Vector&in, const Vector&in, uint, CBaseEntity@, int, trace_t&out); } -namespace util { void TracePortalLine(const Vector&in, const Vector&in, uint, CBaseEntity@, int, trace_t&out, bool); } -namespace util { CBaseEntity@ GetEntityByIndex(int); } +namespace util { CBaseEntity@ CreateEntityByName(const string&in className); } +namespace util { void TraceLine(const Vector&in start, const Vector&in end, uint mask, CBaseEntity@ ignore, int group, trace_t&out trace); } +namespace util { void TraceHull(const Vector&in start, const Vector&in end, const Vector&in mins, const Vector&in maxs, uint mask, CBaseEntity@ ignore, int group, trace_t&out trace); } +namespace util { void TracePortalLine(const Vector&in start, const Vector&in end, uint mask, CBaseEntity@ ignore, int group, trace_t&out trace, bool transform = true); } +namespace util { CBaseEntity@ GetEntityByIndex(int index); } namespace util { int GetMaxEntities(); } -namespace util { void Remove(CBaseEntity@ pEntity); } +namespace util { void Remove(CBaseEntity@ entity); } Vector2D vec2_origin; Vector2D vec2_invalid; Vector vec3_origin; From af34c0ef27ff563a40f6da5b0661561f9e98fe69 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sun, 25 Jan 2026 20:30:11 -0800 Subject: [PATCH 14/19] fix: Just made "convar" "ConVar" in the comments --- misc/logger.as | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/misc/logger.as b/misc/logger.as index 77cfb44..a48437a 100644 --- a/misc/logger.as +++ b/misc/logger.as @@ -10,7 +10,7 @@ class Logger { private ConVar developerCV; // Create a logger with a given name, will print out messages as [scriptsys][name]: Message - // required_developer_level = 0, Message will only print out when the developer convar is greator or equal to this value. + // required_developer_level = 0, Message will only print out when the developer ConVar is greater or equal to this value. Logger(string name, int required_developer_level = 0) { this.name = name; this.required_developer_level = required_developer_level; @@ -25,14 +25,14 @@ class Logger { // Print an info message to the console // string message - the message to print // string end - string that gets appended to the end of the message - // int required_developer_level (optional) - This message will only print out when the developer convar is greator or equal to this value. Additionally, any negative value will make it use the global required level passed in the constructor. + // int required_developer_level (optional) - This message will only print out when the developer ConVar is greater or equal to this value. Additionally, any negative value will make it use the global required level passed in the constructor. void Info(string message, string end, int required_developer_level = -1) { this.__info(message, end, required_developer_level); } // Print an info message to the console // string message - the message to print - // int required_developer_level - This message will only print out when the developer convar is greator or equal to this value. Additionally, any negative value will make it use the global required level passed in the constructor. + // int required_developer_level - This message will only print out when the developer ConVar is greater or equal to this value. Additionally, any negative value will make it use the global required level passed in the constructor. void Info(string message, int required_developer_level) { this.__info(message, "\n", required_developer_level); } @@ -41,8 +41,8 @@ class Logger { void Info(string message) { this.__info(message, "\n", -1); } - - + + private void __info(string message, string end, int required_developer_level) { int dv_lvl = this.GetDeveloperLevel(); if ( @@ -57,14 +57,14 @@ class Logger { // Print an warning message to the console // string message - the message to print // string end - string that gets appended to the end of the message - // int required_developer_level (optional) - This message will only print out when the developer convar is set to this value. Additionally, any negative value will make it use the global required level passed in the constructor. + // int required_developer_level (optional) - This message will only print out when the developer ConVar is set to this value. Additionally, any negative value will make it use the global required level passed in the constructor. void Warn(string message, string end, int required_developer_level = -1) { this.__warn(message, end, required_developer_level); } // Print an warning message to the console // string message - the message to print - // int required_developer_level - This message will only print out when the developer convar is set to this value. Additionally, any negative value will make it use the global required level passed in the constructor. + // int required_developer_level - This message will only print out when the developer ConVar is set to this value. Additionally, any negative value will make it use the global required level passed in the constructor. void Warn(string message, int required_developer_level) { this.__warn(message, "\n", required_developer_level); } @@ -73,8 +73,8 @@ class Logger { void Warn(string message) { this.__warn(message, "\n", -1); } - - + + private void __warn(string message, string end = "\n", int required_developer_level = -1) { int dv_lvl = this.GetDeveloperLevel(); if ( From 987a3585b8b7785484112338edf8ffa30c091ecc Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sun, 25 Jan 2026 20:59:34 -0800 Subject: [PATCH 15/19] fix: Fixed some syntax issues that preventing compiling --- entities/entityarray.as | 61 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index 6849484..8902dbe 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -28,7 +28,7 @@ typedef uint16 EntityTags; // Max allowed amount of tags currently is 1 << 15, t final class EntityInfo { CBaseEntity@ entHandle; // Handle for the entity. - EntityTags tags; // unint16 number that holds bits. + EntityTags entInfoTags; // unint16 number that holds bits. /** * @brief Default constructor. @@ -36,7 +36,7 @@ final class EntityInfo EntityInfo() { @entHandle = null; - tags = EntityTag::NONE; + entInfoTags = EntityTag::NONE; } /** @@ -44,23 +44,23 @@ final class EntityInfo * @param newEntHandle A CBaseEntity handle to pass to the EntityInfo to store. * @param tags What tags should be associated with the entity. */ - EntityInfo( const CBaseEntity@ newEntHandle, EntityTags tags = EntityTag::NONE ) + EntityInfo( CBaseEntity@ newEntHandle, const EntityTags tags = EntityTag::NONE ) { @entHandle = @newEntHandle; - tags = tags; + entInfoTags = tags; } /** * @brief Assign the contents of one EntityInfo's to another. * @param rhs EntityInfo on the right hand side. */ - EntityInfo& opAssign( const EntityInfo& rhs ) + EntityInfo& opAssign( const EntityInfo&in rhs ) { if (this == rhs) return this; - this.entHandle = rhs.entHandle; - this.tags = rhs.tags; + @this.entHandle = @rhs.entHandle; + this.entInfoTags = rhs.entInfoTags; return this; } @@ -71,7 +71,7 @@ final class EntityInfo */ bool opEquals( const EntityInfo&in rhs ) const { - if ((this.entHandle != rhs.entHandle) || (this.tags != rhs.tags)) + if ((@this.entHandle != @rhs.entHandle) || (this.entInfoTags != rhs.entInfoTags)) return false; return true; @@ -79,23 +79,25 @@ final class EntityInfo void Print() { - Msg("EntityHandle->GetEntityName: " + this.entHandle.GetEntityName() + " | "); - Msg("EntityHandle->GetEntityIndex: " + this.entHandle.GetEntityIndex() + " | "); - Msg("Tags: " + this.tags + "\n"); + Msg("Entity Name: " + this.entHandle.GetEntityName() + " | "); + Msg("Entity Index: " + this.entHandle.GetEntityIndex() + " | "); + Msg("Tags: " + this.entInfoTags + "\n"); } } // Custom array type that stores specifically added sets of Entities and information about them. class EntityArray { + // ---------------- CLASS MEMBERS VARIABLES ---------------- \\ + // The underlying array that holds all the EntityInfo "structs". - array entArr; + private array entArr; /** * @brief Assign the contents of one EntityArray array to another EntityArray. * @param rhs EntityArray on the right hand side. */ - EntityArray& opAssign( const EntityArray& rhs ) + EntityArray& opAssign( const EntityArray&inout rhs ) { if (this == rhs) return this; @@ -117,7 +119,7 @@ class EntityArray return false; // Checking individual items of the array. - for (int i = 0; i < this.entArr.length(); i++) + for (uint i = 0; i < this.entArr.length(); i++) { if (this.entArr[i] != rhs.entArr[i]) return false; @@ -154,7 +156,7 @@ class EntityArray */ void PrintArray() { - for (int i = 0; i < entArr.length(); i++) + for (uint i = 0; i < entArr.length(); i++) { Msg("Array Position: " + i + " | "); entArr[i].Print(); @@ -216,7 +218,7 @@ class EntityArray */ void AddByHandle( const CBaseEntity@ entHandle, const EntityTags tags = EntityTag::NONE ) { - if (entHandle == null) + if (@entHandle == null) { Warningl("[EntityHandle] Invalid handle passed to AddByHandle!"); return; @@ -336,8 +338,6 @@ class EntityArray // ---------------- FIND FUNCTIONS ---------------- \\ - // TODO: Should try and take advantage of using the array's find functions for CBaseEntity handles, - // TODO: however the issue is that the array type used is EntityInfo so CBaseEntity can't be used. /** * @brief Find entities in the EntityArray by a CBaseEntity handle. @@ -346,10 +346,11 @@ class EntityArray */ array@ FindByHandle( const CBaseEntity@ handle ) { - array results; - for (int i = 0; i < entArr.length(); i++) + array results; + + for (uint i = 0; i < entArr.length(); i++) { - if (entArr[i].entHandle == handle) + if (@entArr[i].entHandle == @handle) results.insertLast(entArr[i]); } @@ -363,8 +364,8 @@ class EntityArray */ array@ FindByEntityName( const string&in entName ) { - array results; - for (int i = 0; i < entArr.length(); i++) + array results; + for (uint i = 0; i < entArr.length(); i++) { if (entArr[i].entHandle.GetEntityName() == entName) results.insertLast(entArr[i]); @@ -380,8 +381,8 @@ class EntityArray */ array@ FindByClassname( const string&in className ) { - array results; - for (int i = 0; i < entArr.length(); i++) + array results; + for (uint i = 0; i < entArr.length(); i++) { if (entArr[i].entHandle.GetClassname() == className) results.insertLast(entArr[i]); @@ -397,15 +398,17 @@ class EntityArray */ array@ FindByTag( const EntityTags tag ) { - array results; - for (int i = 0; i < entArr.length(); i++) + array results; + for (uint i = 0; i < entArr.length(); i++) { - if (entArr[i].tags & tag) + //! The LSP will say this is invalid when actually it is, + //! there is no need for a defined operator overload for the bitwise AND. + if ((entArr[i].entInfoTags & tag) != 0) { results.insertLast(entArr[i]); } } - + return results; } } From 5996b16dd180bf0ef41517d400e2b5b4460eb6ab Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:22:55 -0800 Subject: [PATCH 16/19] test: Added EntityArray tests, incomplete because not all functionality is currently working --- tests/load_all.as | 1 + tests/test_EntityArray.as | 124 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 tests/test_EntityArray.as diff --git a/tests/load_all.as b/tests/load_all.as index d97e77c..bf5f0ee 100644 --- a/tests/load_all.as +++ b/tests/load_all.as @@ -4,4 +4,5 @@ #include "test_assert.as" #include "test_CuboidVolumeSimple.as" +#include "test_EntityArray.as" #include "test_logger.as" diff --git a/tests/test_EntityArray.as b/tests/test_EntityArray.as new file mode 100644 index 0000000..5003c1c --- /dev/null +++ b/tests/test_EntityArray.as @@ -0,0 +1,124 @@ +/** +* @brief Test the EntityArray special array type. +* @details +* @authors Orsell +* +* @license Distributed under the MIT license - Copyright (c) 2026 Project Collapse Studios +*/ + +#include "../misc/logger.as" +#include "../misc/assert.as" + +#include "../entities/entityarray.as" + +[ServerCommand("as_test_entarray", "Testing EntityArray functionality.")] +void TestEntityArray(const CommandArgs@ args) +{ + Logger log("EntityArrayTest_Logger"); + + log.Info("Testing EntityArray functionality!"); + + log.Info("// ---------- TEST 1: Testing Ideal Functionality"); + log.Info("// ---------- TEST 1-1: Adding entities to an EntityArray by entity name and with a tag."); + + EntityArray entArray; + + // Test adding entities by name with tags + entArray.AddByEntityName("barney1", EntityTag::NPC, 1); + entArray.AddByClassname("player", EntityTag::FRIENDLY, 1); + entArray.AddByClassname("weapon_pistol", EntityTag::CUSTOM, 1); + entArray.AddByClassname("prop_dynamic", EntityTag::MODEL, 10); + entArray.PrintArray(); + + // Test if entities are correctly added + //assert(entArray.Length() == 12, "TEST 1-1: Check 1 failed!"); + //assert(entArray.FindByEntityName("relay1").length() == 1, "TEST 1-1: Check 2 failed!"); + //assert(entArray.FindByClassname("npc_barney").length() == 1, "TEST 1-1: Check 3 failed!"); + //assert(entArray.FindByClassname("prop_dynamic").length() == 10, "TEST 1-1: Check 4 failed!"); + //assert(entArray.FindByTag(EntityTag::LOGIC).length() == 1, "TEST 1-1: Check 5 failed!"); + + return; + + log.Info("\n"); + log.Info("// ---------- TEST 1-2: Testing equality with another EntityArray."); + // // Test equality operator + EntityArray anotherArray; + anotherArray.AddByEntityName("barney1", EntityTag::NPC, 1); + anotherArray.AddByClassname("logic_relay", EntityTag::LOGIC, 1); + anotherArray.AddByClassname("prop_dynamic", EntityTag::MODEL, 10); + // assert(entArray == anotherArray, "TEST 1-2: Check failed!"); + + log.Info("\n"); + log.Info("// ---------- TEST 1-3: Testing removing entities by name."); + // Test removing entities by name + entArray.RemoveByEntityName("npc_barney", 1); + //assert(entArray.Length() == 11, "TEST 1-3: Check 1 failed!"); + //assert(entArray.FindByEntityName("npc_barney").length() == 0, "TEST 1-3: Check 2 failed!"); + + // log.Info("\n"); + // log.Info("// ---------- TEST 1-4: Testing sorting entities by tags."); + // // Test sorting entities by tags + // entArray.SortEntitiesByTags(true); // Ascending order by tags + // assert(entArray[0].tags == EntityTag::LOGIC, "TEST 1-4: Check 1 failed!"); + // assert(entArray[1].tags == EntityTag::MODEL, "TEST 1-4: Check 2 failed!"); + + // Stress Test + + //log.Info("// ---------- TEST 2-1: Testing stress test scenario adding 1000 entities with random tags."); + // Add 1000 entities with random tags + // for (int i = 0; i < 1000; i++) + // { + // EntityTags randomTag = (EntityTags)(1 << (i % 7)); // Cycle through some tags + // entArray.AddByEntityName("entity_" + i, randomTag); + // } + // assert(entArray.Length() == 1002); // Original 2 entities + 1000 added + // assert(entArray.FindByTag(EntityTag::LOGIC).length() == 1); // LOGIC should still be there + // assert(entArray.FindByTag(EntityTag::NONE).length() == 1000); // None should have many added entities + + // // Test removal of entities by class name + // entArray.RemoveByClassname("prop_dynamic", 1); + // assert(entArray.FindByClassname("prop_dynamic").length() == 0); + + // // Stress Test - Remove entities and ensure correct removal + // entArray.RemoveByEntityName("entity_0", 1); + // assert(entArray.Length() == 1001); // One entity removed + // assert(entArray.FindByEntityName("entity_0").length() == 0); + + // Error Cases + // log.Info("\n"); + // log.Info("// ---------- TEST 3: Testing Error Cases"); + // log.Info("// ---------- TEST 3-1: Testing adding an invalid entity handle."); + + // // Test adding an invalid entity handle + // entArray.AddByHandle(null, EntityTag::NONE); // Should not crash, should be ignored + + // log.Info("\n"); + // log.Info("// ---------- TEST 3-2: Testing removing a non-existing entity."); + // // Test removing a non-existing entity + // entArray.RemoveByEntityName("non_existing_entity"); + // assert(entArray.Length() == 1001, "TEST 3-2: Check failed!"); // Should not have changed length + + // log.Info("\n"); + // log.Info("// ---------- TEST 3-3: Testing find a non-existing entity."); + // // Test finding a non-existing entity + // array nonExistent = entArray.FindByEntityName("non_existing_entity"); + // assert(nonExistent.length() == 0, "TEST 3-3: Check failed!"); // Should return an empty array + + // log.Info("\n"); + // log.Info("// ---------- TEST 3-4: Testing adding entities with conflicting tags."); + // // Test adding entities with conflicting tags + // entArray.AddByEntityName("entity_conflict", EntityTag::ENEMY | EntityTag::FRIENDLY); + // assert(entArray.FindByTag(EntityTag::ENEMY).length() == 1, "TEST 3-4: Check 1 failed!"); + // assert(entArray.FindByTag(EntityTag::FRIENDLY).length() == 1, "TEST 3-4: Check 2 failed!"); + // assert(entArray.FindByTag(EntityTag::ENEMY | EntityTag::FRIENDLY).length() == 1, "TEST 3-4: Check 3 failed!"); + + // log.Info("\n"); + // log.Info("// ---------- TEST 4: Testing removing a non-existing entity."); + // // Remove all entities + // entArray.Clear(); + // assert(entArray.Length() == 0, "TEST 4: Check failed!"); // After clearing, array should be empty + + log.Info("\n"); + log.Info("EntityArray functionality testing completed!"); + log.Info("----------------------------------------\n"); +} From b90202cf1ac80b85dded74c675c35a076616ed1f Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sun, 25 Jan 2026 21:23:30 -0800 Subject: [PATCH 17/19] feat: Switched to using logger for reporting messages, added more contrusctors and operator overloads, added more sort functions, cleaned up some other functions --- entities/entityarray.as | 263 +++++++++++++++++++++++++++++++--------- 1 file changed, 203 insertions(+), 60 deletions(-) diff --git a/entities/entityarray.as b/entities/entityarray.as index 8902dbe..8b1de62 100644 --- a/entities/entityarray.as +++ b/entities/entityarray.as @@ -6,6 +6,10 @@ * @license Distributed under the MIT license - Copyright (c) 2026 Project Collapse Studios */ +#include "../misc/logger.as" + +Logger entArrayLog("EntityArray", 2); + // Tags that can be appended to various EntityInfo's in the EntityArray to find certain specific entities in the array. //? Maybe we could have a way to implement custom tags that can be made and applied in special cases at runtime? // TODO: Currently these were just examples of tags we could have, these can be changed out or changed with whatever. @@ -93,6 +97,28 @@ class EntityArray // The underlying array that holds all the EntityInfo "structs". private array entArr; + + // ---------------- CLASS CTORs/DTORs ---------------- \\ + + /** + * @brief Default constructor for the EntityArray. + */ + EntityArray() + { + entArr.resize(0); + } + + /** + * @brief Copy constructor for the EntityArray. + */ + EntityArray( const EntityArray&inout rhs ) + { + this.entArr = rhs.entArr; + } + + + // ---------------- ARRAY FUNCTIONS ---------------- \\ + /** * @brief Assign the contents of one EntityArray array to another EntityArray. * @param rhs EntityArray on the right hand side. @@ -141,6 +167,31 @@ class EntityArray bool opForEnd( uint index ) const { return index >= entArr.length(); } uint opForNext( uint index ) const { return index + 1; } + /** + * @brief Add assignment operator overload for adding and setting a array. + */ + EntityArray& opAddAssign( const EntityArray&in rhs ) + { + for (uint i = 0; i < entArr.length(); i++) + { + AddByInfo(rhs[i]); + } + + return this; + } + + /** + * @brief Add operator overload for adding arrays together. + */ + EntityArray opAdd( const EntityArray&in rhs ) const + { + EntityArray result(this); + return (result += rhs); + } + + + // ---------------- ARRAY FUNCTIONS ---------------- \\ + /** * @brief Clear all the entities from the EntityArray. */ @@ -163,28 +214,33 @@ class EntityArray } } + // ---------------- ADDING FUNCTIONS ---------------- \\ + /** * @brief Add a entity to the EntityArray by its entity name. * @param entName Entity name of the entity to add. * @param tags (optional) What tags should be added with the entity. * @param addAmt (optional) How many of the entities by entity name should be added. */ - void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE, const int addAmt = 1 ) + void AddByEntityName( const string&in entName, const EntityTags tags = EntityTag::NONE, uint addAmt = 1 ) { - CBaseEntity@ ent = null; - for (int i = 0; i < addAmt; ent = EntityList().FindByName(ent, entName)) + for (CBaseEntity@ ent = null; (@ent = EntityList().FindByName(ent, entName)) != null;) { - if (i == addAmt) - return; + if (@ent == null) + continue; + + if (ent.GetEntityName() != entName) + continue; entArr.insertLast(EntityInfo(ent, tags)); - DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\"."); + entArrayLog.Info("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\"."); if (tags > 0) - DevMsgl("Entity tag value is: \"" + tags + "\""); + entArrayLog.Info("Entity tag value is: \"" + tags + "\""); - i++; + if (--addAmt <= 0) + return; } } @@ -194,20 +250,24 @@ class EntityArray * @param tags (optional) What tags should be added with the entity. * @param addAmt (optional) How many of the entities by class name should be added. */ - void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE, const int addAmt = 1 ) + void AddByClassname( const string&in className, const EntityTags tags = EntityTag::NONE, uint addAmt = 1 ) { - CBaseEntity@ ent = null; - for (int i = 0; i < addAmt; ent = EntityList().FindByClassname(ent, className)) + for (CBaseEntity@ ent = null; (@ent = EntityList().FindByClassname(ent, className)) != null;) { - if (i == addAmt) - return; + if (@ent == null) + continue; + + if (ent.GetClassname() != className) + continue; entArr.insertLast(EntityInfo(ent, tags)); - DevMsgl("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\""); + entArrayLog.Info("Added entity \"" + ent.GetEntityName() + "\" with entindex \"" + ent.GetEntityIndex() + "\"."); + if (tags > 0) - DevMsgl("Entity tag value is: \"" + tags + "\""); + entArrayLog.Info("Entity tag value is: \"" + tags + "\""); - i++; + if (--addAmt <= 0) + return; } } @@ -216,18 +276,35 @@ class EntityArray * @param entHandle Handle of the entity to add. * @param tags (optional) What tags should be added with the entity. */ - void AddByHandle( const CBaseEntity@ entHandle, const EntityTags tags = EntityTag::NONE ) + void AddByHandle( CBaseEntity@ entHandle, const EntityTags tags = EntityTag::NONE ) { if (@entHandle == null) { - Warningl("[EntityHandle] Invalid handle passed to AddByHandle!"); + entArrayLog.Warn("Invalid handle passed to AddByHandle!"); return; } entArr.insertLast(EntityInfo(entHandle, tags)); - DevMsgl("Added entity \"" + entHandle.GetEntityName() + "\" with entindex \"" + entHandle.GetEntityIndex() + "\""); + entArrayLog.Info("Added entity \"" + entHandle.GetEntityName() + "\" with entindex \"" + entHandle.GetEntityIndex() + "\"."); + if (tags > 0) - DevMsgl("Entity tag value is: \"" + tags + "\""); + entArrayLog.Info("Entity tag value is: \"" + tags + "\""); + } + + /** + * @brief Add a EntityInfo to the EntityArray + * @param entInfo EntityInfo to add. + */ + void AddByInfo( const EntityInfo&in entInfo ) + { + entArr.insertLast(entInfo); + if (@entInfo.entHandle != null) + entArrayLog.Info("Added entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\"."); + else + entArrayLog.Warn("EntityInfo with a null entity handle has been added!"); + + if (entInfo.entInfoTags > 0) + entArrayLog.Info("Entity tag value is: \"" + entInfo.entInfoTags + "\""); } @@ -238,17 +315,17 @@ class EntityArray * @param entName Name of entity to remove from the array. * @param rmAmt (optional) How many of the entity by it's name should be removed. */ - void RemoveByEntityName( const string&in entName, int rmAmt = 1 ) + void RemoveByEntityName( const string&in entName, uint rmAmt = 1 ) { - for (int i = 0; i < entArr.length(); i++) + for (uint i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; - if ((entInfo.entHandle != null) && (entInfo.entHandle.GetEntityName() == entName)) + if ((@entInfo.entHandle != null) && (entInfo.entHandle.GetEntityName() == entName)) { + entArrayLog.Info("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\"."); entArr.removeAt(i); - DevMsgl("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\""); - rmAmt--; - if (rmAmt <= 0) + + if (--rmAmt <= 0) return; } } @@ -259,17 +336,17 @@ class EntityArray * @param className Class name of entity to remove from the array. * @param rmAmt (optional) How many of the entity by it's class name should be removed. */ - void RemoveByClassname( const string&in className, int rmAmt = 1 ) + void RemoveByClassname( const string&in className, uint rmAmt = 1 ) { - for (int i = 0; i < entArr.length(); i++) + for (uint i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; - if ((entInfo.entHandle != null) && (entInfo.entHandle.GetClassname() == className)) + if ((@entInfo.entHandle != null) && (entInfo.entHandle.GetClassname() == className)) { + entArrayLog.Info("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\"."); entArr.removeAt(i); - DevMsgl("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\""); - rmAmt--; - if (rmAmt <= 0) + + if (--rmAmt <= 0) return; } } @@ -281,12 +358,12 @@ class EntityArray */ void RemoveByHandle( const CBaseEntity@ entHandle ) { - for (int i = 0; i < entArr.length(); i++) + for (uint i = 0; i < entArr.length(); i++) { EntityInfo entInfo = entArr[i]; - if ((entInfo.entHandle != null) && (entInfo.entHandle == entHandle)) + if ((@entInfo.entHandle != null) && (entInfo.entHandle is entHandle)) { - DevMsgl("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\""); + entArrayLog.Info("Removed entity \"" + entInfo.entHandle.GetEntityName() + "\" with entindex \"" + entInfo.entHandle.GetEntityIndex() + "\"."); entArr.removeAt(i); return; } @@ -295,48 +372,114 @@ class EntityArray // ---------------- SORTING FUNCTIONS ---------------- \\ + // TODO: Repetitive code, should be consolidated and optimized a bit. /** - * @brief Compare tags of entities for sorting ascending. - * @param A Entity A. - * @param B Entity B. + * @brief Sort entities in the EntityArray by their tag value. + * @param ascending Whether to sort ascending or descending. */ - bool SortByTagsAsc( const EntityInfo@ A, const EntityInfo@ B ) + void SortEntitiesByTags( bool ascending = true ) { - if (A.tags < B.tags) - return true; - - return false; + if (ascending) + { + entArr.sort( + function(const EntityInfo&in A, const EntityInfo&in B) + { + return A.entInfoTags < B.entInfoTags; + } + ); + } + else + { + entArr.sort( + function(const EntityInfo&in A, const EntityInfo&in B) + { + return A.entInfoTags > B.entInfoTags; + } + ); + } } /** - * @brief Compare tags of entities for sorting descending. - * @param A Entity A. - * @param B Entity B. + * @brief Sort entities in the EntityArray by their entity name. + * @param ascending Whether to sort ascending or descending. */ - bool SortByTagsDesc( const EntityInfo@ A, const EntityInfo@ B ) - { - if (A.tags < B.tags) - return false; + // TODO: Figure out string comparison + // void SortEntitiesByName( bool ascending = true ) + // { + // if (ascending) + // { + // entArr.sort( + // function(const EntityInfo&in A, const EntityInfo&in B) + // { + // return A.entHandle.GetEntityName() < B.entHandle.GetEntityName(); + // } + // ); + // } + // else + // { + // entArr.sort( + // function(const EntityInfo&in A, const EntityInfo&in B) + // { + // return A.entHandle.GetEntityName() > B.entHandle.GetEntityName(); + // } + // ); + // } + // } - return true; - } + /** + * @brief Sort entities in the EntityArray by their entity classname. + * @param ascending Whether to sort ascending or descending. + */ + // TODO: Figure out string comparison + // void SortEntitiesByClassname( bool ascending = true ) + // { + // if (ascending) + // { + // entArr.sort( + // function(const EntityInfo&in A, const EntityInfo&in B) + // { + // return A.entHandle.GetClassname() < B.entHandle.GetClassname(); + // } + // ); + // } + // else + // { + // entArr.sort( + // function(const EntityInfo&in A, const EntityInfo&in B) + // { + // return A.entHandle.GetClassname() > B.entHandle.GetClassname(); + // } + // ); + // } + // } /** - * @brief Sort entities in the EntityArray by their tag value. + * @brief Sort entities in the EntityArray by their entity entity index. * @param ascending Whether to sort ascending or descending. */ - void SortEntitiesByTags( bool ascending = true ) + void SortEntitiesByIndex( bool ascending = true ) { - // TODO: Forgot this was a issue, normal sort function is incomplete by the dump so this is my assumption take on what "T[]::less" actually is. - // TODO: Guess we have to wait till the dump is fixed or think of something else. if (ascending) - entArr.sort(SortByTagsAsc); + { + entArr.sort( + function(const EntityInfo&in A, const EntityInfo&in B) + { + return A.entHandle.GetEntityIndex() < B.entHandle.GetEntityIndex(); + } + ); + } else - entArr.sort(SortByTagsDesc); + { + entArr.sort( + function(const EntityInfo&in A, const EntityInfo&in B) + { + return A.entHandle.GetEntityIndex() > B.entHandle.GetEntityIndex(); + } + ); + } } - // ---------------- FIND FUNCTIONS ---------------- \\ /** @@ -401,7 +544,7 @@ class EntityArray array results; for (uint i = 0; i < entArr.length(); i++) { - //! The LSP will say this is invalid when actually it is, + //! The LSP will say this is invalid when actually it is valid, //! there is no need for a defined operator overload for the bitwise AND. if ((entArr[i].entInfoTags & tag) != 0) { From 2299cb704d6363c361491ce6742d5fc805018a3a Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Fri, 27 Feb 2026 21:12:39 -0800 Subject: [PATCH 18/19] lsp: Updated LSP with latest QA dump. --- as.predefined | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/as.predefined b/as.predefined index 583c379..60ef940 100644 --- a/as.predefined +++ b/as.predefined @@ -1678,6 +1678,21 @@ class StorageScope{ void SetVector(const string&in key, const Vector&in value); void SetString(const string&in key, const string&in value); } +class EHandle{ + ~EHandle(); + EHandle(int&in); + EHandle(int&in, const T@ entity); + void opAssign(const EHandle&in other); + void opHndlAssign(const EHandle&in other); + void opHndlAssign(const T@ entity); + void Set(const T@ entity); + T@ Get() const; + T@ opImplCast() const; + bool opEquals(const EHandle&in other) const; + bool opEquals(const T@ entity) const; + bool ChangedFrom(const T@ entity) const; + bool IsValid() const; +} class trace_t{ ~trace_t(); trace_t(); @@ -1873,6 +1888,10 @@ class CBaseEntity{ string GetDebugName(); int GetEntityIndex() const; bool GetKeyValue(const string&in key, string&out value) const; + bool KeyValue(const string&in key, const string&in value); + bool KeyValue(const string&in key, float value); + bool KeyValue(const string&in key, int value); + bool KeyValue(const string&in key, const Vector&in value); string GetModelName() const; float GetElasticity() const; void SetElasticity(float elasticity); @@ -1895,6 +1914,14 @@ class CBaseEntity{ bool TestCollision(const Ray_t&in ray, uint mask, trace_t&out trace); bool TestHitboxes(const Ray_t&in ray, uint mask, trace_t&out trace); void ComputeWorldSpaceSurroundingBox(Vector&out mins, Vector&out maxs); + int GetSpawnFlags() const; + void AddSpawnFlags(int flags); + void RemoveSpawnFlags(int flags); + void ClearSpawnFlags(); + bool HasSpawnFlags(int flags) const; + bool IsTrigger() const; + bool IsPlayer() const; + bool IsBaseCombatWeapon() const; } class InputData{ ~InputData(); @@ -1911,35 +1938,53 @@ class CBaseEntityOutput{ class COutputVariant : CBaseEntityOutput{ COutputVariant(); void Fire(const Variant&in value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(const Variant&in value); + Variant Get() const; } class COutputInt : CBaseEntityOutput{ COutputInt(); void Fire(int value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(int value); + int Get() const; } class COutputFloat : CBaseEntityOutput{ COutputFloat(); void Fire(float value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(float value); + float Get() const; } class COutputString : CBaseEntityOutput{ COutputString(); void Fire(const string&in value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(const string&in value); + string Get() const; } class COutputEntity : CBaseEntityOutput{ COutputEntity(); void Fire(CBaseEntity@ value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(CBaseEntity@ value); + CBaseEntity@ Get() const; } class COutputVector : CBaseEntityOutput{ COutputVector(); void Fire(const Vector&in value, CBaseEntity@ activator, CBaseEntity@ caller); void Fire(const QAngle&in value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(const QAngle&in value); + void Init(const Vector&in value); + void Get(QAngle&out value) const; + void Get(Vector&out value) const; } class COutputPosVector : CBaseEntityOutput{ COutputPosVector(); void Fire(const Vector&in value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(const Vector&in value); + void Get(Vector&out value) const; } class COutputColor : CBaseEntityOutput{ COutputColor(); void Fire(Color value, CBaseEntity@ activator, CBaseEntity@ caller); + void Init(Color value); + Color Get() const; } class COutputEvent : CBaseEntityOutput{ COutputEvent(); @@ -2405,6 +2450,8 @@ void VectorAngles(const Vector&in forward, QAngle&out angles); void VectorAngles(const Vector&in forward, const Vector&in pseudoup, QAngle&out angles); void VectorMatrix(const Vector&in forward, matrix3x4_t&out mat); void VectorVectors(const Vector&in forward, Vector&out right, Vector&out up); +void AngleVectors(const QAngle&in angle, Vector&out forward, Vector&out right, Vector&out up); +void AngleVectors(const QAngle&in angle, Vector&out forward); void SetIdentityMatrix(matrix3x4_t&out mat); void SetScaleMatrix(float x, float y, float z, matrix3x4_t&out dst); void MatrixBuildRotationAboutAxis(const Vector&in vAxisOfRot, float angleDegrees, matrix3x4_t&out dst); From 9adb898589c36ce409d3870229973b0576d0c395 Mon Sep 17 00:00:00 2001 From: Orsell <34631691+OrsellGit@users.noreply.github.com> Date: Sun, 1 Mar 2026 15:08:30 -0800 Subject: [PATCH 19/19] fix: debugbreak() was removed --- misc/assert.as | 1 - 1 file changed, 1 deletion(-) diff --git a/misc/assert.as b/misc/assert.as index 7f7abb1..581fa7f 100644 --- a/misc/assert.as +++ b/misc/assert.as @@ -16,7 +16,6 @@ void assert( const bool testStatement, const string&in errMsg = "Passed statemen { if (!testStatement) { - debugbreak(); throw("Assertion hit! Error: " + errMsg); } }