Created ItemManager to play drop and flippy sounds for dropped item entities

This commit is contained in:
Collin Smith
2019-12-19 02:25:01 -08:00
parent 7c18932b65
commit b537195d7c
3 changed files with 36 additions and 1 deletions

View File

@ -173,7 +173,6 @@ public class ClientEntityFactory extends ServerEntityFactory {
int id = super.createItem(item, position);
Item itemWrapper = mItem.get(id);
Riiablo.assets.load(itemWrapper.flippyDescriptor);
// Riiablo.audio.play("item_flippy", true);
/**
* FIXME: at least some items appear to be about a half subtile too high after their drop
* animations finish -- is this expected? or some issue with offsets? It's happening with

View File

@ -0,0 +1,33 @@
package com.riiablo.engine.client;
import com.artemis.BaseEntitySystem;
import com.artemis.ComponentMapper;
import com.artemis.annotations.All;
import com.riiablo.Riiablo;
import com.riiablo.codec.Animation;
import com.riiablo.engine.client.component.AnimationWrapper;
import com.riiablo.engine.server.component.Item;
@All({Item.class, AnimationWrapper.class})
public class ItemManager extends BaseEntitySystem {
protected ComponentMapper<Item> mItem;
protected ComponentMapper<AnimationWrapper> mAnimationWrapper;
@Override
protected void inserted(int entityId) {
com.riiablo.item.Item item = mItem.get(entityId).item;
final String sound = item.getDropSound();
mAnimationWrapper.get(entityId).animation.addAnimationListener(item.getDropFxFrame(), new Animation.AnimationListener() {
@Override
public void onTrigger(Animation animation, int frame) {
Riiablo.audio.play(sound, true);
animation.removeAnimationListener(frame, this);
}
});
Riiablo.audio.play("item_flippy", true);
}
@Override
protected void processSystem() {}
}

View File

@ -59,6 +59,7 @@ import com.riiablo.engine.client.DialogManager;
import com.riiablo.engine.client.DirectionResolver;
import com.riiablo.engine.client.HoveredManager;
import com.riiablo.engine.client.ItemLoader;
import com.riiablo.engine.client.ItemManager;
import com.riiablo.engine.client.LabelManager;
import com.riiablo.engine.client.MenuManager;
import com.riiablo.engine.client.MissileLoader;
@ -568,6 +569,8 @@ public class GameScreen extends ScreenAdapter implements GameLoadingScreen.Loada
.with(new LabelManager())
.with(new MonsterLabelManager())
.with(new ItemManager())
.with(new PathDebugger())
.with(new Box2DDebugger())
.with(new PathfindDebugger())