Debian Codegraph @

Sources/Jazz2/Actors/Environment/SteamNote.cpp

raw
1 #include "SteamNote.h"
2 #include "../../ILevelHandler.h"
3
4 namespace Jazz2::Actors::Environment
5 {
6 SteamNote::SteamNote()
7 : _cooldown(0.0f)
8 {
9 }
10
11 void SteamNote::Preload(const ActorActivationDetails& details)
12 {
13 PreloadMetadataAsync("Object/SteamNote"_s);
14 }
15
16 Task<bool> SteamNote::OnActivatedAsync(const ActorActivationDetails& details)
17 {
18
19 _pos.X -= 10.0f;
20
21 SetState(ActorState::SkipPerPixelCollisions, true);
22 SetState(ActorState::CanBeFrozen | ActorState::CollideWithOtherActors | ActorState::ApplyGravitation, false);
23
24 async_await RequestMetadataAsync("Object/SteamNote"_s);
25
26 SetAnimation(AnimState::Default);
27
28 PlaySfx("Appear"_s, 0.4f);
29
30 // It's incorrectly positioned one tile up in "share2.j2l", so move it to correct position
31 OnUpdateHitbox();
32 bool moved = false;
33 std::int32_t i = 10;
34 while (i-- > 0 && MoveInstantly(Vector2f(0.0f, 4.0f), MoveType::Relative)) {
35 moved = true;
36 }
37 while (i-- > 0 && MoveInstantly(Vector2f(0.0f, 1.0f), MoveType::Relative)) {
38 moved = true;
39 }
40 if (moved) {
41 MoveInstantly(Vector2f(0.0f, 18.0f), MoveType::Relative | MoveType::Force);
42 }
43
44 async_return true;
45 }
46
47 void SteamNote::OnUpdate(float timeMult)
48 {
49 if (_cooldown > 0.0f) {
50 _cooldown -= timeMult;
51 if (_cooldown <= 0.0f) {
52 _renderer.AnimTime = 0.0f;
53 _renderer.AnimPaused = false;
54 _renderer.setDrawEnabled(true);
55
56 PlaySfx("Appear"_s, 0.4f);
57 }
58 }
59 }
60
61 void SteamNote::OnUpdateHitbox()
62 {
63 UpdateHitbox(6, 6);
64 }
65
66 void SteamNote::OnAnimationFinished()
67 {
68 _renderer.AnimPaused = true;
69 _renderer.setDrawEnabled(false);
70 _cooldown = 80.0f;
71 }
72 }