DarkflameServer/dScripts
David Markowitz ae349d6b15
feat: Add isolated and simplified path to add components (#1204)
* Components: Make ComponentType inline

Prevents the next commits ODR violation

* Components: Add new components

* Entity: Add headers

inline script component ComponentType

* Components: Flip constructor argument order

Entity comes first always

* Entity: Add generic AddComponent

Allows for much easier adding of components and is error proof by not allowing the user to add more than 1 of a specific component type to an Entity.

* Entity: Migrate all component constructors

Move all to the new variadic templates AddComponent function to reduce clutter and ways the component map is modified.
The new function makes no assumptions.  Component is assumed to not exist and is checked for with operator[].  This will construct a null component which will then be newed if the component didnt exist, or it will just get the current component if it does already exist.  No new component will be allocated or constructed if the component already exists and the already existing pointer is returned instead.

* Entity: Add placement new

For the case where the component may already exist, use a placement new to construct the component again, it would be constructed again, but would not need to go through the allocator.

* Entity: Add comments on likely new code

* Tests: Fix tests

* Update Entity.cpp

* Update SGCannon.cpp

* Entity: call destructor when re-constructing

* Update Entity.cpp

Update Entity.cpp

---------

Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
2023-10-22 20:08:49 -05:00
..
02_server Scripts: Fix possible nullptr access (#1232) 2023-10-22 14:53:54 -07:00
ai feat: Add isolated and simplified path to add components (#1204) 2023-10-22 20:08:49 -05:00
client Breakout rest of the enums from dCommonVars and clean it up (#1061) 2023-05-02 17:39:21 -05:00
EquipmentScripts Move EntityManager to Game namespace (#1140) 2023-07-15 13:56:33 -07:00
EquipmentTriggers Make wrapper for casting skills (#987) 2023-02-10 02:30:17 -06:00
zone Fix typing of some player flag variables (#1067) 2023-05-06 13:32:26 -05:00
ActivityManager.cpp feat: Abstract Logger and simplify code (#1207) 2023-10-21 16:31:55 -07:00
ActivityManager.h Scripts: Fix ambiguous base class (#1216) 2023-10-09 15:31:25 -05:00
BaseConsoleTeleportServer.cpp Move EntityManager to Game namespace (#1140) 2023-07-15 13:56:33 -07:00
BaseConsoleTeleportServer.h format codebase 2022-07-28 08:39:57 -05:00
BasePropertyServer.cpp Move dZoneManager to game namespace (#1143) 2023-07-17 17:55:33 -05:00
BasePropertyServer.h Scripts: Fix ambiguous base class (#1216) 2023-10-09 15:31:25 -05:00
BaseRandomServer.cpp feat: Abstract Logger and simplify code (#1207) 2023-10-21 16:31:55 -07:00
BaseRandomServer.h format codebase 2022-07-28 08:39:57 -05:00
BaseSurvivalServer.cpp fix: Remove usage of rand() and seed randomness for chatserver (#1152) 2023-08-03 21:38:19 -05:00
BaseSurvivalServer.h format codebase 2022-07-28 08:39:57 -05:00
BaseWavesGenericEnemy.cpp Move dZoneManager to game namespace (#1143) 2023-07-17 17:55:33 -05:00
BaseWavesGenericEnemy.h Scripts: Fix ambiguous base class (#1216) 2023-10-09 15:31:25 -05:00
BaseWavesServer.cpp Merge branch 'main' into pr/1107 2023-07-21 19:40:30 -07:00
BaseWavesServer.h format codebase 2022-07-28 08:39:57 -05:00
ChooseYourDestinationNsToNt.cpp Breakout rest of the enums from dCommonVars and clean it up (#1061) 2023-05-02 17:39:21 -05:00
ChooseYourDestinationNsToNt.h format codebase 2022-07-28 08:39:57 -05:00
CMakeLists.txt Implement the Imaginite Backpack and Shard armor scripts (#886) 2022-12-21 14:33:41 -08:00
CppScripts.cpp feat: Abstract Logger and simplify code (#1207) 2023-10-21 16:31:55 -07:00
CppScripts.h Scripts: Fix ambiguous base class (#1216) 2023-10-09 15:31:25 -05:00
Darkitect.cpp Move EntityManager to Game namespace (#1140) 2023-07-15 13:56:33 -07:00
Darkitect.h Optimize scripts for faster compilation (#597) 2022-07-04 23:00:10 -07:00
NPCAddRemoveItem.cpp Breakout rest of the enums from dCommonVars and clean it up (#1061) 2023-05-02 17:39:21 -05:00
NPCAddRemoveItem.h Scripts: Fix ambiguous base class (#1216) 2023-10-09 15:31:25 -05:00
NtFactionSpyServer.cpp feat: Add isolated and simplified path to add components (#1204) 2023-10-22 20:08:49 -05:00
NtFactionSpyServer.h Breakout rest of the enums from dCommonVars and clean it up (#1061) 2023-05-02 17:39:21 -05:00
ScriptComponent.cpp chore: Make serialize actually virtual (#1156) 2023-08-10 14:33:15 -07:00
ScriptComponent.h feat: Add isolated and simplified path to add components (#1204) 2023-10-22 20:08:49 -05:00
ScriptedPowerupSpawner.cpp perf: Loot memory savings (#1165) 2023-10-09 15:33:22 -05:00
ScriptedPowerupSpawner.h format codebase 2022-07-28 08:39:57 -05:00
SpawnPetBaseServer.cpp Move EntityManager to Game namespace (#1140) 2023-07-15 13:56:33 -07:00
SpawnPetBaseServer.h format codebase 2022-07-28 08:39:57 -05:00