mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Change the energy consumption counter to be per-entity, adjust consumption rates, and scale the number of entities you can defend from by the caster's experience level
This commit is contained in:
parent
186d7cdbee
commit
3fd161a0d2
1 changed files with 32 additions and 9 deletions
|
@ -1,6 +1,9 @@
|
|||
package com.minelittlepony.unicopia.ability.magic.spell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.minelittlepony.unicopia.Affinity;
|
||||
|
@ -31,6 +34,8 @@ public class ShieldSpell extends AbstractRangedAreaSpell implements Attached {
|
|||
|
||||
private final ParticleHandle particlEffect = new ParticleHandle();
|
||||
|
||||
private final Map<UUID, Target> targets = new TreeMap<>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "shield";
|
||||
|
@ -71,16 +76,15 @@ public class ShieldSpell extends AbstractRangedAreaSpell implements Attached {
|
|||
|
||||
@Override
|
||||
public boolean updateOnPerson(Caster<?> source) {
|
||||
int costMultiplier = applyEntities(source);
|
||||
long costMultiplier = applyEntities(source);
|
||||
if (costMultiplier > 0) {
|
||||
if (source.getMaster().age % 20 == 0) {
|
||||
double cost = 2 + source.getLevel().get();
|
||||
double cost = 2 + source.getLevel().get();
|
||||
|
||||
cost *= Math.max(1, costMultiplier / 12F);
|
||||
cost *= costMultiplier / ((1 + source.getLevel().get()) * 3F);
|
||||
cost /= 2.725D;
|
||||
|
||||
if (!source.subtractEnergyCost(cost)) {
|
||||
onDestroyed(source);
|
||||
}
|
||||
if (!source.subtractEnergyCost(cost)) {
|
||||
onDestroyed(source);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,14 +127,17 @@ public class ShieldSpell extends AbstractRangedAreaSpell implements Attached {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
protected int applyEntities(Caster<?> source) {
|
||||
protected long applyEntities(Caster<?> source) {
|
||||
double radius = getDrawDropOffRange(source);
|
||||
|
||||
Vec3d origin = source.getOriginVector();
|
||||
|
||||
this.targets.values().removeIf(Target::tick);
|
||||
|
||||
List<Entity> targets = getTargets(source, radius);
|
||||
targets.forEach(i -> {
|
||||
try {
|
||||
this.targets.computeIfAbsent(i.getUuid(), Target::new);
|
||||
double dist = i.getPos().distanceTo(origin);
|
||||
|
||||
applyRadialEffect(source, i, dist, radius);
|
||||
|
@ -139,7 +146,7 @@ public class ShieldSpell extends AbstractRangedAreaSpell implements Attached {
|
|||
}
|
||||
});
|
||||
|
||||
return targets.size();
|
||||
return this.targets.values().stream().filter(Target::canHurt).count();
|
||||
}
|
||||
|
||||
protected void applyRadialEffect(Caster<?> source, Entity target, double distance, double radius) {
|
||||
|
@ -213,4 +220,20 @@ public class ShieldSpell extends AbstractRangedAreaSpell implements Attached {
|
|||
ProjectileUtil.setThrowableHeading(projectile, normal, (float)motion.length(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
class Target {
|
||||
|
||||
int cooldown = 20;
|
||||
|
||||
Target(UUID id) {
|
||||
}
|
||||
|
||||
boolean tick() {
|
||||
return --cooldown < 0;
|
||||
}
|
||||
|
||||
boolean canHurt() {
|
||||
return cooldown == 20;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue