void character::character::animateStepOccured() {
Vec p = pos();
p.y = Game::World.hmHeight(p.xz());
Int type = MUT_DEFAULT;
if(Game::World.waterUnder(p)) {
// this means we're just below water level, but still walking
type = MUT_WATER;
} else {
p = ctrl.actor.pos();
p.y -= ctrl.radius() + 0.05;
if(p.y < Game::World.hmHeight(p.xz(), true)) {
// get material from the terrain we're walking on
type = Game::World.hmMaterial(p.xz())->user_type;
} else {
// char is somewhere above terrain, but walking
// so check for object right below character
Int type = MUT_VOID;
Game::Area * area = Game::World.areaActive(Game::World.worldToArea(pos().xz()));
if (area != NULL) {
REPA(area->data()->embed_objs) {
if(Cuts(p, area->data()->embed_objs[i].actor.shape(false))) {
const MeshPtr m = area->data()->embed_objs[i].mesh();
REPAD(j, m->parts) {
if (Equal(m->parts[j].name, "material")) {
type = m->parts[j].material()->user_type;
break;
}
}
break;
}
}
}
}
switch(type) {
case MUT_WATER: {
_stepsWater[Random(7)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
case MUT_STONE:
case MUT_ROAD: {
_stepsStone[Random(5)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
case MUT_PLANT: {
_stepsGrass[Random(5)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
case MUT_METAL: {
_stepsMetal[Random(4)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
case MUT_WOOD: {
_stepsWood[Random(4)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
case MUT_SNOW:
case MUT_ICE: {
_stepsSnow[Random(5)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
case MUT_VOID: break;
default: {
_stepsWoodland[Random(8)].play().pos(YSEVec(T.pos())).speed(RandomF(0.95, 1.05));
break;
}
}
}
}