Search in sources :

Example 1 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectTrail method iterate.

@Override
public void iterate() {
    Location origin = getOrigin();
    Location target = getTarget();
    if (origin == null)
        return;
    Vector delta = direction.clone();
    Location source = origin.clone();
    if (playAtOrigin) {
        source.add(delta.multiply(scale(size) + 1));
    }
    if (target != null && playAtTarget) {
        target = target.clone();
        target.add(delta.multiply(-scale(size) + 1));
    }
    playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
}
Also used : Vector(org.bukkit.util.Vector) DynamicLocation(de.slikey.effectlib.util.DynamicLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation) Location(org.bukkit.Location)

Example 2 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectTransform method iterateSteps.

public void iterateSteps(Location originalOrigin, Location originalTarget) {
    for (int i = 0; i < steps; i++) {
        Location source = originalOrigin;
        Location target = originalTarget;
        if (playAtOrigin) {
            source = source.clone();
            source.add(positionTransform.get(source, totalSteps));
        }
        if (target != null && playAtTarget) {
            target = target.clone();
            target.add(positionTransform.get(target, totalSteps));
        }
        playEffect(new DynamicLocation(source, getOriginEntity()), new DynamicLocation(target, getTargetEntity()));
        totalSteps++;
        if (maxStep > 0 && totalSteps >= maxStep) {
            totalSteps = 0;
        }
    }
}
Also used : DynamicLocation(de.slikey.effectlib.util.DynamicLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation) Location(org.bukkit.Location)

Example 3 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectPlayer method startEffects.

public void startEffects(DynamicLocation origin, DynamicLocation target) {
    // Kinda hacky, but makes cross-world trails (e.g. Repair, Backup) work
    Location targetLocation = target == null ? null : target.getLocation();
    Location originLocation = origin == null ? null : origin.getLocation();
    if (targetLocation != null && originLocation != null && !originLocation.getWorld().equals(targetLocation.getWorld())) {
        targetLocation.setWorld(originLocation.getWorld());
    }
    this.origin = origin;
    this.target = target;
    if (originRelativeOffset != null && this.origin != null) {
        this.origin.addRelativeOffset(originRelativeOffset);
    }
    if (targetRelativeOffset != null && this.target != null) {
        this.target.addRelativeOffset(targetRelativeOffset);
    }
    if (hasFirework) {
        fireworkEffect = getFireworkEffect(getColor1(), getColor2(), fireworkType, fireworkFlicker, false);
    } else {
        fireworkEffect = null;
    }
    // Should I let EffectLib handle delay?
    if (delayTicks > 0 && plugin != null) {
        final EffectPlayer player = this;
        Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

            @Override
            public void run() {
                player.startPlay();
            }
        }, delayTicks);
    } else {
        startPlay();
    }
}
Also used : Location(org.bukkit.Location) SourceLocation(com.elmakers.mine.bukkit.magic.SourceLocation) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Example 4 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class CustomProjectileAction method startProjectileEffects.

protected void startProjectileEffects(CastContext context, String effectKey) {
    Collection<EffectPlayer> projectileEffects = context.getEffects(effectKey);
    for (EffectPlayer apiEffectPlayer : projectileEffects) {
        if (effectLocation == null) {
            effectLocation = new DynamicLocation(actionContext.getTargetLocation());
            effectLocation.setDirection(velocity);
        }
        if (activeProjectileEffects == null) {
            activeProjectileEffects = new ArrayList<>();
        }
        // Hrm- this is ugly, but I don't want the API to depend on EffectLib.
        if (apiEffectPlayer instanceof com.elmakers.mine.bukkit.effect.EffectPlayer) {
            com.elmakers.mine.bukkit.effect.EffectPlayer effectPlayer = (com.elmakers.mine.bukkit.effect.EffectPlayer) apiEffectPlayer;
            effectPlayer.setEffectPlayList(activeProjectileEffects);
            effectPlayer.startEffects(effectLocation, null);
        }
    }
}
Also used : EffectPlayer(com.elmakers.mine.bukkit.api.effect.EffectPlayer) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Example 5 with DynamicLocation

use of de.slikey.effectlib.util.DynamicLocation in project MagicPlugin by elBukkit.

the class EffectPlayer method start.

public void start(Location origin, Entity originEntity, Collection<Entity> targets) {
    if (targets == null || targets.size() == 0)
        return;
    DynamicLocation source = new DynamicLocation(origin, originEntity);
    for (Entity targetEntity : targets) {
        if (targetEntity == null)
            continue;
        // This is not really going to work out well for any Effect type but Single!
        // TODO : Perhaps re-visit?
        DynamicLocation target = new DynamicLocation(targetEntity);
        startEffects(source, target);
    }
}
Also used : Entity(org.bukkit.entity.Entity) DynamicLocation(de.slikey.effectlib.util.DynamicLocation)

Aggregations

DynamicLocation (de.slikey.effectlib.util.DynamicLocation)10 Location (org.bukkit.Location)8 SourceLocation (com.elmakers.mine.bukkit.magic.SourceLocation)4 Entity (org.bukkit.entity.Entity)2 Vector (org.bukkit.util.Vector)2 EffectPlayer (com.elmakers.mine.bukkit.api.effect.EffectPlayer)1 ParticleEffect (de.slikey.effectlib.util.ParticleEffect)1 Material (org.bukkit.Material)1