|
| 1 | +/* |
| 2 | + * This file is part of SpongeAPI, licensed under the MIT License (MIT). |
| 3 | + * |
| 4 | + * Copyright (c) SpongePowered <https://www.spongepowered.org> |
| 5 | + * Copyright (c) contributors |
| 6 | + * |
| 7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 8 | + * of this software and associated documentation files (the "Software"), to deal |
| 9 | + * in the Software without restriction, including without limitation the rights |
| 10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 11 | + * copies of the Software, and to permit persons to whom the Software is |
| 12 | + * furnished to do so, subject to the following conditions: |
| 13 | + * |
| 14 | + * The above copyright notice and this permission notice shall be included in |
| 15 | + * all copies or substantial portions of the Software. |
| 16 | + * |
| 17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 23 | + * THE SOFTWARE. |
| 24 | + */ |
| 25 | +package org.spongepowered.api.effect; |
| 26 | + |
| 27 | +import org.spongepowered.api.Sponge; |
| 28 | +import org.spongepowered.api.entity.Entity; |
| 29 | + |
| 30 | +/** |
| 31 | + * Represents the state of an {@link Entity}'s vanish state. |
| 32 | + * Accessible through {@link org.spongepowered.api.data.Keys#VANISH_STATE} |
| 33 | + */ |
| 34 | +public interface VanishState { |
| 35 | + |
| 36 | + /** |
| 37 | + * Gets a vanished state via {@link Factory#vanish()} with the following |
| 38 | + * defaults: |
| 39 | + * <ul> |
| 40 | + * <li>{@link VanishState#invisible()} = {@code true}</li> |
| 41 | + * <li>{@link VanishState#affectsMonsterSpawning()} = {@code false}</li> |
| 42 | + * <li>{@link VanishState#untargetable()} = {@code true}</li> |
| 43 | + * <li>{@link VanishState#createsSounds()} = {@code false}</li> |
| 44 | + * <li>{@link VanishState#createsParticles()} = {@code false}</li> |
| 45 | + * </ul> |
| 46 | + * |
| 47 | + * @return A vanished state with the provided defaults |
| 48 | + */ |
| 49 | + static VanishState vanished() { |
| 50 | + return Sponge.game().factoryProvider().provide(VanishState.Factory.class).vanished(); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * A {@link VanishState} that is invisible with the following defaults: |
| 55 | + * <ul> |
| 56 | + * <li>{@link VanishState#invisible()} = {@code false}</li> |
| 57 | + * <li>{@link VanishState#affectsMonsterSpawning()} = {@code true}</li> |
| 58 | + * <li>{@link VanishState#untargetable()} = {@code false}</li> |
| 59 | + * <li>{@link VanishState#createsSounds()} = {@code true}</li> |
| 60 | + * <li>{@link VanishState#createsParticles()} = {@code true}</li> |
| 61 | + * </ul> |
| 62 | + * |
| 63 | + * @return A visible state with the provided defaults |
| 64 | + */ |
| 65 | + static VanishState unvanished() { |
| 66 | + return Sponge.game().factoryProvider().provide(VanishState.Factory.class).unvanished(); |
| 67 | + } |
| 68 | + |
| 69 | + /** |
| 70 | + * Gets whether the state is visible. If an {@link Entity} is visible, then |
| 71 | + * other aspects of this state will be ignored, such as |
| 72 | + * {@link #ignoresCollisions()}, {@link #untargetable()}, etc. |
| 73 | + * |
| 74 | + * @return Whether the {@link Entity} is visible |
| 75 | + */ |
| 76 | + boolean invisible(); |
| 77 | + |
| 78 | + /** |
| 79 | + * Gets a vanished {@link VanishState state} with {@link #ignoresCollisions()} |
| 80 | + * and {@link #untargetable()} set to {@code true}. If the state is already |
| 81 | + * {@link #invisible()}, then the same state is returned. |
| 82 | + * |
| 83 | + * @return The vanished state |
| 84 | + */ |
| 85 | + VanishState vanish(); |
| 86 | + |
| 87 | + /** |
| 88 | + * Gets a visible state {@link VanishState} with {@link #ignoresCollisions()} |
| 89 | + * and {@link #untargetable()} set to {@code false}. If the state is already |
| 90 | + * {@link #invisible()} being {@code false}, then the same state is returned. |
| 91 | + * |
| 92 | + * @return The visible state |
| 93 | + */ |
| 94 | + VanishState unvanish(); |
| 95 | + |
| 96 | + /** |
| 97 | + * Gets if the {@link Entity} will ignore collisions. In cases where |
| 98 | + * {@link #invisible()} is {@code false}, this will return {@code false}. |
| 99 | + * |
| 100 | + * @return Whether collisions will be ignored |
| 101 | + */ |
| 102 | + boolean ignoresCollisions(); |
| 103 | + |
| 104 | + /** |
| 105 | + * If {@link #invisible()} returns true, this will return the |
| 106 | + * {@link VanishState} with the desired flag of |
| 107 | + * {@link #ignoresCollisions()}. |
| 108 | + * |
| 109 | + * @param ignoresCollisions Whether collisions will be ignored |
| 110 | + * @return The new VanishState, the value changed |
| 111 | + */ |
| 112 | + VanishState ignoreCollisions(boolean ignoresCollisions); |
| 113 | + |
| 114 | + /** |
| 115 | + * Gets if the {@link Entity} will be untargetable by entity ai. In cases |
| 116 | + * where {@link #invisible()} is {@code false}, this will return |
| 117 | + * {@code false}. |
| 118 | + * |
| 119 | + * @return Whether the {@link Entity} will be untargetable |
| 120 | + */ |
| 121 | + boolean untargetable(); |
| 122 | + |
| 123 | + /** |
| 124 | + * If {@link #invisible()} returns true, this will return the |
| 125 | + * {@link VanishState} with the desired flag of |
| 126 | + * {@link #ignoresCollisions()}. |
| 127 | + * |
| 128 | + * @param untargetable Whether the entity can be targeted by AI |
| 129 | + * @return The new VanishState, the value changed |
| 130 | + */ |
| 131 | + VanishState untargetable(boolean untargetable); |
| 132 | + |
| 133 | + /** |
| 134 | + * Gets if {@link #affectsMonsterSpawning()} returns {@code false}, the |
| 135 | + * vanished {@link Entity} will not spawn monsters or affect near by monster |
| 136 | + * spawners. |
| 137 | + * <p>Note that this flag works in conjunction with |
| 138 | + * {@link org.spongepowered.api.data.Keys#AFFECTS_SPAWNING} such that either |
| 139 | + * one being {@code false} will disable spawning.</p> |
| 140 | + * |
| 141 | + * @return Whether the {@link Entity} will affect monster spawning |
| 142 | + */ |
| 143 | + boolean affectsMonsterSpawning(); |
| 144 | + |
| 145 | + /** |
| 146 | + * If {@link #invisible()} returns true, this will return the |
| 147 | + * {@link VanishState} with the desired flag. |
| 148 | + * <p>Note that this flag works in conjunction with |
| 149 | + * {@link org.spongepowered.api.data.Keys#AFFECTS_SPAWNING} such that either |
| 150 | + * one being false will disable spawning.</p> |
| 151 | + * |
| 152 | + * @param affectsMonsterSpawning Whether the {@link Entity} will affect |
| 153 | + * monster spawning |
| 154 | + * @return The new VanishState |
| 155 | + */ |
| 156 | + VanishState affectMonsterSpawning(boolean affectsMonsterSpawning); |
| 157 | + |
| 158 | + /** |
| 159 | + * Gets if the {@link Entity} will produce sounds from various actions that |
| 160 | + * occur while {@link #invisible()} is {@code true}. |
| 161 | + * |
| 162 | + * @return Whether the {@link Entity} will produce sounds while invisible |
| 163 | + */ |
| 164 | + boolean createsSounds(); |
| 165 | + |
| 166 | + /** |
| 167 | + * If {@link #invisible()} returns true, this will return the |
| 168 | + * {@link VanishState} with the desired flag of |
| 169 | + * {@link #createsSounds()}. |
| 170 | + * |
| 171 | + * @param createSounds Whether the {@link Entity} will produce sounds |
| 172 | + * @return The new VanishState |
| 173 | + */ |
| 174 | + VanishState createSounds(boolean createSounds); |
| 175 | + |
| 176 | + /** |
| 177 | + * Gets if the {@link Entity} will produce particles from various actions |
| 178 | + * that occur while {@link #invisible()} is {@code true}. |
| 179 | + * |
| 180 | + * @return Whether the {@link Entity} will produce particles while invisible |
| 181 | + */ |
| 182 | + boolean createsParticles(); |
| 183 | + |
| 184 | + /** |
| 185 | + * If {@link #invisible()} returns true, this will return the |
| 186 | + * {@link VanishState} with the desired flag of |
| 187 | + * {@link #createsParticles()}. |
| 188 | + * |
| 189 | + * @param createParticles Whether the {@link Entity} will produce particles |
| 190 | + * @return The new VanishState |
| 191 | + */ |
| 192 | + VanishState createParticles(boolean createParticles); |
| 193 | + |
| 194 | + interface Factory { |
| 195 | + |
| 196 | + /** |
| 197 | + * Creates a {@link VanishState} that is invisible with the following |
| 198 | + * defaults: |
| 199 | + * <ul> |
| 200 | + * <li>{@link VanishState#invisible()} = {@code true}</li> |
| 201 | + * <li>{@link VanishState#affectsMonsterSpawning()} = {@code false}</li> |
| 202 | + * <li>{@link VanishState#untargetable()} = {@code true}</li> |
| 203 | + * <li>{@link VanishState#createsSounds()} = {@code false}</li> |
| 204 | + * <li>{@link VanishState#createsParticles()} = {@code false}</li> |
| 205 | + * </ul> |
| 206 | + * |
| 207 | + * @return A newly created invisible {@link VanishState} |
| 208 | + */ |
| 209 | + VanishState vanished(); |
| 210 | + |
| 211 | + /** |
| 212 | + * A {@link VanishState} that is visible with the following defaults: |
| 213 | + * <ul> |
| 214 | + * <li>{@link VanishState#invisible()} = {@code false}</li> |
| 215 | + * <li>{@link VanishState#affectsMonsterSpawning()} = {@code true}</li> |
| 216 | + * <li>{@link VanishState#untargetable()} = {@code false}</li> |
| 217 | + * <li>{@link VanishState#createsSounds()} = {@code true}</li> |
| 218 | + * <li>{@link VanishState#createsParticles()} = {@code true}</li> |
| 219 | + * </ul> |
| 220 | + * |
| 221 | + * @return A newly created visible {@link VanishState} |
| 222 | + */ |
| 223 | + VanishState unvanished(); |
| 224 | + } |
| 225 | +} |
0 commit comments