Add prefab support
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "entityprefabplayer.h"
|
||||
#include "entity/entitymanager.h"
|
||||
#include "entity/component/display/entityposition.h"
|
||||
#include "entity/component/display/entityrenderable.h"
|
||||
#include "entity/component/physics/entityphysics.h"
|
||||
#include "display/color.h"
|
||||
|
||||
errorret_t entityPrefabPlayerApply(
|
||||
entitymanager_t *mgr,
|
||||
const entityid_t entityId
|
||||
) {
|
||||
componentid_t posComp = entityAddComponent(
|
||||
mgr, entityId, COMPONENT_TYPE_POSITION
|
||||
);
|
||||
vec3 startPos = { 0.0f, 5.0f, 0.0f };
|
||||
entityPositionSetLocalPosition(mgr, entityId, posComp, startPos);
|
||||
|
||||
componentid_t renderComp = entityAddComponent(
|
||||
mgr, entityId, COMPONENT_TYPE_RENDERABLE
|
||||
);
|
||||
entityRenderableSetColor(
|
||||
mgr, entityId, renderComp, color4b(255, 80, 80, 255)
|
||||
);
|
||||
|
||||
entityAddComponent(mgr, entityId, COMPONENT_TYPE_PLAYER);
|
||||
|
||||
componentid_t physComp = entityAddComponent(
|
||||
mgr, entityId, COMPONENT_TYPE_PHYSICS
|
||||
);
|
||||
entityPhysicsSetBodyType(mgr, entityId, physComp, PHYSICS_BODY_DYNAMIC);
|
||||
entityPhysicsSetCollideMask(mgr, entityId, physComp, 0x3);
|
||||
|
||||
errorOk();
|
||||
}
|
||||
Reference in New Issue
Block a user