-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This state keeps track of the extra options and enables a simpler usage of 'simple vanish' vs customizations of vanish. Signed-off-by: Gabriel Harris-Rouquette <gabizou@me.com>
- Loading branch information
Showing
4 changed files
with
230 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
195 changes: 195 additions & 0 deletions
195
src/main/java/org/spongepowered/api/effect/VanishState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
/* | ||
* This file is part of SpongeAPI, licensed under the MIT License (MIT). | ||
* | ||
* Copyright (c) SpongePowered <https://www.spongepowered.org> | ||
* Copyright (c) contributors | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.spongepowered.api.effect; | ||
|
||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.api.entity.Entity; | ||
|
||
/** | ||
* Represents the state of an {@link Entity}'s vanish state. | ||
* Accessible through {@link org.spongepowered.api.data.Keys#VANISH_STATE} | ||
*/ | ||
public interface VanishState { | ||
|
||
static VanishState vanished() { | ||
return Sponge.game().factoryProvider().provide(VanishState.Factory.class).vanished(); | ||
} | ||
|
||
static VanishState unvanished() { | ||
return Sponge.game().factoryProvider().provide(VanishState.Factory.class).unvanished(); | ||
} | ||
|
||
/** | ||
* Gets whether the state is visible. If an {@link Entity} is visible, then | ||
* other aspects of this state will be ignored, such as | ||
* {@link #ignoresCollisions()}, {@link #untargetable()}, etc. | ||
* | ||
* @return Whether the {@link Entity} is visible | ||
*/ | ||
boolean invisible(); | ||
|
||
/** | ||
* Gets a vanished {@link VanishState state} with {@link #ignoresCollisions()} | ||
* and {@link #untargetable()} set to {@code true}. If the state is already | ||
* {@link #invisible()}, then the same state is returned. | ||
* | ||
* @return The vanished state | ||
*/ | ||
VanishState vanish(); | ||
|
||
/** | ||
* Gets a visible state {@link VanishState} with {@link #ignoresCollisions()} | ||
* and {@link #untargetable()} set to {@code false}. If the state is already | ||
* {@link #invisible()} being {@code false}, then the same state is returned. | ||
* | ||
* @return The visible state | ||
*/ | ||
VanishState unvanish(); | ||
|
||
/** | ||
* Gets if the {@link Entity} will ignore collisions. In cases where | ||
* {@link #invisible()} is {@code false}, this will return {@code false}. | ||
* | ||
* @return Whether collisions will be ignored | ||
*/ | ||
boolean ignoresCollisions(); | ||
|
||
/** | ||
* If {@link #invisible()} returns true, this will return the | ||
* {@link VanishState} with the desired flag of | ||
* {@link #ignoresCollisions()}. | ||
* | ||
* @param ignoresCollisions Whether collisions will be ignored | ||
* @return The new VanishState, the value changed | ||
*/ | ||
VanishState ignoreCollisions(boolean ignoresCollisions); | ||
|
||
/** | ||
* Gets if the {@link Entity} will be untargetable by entity ai. In cases | ||
* where {@link #invisible()} is {@code false}, this will return | ||
* {@code false}. | ||
* | ||
* @return Whether the {@link Entity} will be untargetable | ||
*/ | ||
boolean untargetable(); | ||
|
||
/** | ||
* If {@link #invisible()} returns true, this will return the | ||
* {@link VanishState} with the desired flag of | ||
* {@link #ignoresCollisions()}. | ||
* | ||
* @param untargetable Whether the entity can be targeted by AI | ||
* @return The new VanishState, the value changed | ||
*/ | ||
VanishState untargetable(boolean untargetable); | ||
|
||
/** | ||
* Gets if {@link #affectsMonsterSpawning()} returns {@code false}, the | ||
* vanished {@link Entity} will not spawn monsters or affect near by monster | ||
* spawners. | ||
* <p>Note that this flag works in conjunction with | ||
* {@link org.spongepowered.api.data.Keys#AFFECTS_SPAWNING} such that either | ||
* one being {@code false} will disable spawning.</p> | ||
* | ||
* @return Whether the {@link Entity} will affect monster spawning | ||
*/ | ||
boolean affectsMonsterSpawning(); | ||
|
||
/** | ||
* If {@link #invisible()} returns true, this will return the | ||
* {@link VanishState} with the desired flag. | ||
* <p>Note that this flag works in conjunction with | ||
* {@link org.spongepowered.api.data.Keys#AFFECTS_SPAWNING} such that either | ||
* one being false will disable spawning.</p> | ||
* | ||
* @param affectsMonsterSpawning Whether the {@link Entity} will affect | ||
* monster spawning | ||
* @return The new VanishState | ||
*/ | ||
VanishState affectMonsterSpawning(boolean affectsMonsterSpawning); | ||
|
||
/** | ||
* Gets if the {@link Entity} will produce sounds from various actions that | ||
* occur while {@link #invisible()} is {@code true}. | ||
* | ||
* @return Whether the {@link Entity} will produce sounds while invisible | ||
*/ | ||
boolean createsSounds(); | ||
|
||
/** | ||
* If {@link #invisible()} returns true, this will return the | ||
* {@link VanishState} with the desired flag of | ||
* {@link #createsSounds()}. | ||
* | ||
* @param createSounds Whether the {@link Entity} will produce sounds | ||
* @return The new VanishState | ||
*/ | ||
VanishState createSounds(boolean createSounds); | ||
|
||
/** | ||
* Gets if the {@link Entity} will produce particles from various actions | ||
* that occur while {@link #invisible()} is {@code true}. | ||
* | ||
* @return Whether the {@link Entity} will produce particles while invisible | ||
*/ | ||
boolean createsParticles(); | ||
|
||
/** | ||
* If {@link #invisible()} returns true, this will return the | ||
* {@link VanishState} with the desired flag of | ||
* {@link #createsParticles()}. | ||
* | ||
* @param createParticles Whether the {@link Entity} will produce particles | ||
* @return The new VanishState | ||
*/ | ||
VanishState createParticles(boolean createParticles); | ||
|
||
interface Factory { | ||
|
||
/** | ||
* Creates a vanished state with the defaults: | ||
* <ul> | ||
* <li>{@link #ignoresCollisions()} = {@code true}</li> | ||
* <li>{@link #untargetable()} = {@code true}</li> | ||
* <li>{@link #invisible()} = {@code true}</li> | ||
* </ul> | ||
* | ||
* @return The default vanished state | ||
*/ | ||
VanishState vanished(); | ||
|
||
/** | ||
* Creates an unvanished state with the defaults: | ||
* <ul> | ||
* <li>{@link #ignoresCollisions()} = {@code false}</li> | ||
* <li>{@link #untargetable()} = {@code false}</li> | ||
* <li>{@link #invisible()} = {@code false}</li> | ||
* </ul> | ||
* | ||
* @return The default visible state | ||
*/ | ||
VanishState unvanished(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters