summary refs log tree commit diff stats
path: root/src/character_system.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/character_system.cpp')
-rw-r--r--src/character_system.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/character_system.cpp b/src/character_system.cpp index d0c416e..7d456f6 100644 --- a/src/character_system.cpp +++ b/src/character_system.cpp
@@ -39,6 +39,32 @@ void CharacterSystem::addSpriteToParty(int leaderId, int followerId) {
39 game_.getSystem<AnimationSystem>().setSpriteAnimation(followerId, "still"); 39 game_.getSystem<AnimationSystem>().setSpriteAnimation(followerId, "still");
40} 40}
41 41
42void CharacterSystem::transplantParty(int leaderId, vec2i pos, Direction dir) {
43 Sprite& leader = game_.getSprite(leaderId);
44 CharacterState oldState = leader.characterState;
45
46 std::vector<int> followers = leader.followers;
47 leader.followers.clear();
48
49 game_.getSystem<TransformSystem>().moveSprite(leaderId, pos);
50 game_.getSystem<AnimationSystem>().setSpriteDirection(leaderId, dir);
51
52 for (int followerId : followers) {
53 Sprite& follower = game_.getSprite(followerId);
54 follower.trail.clear();
55
56 game_.getSystem<TransformSystem>().moveSprite(followerId, pos);
57 game_.getSystem<AnimationSystem>().setSpriteDirection(followerId, dir);
58 addSpriteToParty(leaderId, followerId);
59 }
60
61 if (oldState == CharacterState::Running) {
62 startRunning(leaderId);
63 } else {
64 setPartyState(leaderId, oldState);
65 }
66}
67
42void CharacterSystem::moveInDirection(int spriteId, Direction dir) { 68void CharacterSystem::moveInDirection(int spriteId, Direction dir) {
43 Sprite& sprite = game_.getSprite(spriteId); 69 Sprite& sprite = game_.getSprite(spriteId);
44 70
@@ -266,11 +292,3 @@ void CharacterSystem::destroySprite(int spriteId) {
266 stopRunningSound(sprite); 292 stopRunningSound(sprite);
267 } 293 }
268} 294}
269
270void CharacterSystem::clearSpriteCache() {
271 for (Sprite& sprite : game_.getSprites() | game_.spriteView()) {
272 if (sprite.runningSfxChannel != -1) {
273 stopRunningSound(sprite);
274 }
275 }
276}