forked from SteamWar/SteamWar
82 lines
3.4 KiB
Java
82 lines
3.4 KiB
Java
/*
|
|
* 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;
|
|
|
|
import lombok.SneakyThrows;
|
|
import org.bukkit.util.Vector;
|
|
|
|
import javax.imageio.ImageIO;
|
|
import java.awt.*;
|
|
import java.awt.image.BufferedImage;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
public interface WingDesign {
|
|
|
|
@SneakyThrows
|
|
static Vector[] create(String resource) {
|
|
List<Vector> vectors = new ArrayList<>();
|
|
BufferedImage bufferedImage = ImageIO.read(WingDesign.class.getResourceAsStream(resource));
|
|
for (int x = 0; x < bufferedImage.getWidth(); x++) {
|
|
for (int y = 0; y < bufferedImage.getHeight(); y++) {
|
|
int rgb = bufferedImage.getRGB(x, y);
|
|
if (Color.WHITE.getRGB() != rgb) {
|
|
vectors.add(new Vector(x - bufferedImage.getWidth() / 2.0, bufferedImage.getHeight() - y - 1.0, 0));
|
|
}
|
|
}
|
|
}
|
|
return vectors.toArray(new Vector[0]);
|
|
}
|
|
|
|
class WingDesignImpl implements WingDesign {
|
|
private final Vector[] vectors;
|
|
|
|
public WingDesignImpl(Vector[] vectors) {
|
|
this.vectors = vectors;
|
|
}
|
|
|
|
@Override
|
|
public Vector[] getVectors() {
|
|
return vectors;
|
|
}
|
|
}
|
|
|
|
Vector[] getVectors();
|
|
|
|
WingDesign SIMPLE = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSimple4.png"));
|
|
WingDesign COMPLEX = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSimple2.png"));
|
|
WingDesign SWORD = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSword.png"));
|
|
WingDesign SW = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSW.png"));
|
|
WingDesign WGS = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingWGS.png"));
|
|
WingDesign SWORD_CROSSED = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/WingSwordCrossed.png"));
|
|
WingDesign MWGL = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/MWGL.png"));
|
|
|
|
WingDesign ECLIPSE = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/ECLIPSE-Logo.png"));
|
|
WingDesign PL = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/PL-Logo.png"));
|
|
|
|
WingDesign PlompaEasterWings = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/ECAL-Logo.png"));
|
|
|
|
WingDesign ELY_E = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/Ely_E.png"));
|
|
WingDesign ELY_L = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/Ely_L.png"));
|
|
WingDesign ELY_Y = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/Ely_Y.png"));
|
|
|
|
WingDesign EV = new WingDesignImpl(create("/de/steamwar/lobby/particle/decorator/EV.png"));
|
|
}
|