/* * KartPhysicsComponent.cpp * * Created on: Aug 19, 2020 * Author: fredrick */ #include "KartPhysicsComponent.h" namespace JamSpook { KartPhysicsComponent::KartPhysicsComponent(mat4 transform, shared_ptr > > entity, weak_ptr > physicsSystem, weak_ptr > > physicsCollisionSubSystem, weak_ptr > > physicsColliderQuerySubSystem, shared_ptr collider): PhysicsComponent(transform, entity, physicsSystem, physicsCollisionSubSystem, physicsColliderQuerySubSystem, collider) {} KartPhysicsComponent::~KartPhysicsComponent() {} void KartPhysicsComponent::update(const milliseconds dtms) { // Log::write(LogLevel::trace, "CollectablePhysicsComponent - update"); PhysicsComponent::update(dtms); if (getPosition().y < -100.0f) { setPosition(vec3(getFloatInRange(-10.0f, 10.0f), 10, /// above the ball getFloatInRange(-10.0f, 10.0f))); } } void KartPhysicsComponent::onICCMessage(shared_ptr message) { PhysicsComponent::onICCMessage(message); } void KartPhysicsComponent::onCollision(const string& tag) { if (tag == "ground-plane") { vec3 position = getPosition(); setPosition(vec3(position.x, 10.0f, position.z)); ICCBroadcast(make_shared(IDCache::get("GroundContactMessage"))); } } } // namespace JamSpook