Search in sources :

Example 1 with EventType

use of org.blockartistry.DynSurround.client.footsteps.interfaces.EventType in project DynamicSurroundings by OreCruncher.

the class Generator method simulateFootsteps.

protected void simulateFootsteps(@Nonnull final EntityLivingBase entity) {
    updateWalkedOnStep(entity);
    final float distanceReference = (float) this.distanceWalkedOnStepModified;
    if (this.dmwBase > distanceReference) {
        this.dmwBase = 0;
        this.dwmYChange = 0;
    }
    final double movX = entity.motionX;
    final double movZ = entity.motionZ;
    final double scal = movX * this.xMovec + movZ * this.zMovec;
    if (this.scalStat != scal < 0.001f) {
        this.scalStat = !this.scalStat;
        if (this.scalStat && this.VAR.PLAY_WANDER && !hasSpecialStoppingConditions(entity)) {
            playSinglefoot(entity, 0d, EventType.WANDER, this.isRightFoot);
        }
    }
    this.xMovec = movX;
    this.zMovec = movZ;
    if (entity.onGround || entity.isInWater() || entity.isOnLadder()) {
        EventType event = null;
        float dwm = distanceReference - this.dmwBase;
        final boolean immobile = stoppedImmobile(distanceReference);
        if (immobile && !entity.isOnLadder()) {
            dwm = 0;
            this.dmwBase = distanceReference;
        }
        float distance = 0f;
        if (entity.isOnLadder() && !entity.onGround) {
            distance = this.VAR.STRIDE_LADDER;
        } else if (!entity.isInWater() && MathStuff.abs(this.yPosition - entity.posY) > 0.4d) {
            // step
            if (this.yPosition < entity.posY) {
                // Going upstairs
                distance = this.VAR.STRIDE_STAIR;
                event = speedDisambiguator(entity, EventType.UP, EventType.UP_RUN);
            } else if (!entity.isSneaking()) {
                // Going downstairs
                distance = -1f;
                event = speedDisambiguator(entity, EventType.DOWN, EventType.DOWN_RUN);
            }
            this.dwmYChange = distanceReference;
        } else {
            distance = this.VAR.STRIDE;
        }
        if (event == null) {
            event = speedDisambiguator(entity, EventType.WALK, EventType.RUN);
        }
        distance = reevaluateDistance(event, distance);
        if (dwm > distance) {
            produceStep(entity, event, 0F);
            stepped(entity, event);
            this.dmwBase = distanceReference;
        }
    }
    // while descending stairs
    if (entity.onGround) {
        this.yPosition = entity.posY;
    }
}
Also used : EventType(org.blockartistry.DynSurround.client.footsteps.interfaces.EventType)

Example 2 with EventType

use of org.blockartistry.DynSurround.client.footsteps.interfaces.EventType in project DynamicSurroundings by OreCruncher.

the class AcousticsJsonReader method parseSelector.

private void parseSelector(final EventSelectorAcoustics selector, final JsonObject acousticsDefinition) throws JsonParseException {
    for (final EventType i : EventType.values()) {
        final String eventName = i.jsonName();
        if (acousticsDefinition.has(eventName)) {
            final JsonElement unsolved = acousticsDefinition.get(eventName);
            final IAcoustic acoustic = solveAcoustic(unsolved);
            selector.setAcousticPair(i, acoustic);
        }
    }
}
Also used : EventType(org.blockartistry.DynSurround.client.footsteps.interfaces.EventType) IAcoustic(org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic) JsonElement(com.google.gson.JsonElement)

Aggregations

EventType (org.blockartistry.DynSurround.client.footsteps.interfaces.EventType)2 JsonElement (com.google.gson.JsonElement)1 IAcoustic (org.blockartistry.DynSurround.client.footsteps.interfaces.IAcoustic)1