mirror of
https://github.com/Retera/WarsmashModEngine.git
synced 2022-07-31 17:38:59 +02:00
Add build sounds and rough draft of build progress bar
This commit is contained in:
parent
4fbb7adeaf
commit
632576323c
@ -446,4 +446,8 @@ public final class GameUI extends AbstractUIFrame implements UIFrame {
|
|||||||
super.add(childFrame);
|
super.add(childFrame);
|
||||||
this.nameToFrame.put(childFrame.getName(), childFrame);
|
this.nameToFrame.put(childFrame.getName(), childFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Scene getUiScene() {
|
||||||
|
return uiScene;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,11 @@ public class SplatModel {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(float x, float y, float z, float scale, float[] centerOffset) {
|
||||||
|
locations.add(new float[]{x - scale, y - scale, x + scale, y + scale, z});
|
||||||
|
compact(Gdx.gl30, centerOffset);
|
||||||
|
}
|
||||||
|
|
||||||
private static final class Batch {
|
private static final class Batch {
|
||||||
private final int uvsOffset;
|
private final int uvsOffset;
|
||||||
private final int vertexBuffer;
|
private final int vertexBuffer;
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -12,13 +12,10 @@ import com.etheller.warsmash.util.RenderMathUtils;
|
|||||||
import com.etheller.warsmash.util.War3ID;
|
import com.etheller.warsmash.util.War3ID;
|
||||||
import com.etheller.warsmash.viewer5.handlers.mdx.MdxComplexInstance;
|
import com.etheller.warsmash.viewer5.handlers.mdx.MdxComplexInstance;
|
||||||
import com.etheller.warsmash.viewer5.handlers.mdx.MdxModel;
|
import com.etheller.warsmash.viewer5.handlers.mdx.MdxModel;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens;
|
import com.etheller.warsmash.viewer5.handlers.w3x.*;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag;
|
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.PrimaryTag;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag;
|
import com.etheller.warsmash.viewer5.handlers.w3x.AnimationTokens.SecondaryTag;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.SequenceUtils;
|
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.SplatModel.SplatMover;
|
import com.etheller.warsmash.viewer5.handlers.w3x.SplatModel.SplatMover;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.UnitSoundset;
|
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.War3MapViewer;
|
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid;
|
import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType;
|
import com.etheller.warsmash.viewer5.handlers.w3x.environment.PathingGrid.MovementType;
|
||||||
import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.AbilityDataUI;
|
import com.etheller.warsmash.viewer5.handlers.w3x.rendersim.ability.AbilityDataUI;
|
||||||
@ -39,6 +36,7 @@ public class RenderUnit {
|
|||||||
private static final War3ID ORIENTATION_INTERPOLATION = War3ID.fromString("uori");
|
private static final War3ID ORIENTATION_INTERPOLATION = War3ID.fromString("uori");
|
||||||
private static final War3ID ANIM_PROPS = War3ID.fromString("uani");
|
private static final War3ID ANIM_PROPS = War3ID.fromString("uani");
|
||||||
private static final War3ID BLEND_TIME = War3ID.fromString("uble");
|
private static final War3ID BLEND_TIME = War3ID.fromString("uble");
|
||||||
|
private static final War3ID BUILD_SOUND_LABEL = War3ID.fromString("ubsl");
|
||||||
private static final float[] heapZ = new float[3];
|
private static final float[] heapZ = new float[3];
|
||||||
public final MdxComplexInstance instance;
|
public final MdxComplexInstance instance;
|
||||||
public final MutableGameObject row;
|
public final MutableGameObject row;
|
||||||
@ -66,6 +64,7 @@ public class RenderUnit {
|
|||||||
private boolean corpse;
|
private boolean corpse;
|
||||||
private boolean boneCorpse;
|
private boolean boneCorpse;
|
||||||
private final RenderUnitTypeData typeData;
|
private final RenderUnitTypeData typeData;
|
||||||
|
public UnitSound buildSound;
|
||||||
|
|
||||||
public RenderUnit(final War3MapViewer map, final MdxModel model, final MutableGameObject row, final float x,
|
public RenderUnit(final War3MapViewer map, final MdxModel model, final MutableGameObject row, final float x,
|
||||||
final float y, final float z, final int playerIndex, final UnitSoundset soundset,
|
final float y, final float z, final int playerIndex, final UnitSoundset soundset,
|
||||||
@ -128,6 +127,7 @@ public class RenderUnit {
|
|||||||
|
|
||||||
final float blendTime = row.getFieldAsFloat(BLEND_TIME, 0);
|
final float blendTime = row.getFieldAsFloat(BLEND_TIME, 0);
|
||||||
instance.setBlendTime(blendTime * 1000.0f);
|
instance.setBlendTime(blendTime * 1000.0f);
|
||||||
|
buildSound = map.getUiSounds().getSound(row.getFieldAsString(BUILD_SOUND_LABEL, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
@ -350,6 +350,9 @@ public class RenderUnit {
|
|||||||
this.selectionCircle.move(dx, dy, map.terrain.centerOffset);
|
this.selectionCircle.move(dx, dy, map.terrain.centerOffset);
|
||||||
}
|
}
|
||||||
this.unitAnimationListenerImpl.update();
|
this.unitAnimationListenerImpl.update();
|
||||||
|
if(!dead && simulationUnit.isConstructing()) {
|
||||||
|
instance.setFrameByRatio(simulationUnit.getConstructionProgress() / simulationUnit.getUnitType().getBuildTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getGroundHeightSample(final float groundHeight, final MdxComplexInstance currentWalkableUnder,
|
private float getGroundHeightSample(final float groundHeight, final MdxComplexInstance currentWalkableUnder,
|
||||||
|
@ -223,6 +223,10 @@ public class CSimulation {
|
|||||||
this.simulationRenderController.spawnUnitDamageSound(damagedUnit, weaponSound, armorType);
|
this.simulationRenderController.spawnUnitDamageSound(damagedUnit, weaponSound, armorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unitConstructedEvent(CUnit constructingUnit, CUnit constructedStructure) {
|
||||||
|
this.simulationRenderController.spawnUnitConstructionSound(constructingUnit, constructedStructure);
|
||||||
|
}
|
||||||
|
|
||||||
public CPlayer getPlayer(final int index) {
|
public CPlayer getPlayer(final int index) {
|
||||||
return this.players.get(index);
|
return this.players.get(index);
|
||||||
}
|
}
|
||||||
@ -230,4 +234,8 @@ public class CSimulation {
|
|||||||
public CommandErrorListener getCommandErrorListener() {
|
public CommandErrorListener getCommandErrorListener() {
|
||||||
return this.commandErrorListener;
|
return this.commandErrorListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void unitConstructFinishEvent(CUnit constructedStructure) {
|
||||||
|
this.simulationRenderController.spawnUnitConstructionFinishSound(constructedStructure);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,8 @@ public class CUnit extends CWidget {
|
|||||||
private transient CBehaviorFollow followBehavior;
|
private transient CBehaviorFollow followBehavior;
|
||||||
private transient CBehaviorPatrol patrolBehavior;
|
private transient CBehaviorPatrol patrolBehavior;
|
||||||
private transient CBehaviorStop stopBehavior;
|
private transient CBehaviorStop stopBehavior;
|
||||||
|
private boolean constructing = false;
|
||||||
|
private float constructionProgress;
|
||||||
|
|
||||||
public CUnit(final int handleId, final int playerIndex, final float x, final float y, final float life,
|
public CUnit(final int handleId, final int playerIndex, final float x, final float y, final float life,
|
||||||
final War3ID typeId, final float facing, final float mana, final int maximumLife, final int maximumMana,
|
final War3ID typeId, final float facing, final float mana, final int maximumLife, final int maximumMana,
|
||||||
@ -199,6 +201,14 @@ public class CUnit extends CWidget {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (constructing) {
|
||||||
|
constructionProgress += WarsmashConstants.SIMULATION_STEP_TIME;
|
||||||
|
if (constructionProgress >= unitType.getBuildTime()) {
|
||||||
|
constructing = false;
|
||||||
|
game.unitConstructFinishEvent(this);
|
||||||
|
this.stateNotifier.ordersChanged(getCurrentAbilityHandleId(), getCurrentOrderId());
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (this.currentBehavior != null) {
|
else if (this.currentBehavior != null) {
|
||||||
final CBehavior lastBehavior = this.currentBehavior;
|
final CBehavior lastBehavior = this.currentBehavior;
|
||||||
this.currentBehavior = this.currentBehavior.update(game);
|
this.currentBehavior = this.currentBehavior.update(game);
|
||||||
@ -670,4 +680,22 @@ public class CUnit extends CWidget {
|
|||||||
return getCurrentBehavior() instanceof CBehaviorMove;
|
return getCurrentBehavior() instanceof CBehaviorMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setConstructing(boolean constructing) {
|
||||||
|
this.constructing = constructing;
|
||||||
|
if (constructing) {
|
||||||
|
unitAnimationListener.playAnimation(true, PrimaryTag.BIRTH, SequenceUtils.EMPTY, 0.0f, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConstructionProgress(float constructionProgress) {
|
||||||
|
this.constructionProgress = constructionProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConstructing() {
|
||||||
|
return constructing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getConstructionProgress() {
|
||||||
|
return constructionProgress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,10 @@ public class CBehaviorOrcBuild extends CAbstractRangedPointTargetBehavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
protected CBehavior update(final CSimulation simulation, final boolean withinRange) {
|
||||||
simulation.createUnit(this.orderId, this.unit.getPlayerIndex(), this.targetX, this.targetY,
|
CUnit constructedStructure = simulation.createUnit(this.orderId, this.unit.getPlayerIndex(), this.targetX, this.targetY,
|
||||||
simulation.getGameplayConstants().getBuildingAngle());
|
simulation.getGameplayConstants().getBuildingAngle());
|
||||||
|
constructedStructure.setConstructing(true);
|
||||||
|
simulation.unitConstructedEvent(this.unit, constructedStructure);
|
||||||
return this.unit.pollNextOrderBehavior(simulation);
|
return this.unit.pollNextOrderBehavior(simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,11 @@ public interface SimulationRenderController {
|
|||||||
|
|
||||||
void spawnUnitDamageSound(CUnit damagedUnit, final String weaponSound, String armorType);
|
void spawnUnitDamageSound(CUnit damagedUnit, final String weaponSound, String armorType);
|
||||||
|
|
||||||
|
void spawnUnitConstructionSound(CUnit constructingUnit, CUnit constructedStructure);
|
||||||
|
|
||||||
void removeUnit(CUnit unit);
|
void removeUnit(CUnit unit);
|
||||||
|
|
||||||
BufferedImage getBuildingPathingPixelMap(War3ID rawcode);
|
BufferedImage getBuildingPathingPixelMap(War3ID rawcode);
|
||||||
|
|
||||||
|
void spawnUnitConstructionFinishSound(CUnit constructedStructure);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user