forked from SteamWar/SteamWar
Redraw beating wings every tick only after a jump
The wing beat touch no longer lowers the entry's interval. Its wings are drawn every tick during the beat and at their usual interval otherwise; the extra redraws do not count towards the slot budget.
This commit is contained in:
@@ -140,8 +140,8 @@ public class Designs {
|
||||
|
||||
@Override
|
||||
public void adjust(Parameter<?> changed, ParameterValues values) {
|
||||
if (changed != WING_MOTION && changed != EntryParameters.TOUCH) return;
|
||||
boolean moving = values.get(WING_MOTION) != Wing.Motion.NONE || values.get(EntryParameters.TOUCH) == Touches.JUMP_WINGS;
|
||||
if (changed != WING_MOTION) return;
|
||||
boolean moving = values.get(WING_MOTION) != Wing.Motion.NONE;
|
||||
int interval = values.get(EntryParameters.INTERVAL);
|
||||
if (moving && interval > MOVING_WING_INTERVAL) {
|
||||
values.set(EntryParameters.INTERVAL, MOVING_WING_INTERVAL);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class Wing extends DelegatingParticleElement {
|
||||
private static final double MOVING_OPEN_DEGREES = 15;
|
||||
private static final double FULL_OPEN_SPEED = 0.6;
|
||||
private static final double FLAP_DEGREES = 25;
|
||||
private static final int JUMP_BEAT_TICKS = 10;
|
||||
public static final int JUMP_BEAT_TICKS = 10;
|
||||
|
||||
private double size;
|
||||
private WingDesign wingDesign;
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.steamwar.lobby.particle.elements.touch;
|
||||
|
||||
import de.steamwar.lobby.particle.BodyMotion;
|
||||
import de.steamwar.lobby.particle.ParticleElement;
|
||||
import de.steamwar.lobby.particle.ParticleTickData;
|
||||
import de.steamwar.lobby.particle.elements.DelegatingParticleElement;
|
||||
|
||||
// Ticks the element every tick for a while after each jump, and as usual otherwise
|
||||
public class AfterJump extends DelegatingParticleElement {
|
||||
|
||||
private final ParticleElement otherwise;
|
||||
private final int ticks;
|
||||
|
||||
public AfterJump(ParticleElement particleElement, ParticleElement otherwise, int ticks) {
|
||||
super(particleElement);
|
||||
this.otherwise = otherwise;
|
||||
this.ticks = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick(ParticleTickData particleTickData) {
|
||||
if (BodyMotion.ticksSinceJump(particleTickData.getPlayer()) <= ticks) {
|
||||
particleElement.tick(particleTickData);
|
||||
} else {
|
||||
otherwise.tick(particleTickData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import de.steamwar.lobby.particle.ParticleTickData;
|
||||
import de.steamwar.lobby.particle.UnlockContext;
|
||||
import de.steamwar.lobby.particle.design.*;
|
||||
import de.steamwar.lobby.particle.elements.*;
|
||||
import de.steamwar.lobby.particle.elements.touch.AfterJump;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -98,7 +99,11 @@ public class ParticleEntry {
|
||||
element = values.get(VISIBILITY).wrap(element);
|
||||
|
||||
int interval = values.get(INTERVAL);
|
||||
if (interval > 1) {
|
||||
if (interval > 1 && design.absorbsTouch(values.get(TOUCH))) {
|
||||
// The jump beat needs every tick to look smooth; outside of it the usual interval applies, and the
|
||||
// extra redraws are not counted towards the budget
|
||||
element = new AfterJump(element, new Delayed(element, interval), Wing.JUMP_BEAT_TICKS);
|
||||
} else if (interval > 1) {
|
||||
element = new Delayed(element, interval);
|
||||
}
|
||||
if (values.get(TICK_MODE) == TickMode.ALWAYS) {
|
||||
|
||||
Reference in New Issue
Block a user