-
-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dmSDK: Added possibility to load collection proxies and spawn factories from C++ #8667
Changes from 9 commits
43e4a80
dd9e090
3eb3414
54e2f66
f05029e
0d140f7
fa7b18a
76011b3
0729305
db49980
4d57015
3cc872d
d985ec0
22711ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
// Copyright 2009-2014 Ragnar Svensson, Christian Murray | ||
// Licensed under the Defold License version 1.0 (the "License"); you may not use | ||
// this file except in compliance with the License. | ||
// | ||
// | ||
// You may obtain a copy of the License, together with FAQs at | ||
// https://www.defold.com/license | ||
// | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
|
@@ -217,9 +217,9 @@ namespace dmGameObject | |
struct ComponentGetParams | ||
{ | ||
/// Component world | ||
void* m_World; | ||
dmGameObject::HComponentWorld m_World; | ||
/// User data storage pointer | ||
uintptr_t* m_UserData; | ||
dmGameObject::HComponentInternal m_UserData; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding more type safety. |
||
}; | ||
|
||
/*# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
// Copyright 2009-2014 Ragnar Svensson, Christian Murray | ||
// Licensed under the Defold License version 1.0 (the "License"); you may not use | ||
// this file except in compliance with the License. | ||
// | ||
// | ||
// You may obtain a copy of the License, together with FAQs at | ||
// https://www.defold.com/license | ||
// | ||
// | ||
// Unless required by applicable law or agreed to in writing, software distributed | ||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
|
@@ -86,6 +86,34 @@ namespace dmGameObject | |
*/ | ||
typedef struct CollectionHandle* HCollection; | ||
|
||
/*# | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved from internal header. |
||
* Handle to a list of properties (gameobject_props.h) | ||
* @typedef | ||
* @name HPropertyContainer | ||
*/ | ||
typedef struct PropertyContainer* HPropertyContainer; | ||
|
||
/*# | ||
* Opaque handle to component instance | ||
* @typedef | ||
* @name HComponent | ||
*/ | ||
typedef void* HComponent; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A HComponent, is intended to be a fully resolved pointer, to be used with our c++ sdk's. |
||
|
||
/*# | ||
* Opaque handle to internal representation of a component instance | ||
* @typedef | ||
* @name HComponentInternal | ||
*/ | ||
typedef uintptr_t HComponentInternal; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A HComponentInternal, may be anything that the component type needs (e.g. a uin16_t handle). It needs to be resolved (handled by our component extensions) to get an actual pointer. |
||
|
||
/*# | ||
* Opaque handle to a component world | ||
* @typedef | ||
* @name HComponentWorld | ||
*/ | ||
typedef void* HComponentWorld; | ||
|
||
typedef void* HCollectionDesc; | ||
|
||
/*# | ||
|
@@ -473,6 +501,22 @@ namespace dmGameObject | |
*/ | ||
dmMessage::HSocket GetMessageSocket(HCollection collection); | ||
|
||
/*# spawn a new game object | ||
* Spawns a new gameobject instance. The actual creation is performed after the update is completed. | ||
* @name Spawn | ||
* @param collection [type: HCollection] Gameobject collection | ||
* @param prototype [type: HPrototype] Prototype | ||
* @param prototype_name [type: const char*] Prototype file name (.goc) | ||
* @param id [type: dmhash_t] Id of the spawned instance | ||
* @param properties [type: HPropertyContainer] Container with override properties | ||
* @param position [type: dmVMath::Vector3] Position of the spawed object | ||
* @param rotation [type: dmVMath::Quat] Rotation of the spawned object | ||
* @param scale [type: dmVMath::Vector3] Scale of the spawned object | ||
* return instance [type: HInstance] the spawned instance, 0 at failure | ||
*/ | ||
HInstance Spawn(HCollection collection, HPrototype prototype, const char* prototype_name, dmhash_t id, | ||
HPropertyContainer properties, const dmVMath::Point3& position, const dmVMath::Quat& rotation, const dmVMath::Vector3& scale); | ||
|
||
/*# | ||
* Retrieve a collection from the specified instance | ||
* @name GetCollection | ||
|
@@ -560,6 +604,9 @@ namespace dmGameObject | |
*/ | ||
Result GetComponentId(HInstance instance, uint16_t component_index, dmhash_t* component_id); | ||
|
||
// Get the component, component type and its world | ||
Result GetComponent(HInstance instance, dmhash_t component_id, uint32_t* component_type, HComponent* component, HComponentWorld* out_world); | ||
|
||
/*# set position | ||
* Set gameobject instance position | ||
* @name SetPosition | ||
|
@@ -728,6 +775,31 @@ namespace dmGameObject | |
*/ | ||
HInstance GetParent(HInstance instance); | ||
|
||
/*# | ||
* Get the component type index | ||
* @name GetComponentTypeIndex | ||
* @param collection Collection handle | ||
* @param type_hash [type:dhmash_t] The hashed name of the registered component type (e.g. dmHashString("guic")) | ||
* @return type_index [type:uint32_t] The component type index. 0xFFFFFFFF if not found | ||
*/ | ||
uint32_t GetComponentTypeIndex(HCollection collection, dmhash_t type_hash); | ||
|
||
/*# | ||
* Retrieve the world in the collection connected to the supplied component | ||
* @param collection Collection handle | ||
* @param component_type_index index of the component type | ||
* @return world [type:void*] The pointer to the world, 0x0 if not found | ||
*/ | ||
HComponentWorld GetWorld(HCollection collection, uint32_t component_type_index); | ||
|
||
/*# | ||
* Retrieve the context for a component type | ||
* @param collection Collection handle | ||
* @param component_type_index index of the component type | ||
* @return context [type:void*] The pointer to the context, 0x0 if not found | ||
*/ | ||
void* GetContext(HCollection collection, uint32_t component_type_index); | ||
|
||
|
||
// These functions are used for profiling functionality | ||
|
||
|
@@ -976,4 +1048,3 @@ namespace dmGameObject | |
} | ||
|
||
#endif // DMSDK_GAMEOBJECT_H | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New feature:
Since the extension system isn't aware of the game loop as such, I introduced two new events
EVENT_ID_ENGINE_DELETE
andEVENT_ID_ENGINE_INITIALIZED
so that the extension can act upon it.I.e. this helps with things like: don't load things before the game has been initialized, and don't delete your things too late.