A reimplementation of Mario Kart Wii's physics engine in C++
Loading...
Searching...
No Matches
ObjectPylon.hh
1#pragma once
2
3#include "game/field/obj/ObjectCollidable.hh"
4
5namespace Field {
6
8class ObjectPylon final : public ObjectCollidable {
9public:
11 ~ObjectPylon() override;
12
13 void init() override;
14 void calc() override;
15
17 [[nodiscard]] u32 loadFlags() const override {
18 return 1;
19 }
20
21 Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart,
22 Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override;
23
24private:
25 enum State {
26 Idle = 0,
27 Moving = 1,
28 Hide = 2,
29 ComeBack = 3,
30 Hiding = 4,
31 Hit = 5,
32 };
33
34 void checkCollision(const EGG::Vector3f &hitDepth);
35
36 void startHit(f32 velFactor, EGG::Vector3f &hitDepth);
37
38 void calcHit();
39 void calcHiding();
40 void calcHide();
41 void calcComeBack();
42
43 State m_state;
44 std::array<ObjectPylon *, 2> m_neighbors;
45 const EGG::Vector3f m_initPos;
46 const EGG::Vector3f m_initScale;
47 const EGG::Vector3f m_initRot;
52
53 static constexpr f32 RADIUS = 120.0f;
54 static constexpr f32 FALL_VEL = 20.0f;
55
57 static constexpr u32 STATE_COOLDOWN_FRAMES = 5;
58};
59
60} // namespace Field
The traffic cones on Daisy Circuit.
Definition ObjectPylon.hh:8
EGG::Vector3f m_angVel
Added to rotation while in Hit state.
u32 m_stateStartFrame
Frame when pylon entered the current m_state.
void checkCollision(const EGG::Vector3f &hitDepth)
EGG::Vector3f m_vel
Velocity used in Hit and ComeBack states.
static constexpr u32 STATE_COOLDOWN_FRAMES
Minimum frames before a state change can occur.
Kart::Reaction onCollision(Kart::KartObject *kartObj, Kart::Reaction reactionOnKart, Kart::Reaction reactionOnObj, EGG::Vector3f &hitDepth) override
u32 m_numBounces
Number of floor collisions while in Hit state.
The highest level abstraction for a kart.
Definition KartObject.hh:11
Pertains to collision.
A 3D float vector.
Definition Vector.hh:88