Skip to content

Commit

Permalink
Merge branch 'fix-buff-icons'
Browse files Browse the repository at this point in the history
  • Loading branch information
William Linna committed Jun 28, 2015
2 parents 45d9b75 + f1dd0d2 commit 8092f49
Show file tree
Hide file tree
Showing 52 changed files with 677 additions and 288 deletions.
23 changes: 15 additions & 8 deletions src/arkhados/CharacterInteraction.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import arkhados.controls.CInfluenceInterface;
import arkhados.gamemode.GameMode;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import arkhados.util.Builder;
import arkhados.util.RoundStats;
import arkhados.util.UserDataStrings;
import com.jme3.scene.Spatial;
Expand All @@ -40,7 +42,7 @@ public class CharacterInteraction {

public static void harm(CInfluenceInterface attacker,
CInfluenceInterface target, final float rawDamage,
List<AbstractBuff> buffs, boolean canBreakCC) {
List<AbstractBuffBuilder> buffBuilders, boolean canBreakCC) {

if (target == null) {
return;
Expand Down Expand Up @@ -90,12 +92,17 @@ public static void harm(CInfluenceInterface attacker,
gameMode.playerDied(targetPlayerId, latestDamagerId);
}

if (buffs != null) {
for (AbstractBuff buff : buffs) {
if (buff != null && !buff.isFriendly()) {
buff.attachToCharacter(target);
} else if (buff == null) {
if (buffBuilders != null) {
for (Builder<AbstractBuff> buffBuilder : buffBuilders) {
AbstractBuff buff = buffBuilder.build();

if (buff == null) {
System.out.println("Null in buff-list");
continue;
}

if (!buff.isFriendly()) {
buff.attachToCharacter(target);
}
}
}
Expand All @@ -119,7 +126,7 @@ public static void heal(CInfluenceInterface healer,
}

public static void startNewRound() {
final RoundStats roundStats = new RoundStats();
RoundStats roundStats = new RoundStats();
roundStats.initialize();
roundStatList.add(roundStats);
}
Expand All @@ -128,7 +135,7 @@ public static void addPlayer(int playerId) {
RoundStats round = roundStatList.get(roundStatList.size() - 1);
round.addPlayer(playerId);
}

public static void removePlayer(int playerId) {
RoundStats round = roundStatList.get(roundStatList.size() - 1);
round.removePlayer(playerId);
Expand Down
2 changes: 1 addition & 1 deletion src/arkhados/ServerWorldCollisionListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void projectileCharacterCollision(CProjectile projectile,
return;
}

final CSpellBuff buffControl = projectile.getSpatial()
CSpellBuff buffControl = projectile.getSpatial()
.getControl(CSpellBuff.class);

final boolean canBreakCC = damage > 0f ? true : false;
Expand Down
5 changes: 3 additions & 2 deletions src/arkhados/actions/ACharge.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import arkhados.controls.CCharacterPhysics;
import arkhados.controls.CInfluenceInterface;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import arkhados.util.UserDataStrings;
import com.jme3.bullet.collision.PhysicsCollisionEvent;
import com.jme3.bullet.collision.PhysicsCollisionListener;
Expand Down Expand Up @@ -49,7 +50,7 @@ public class ACharge extends EntityAction
private Vector3f direction;
private GhostControl ghost;
private Node ghostNode;
private List<AbstractBuff> buffs = new ArrayList<>();
private List<AbstractBuffBuilder> buffs = new ArrayList<>();
private boolean hasCollided = false;
private Spatial collidedWith = null;
private float hitDamage;
Expand All @@ -58,7 +59,7 @@ public ACharge(float range) {
this.range = range;
}

public void addBuff(AbstractBuff buff) {
public void addBuff(AbstractBuffBuilder buff) {
buffs.add(buff);
}

Expand Down
43 changes: 25 additions & 18 deletions src/arkhados/actions/ASplash.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import arkhados.controls.CCharacterPhysics;
import arkhados.controls.CInfluenceInterface;
import arkhados.controls.CSpellBuff;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import arkhados.util.DistanceScaling;
import arkhados.util.Selector;
import arkhados.util.UserDataStrings;
Expand All @@ -31,24 +31,24 @@

/**
*
* @author william TODO: Currently SplashAction seems to be meant for negative things only. There
* could be healing splash too or something like that.
* @author william TODO: Currently SplashAction seems to be meant for negative
* things only. There could be healing splash too or something like that.
*/
public class ASplash extends EntityAction {

private float radius;
private float baseDamage;
private Float customImpulse;
private DistanceScaling damageDistance;
private List<AbstractBuff> splashBuffs;
private List<AbstractBuffBuilder> splashBuffs;
private boolean splashBuffsOnly = false;
private List<Spatial> excluded = new ArrayList<>();
private Integer excludedTeam = null;

private CInfluenceInterface casterInterface;

public ASplash(float radius, float baseDamage, DistanceScaling damageDistanceScaling,
List<AbstractBuff> splashBuffs) {
public ASplash(float radius, float baseDamage,
DistanceScaling damageDistanceScaling,
List<AbstractBuffBuilder> splashBuffs) {
this.radius = radius;
this.baseDamage = baseDamage;
this.damageDistance = damageDistanceScaling;
Expand All @@ -58,7 +58,8 @@ public ASplash(float radius, float baseDamage, DistanceScaling damageDistanceSca
}

public ASplash(float radius, float baseDamage, float impulse,
DistanceScaling damageDistance, List<AbstractBuff> splashBuffs) {
DistanceScaling damageDistance,
List<AbstractBuffBuilder> splashBuffs) {
this.radius = radius;
this.baseDamage = baseDamage;
this.customImpulse = impulse;
Expand All @@ -68,8 +69,8 @@ public ASplash(float radius, float baseDamage, float impulse,

@Override
public boolean update(float tpf) {
List<SpatialDistancePair> spatialsOnDistance =
Selector.getSpatialsWithinDistance(new ArrayList<SpatialDistancePair>(),
List<SpatialDistancePair> spatialsOnDistance = Selector
.getSpatialsWithinDistance(new ArrayList<SpatialDistancePair>(),
spatial, radius);

for (SpatialDistancePair pair : spatialsOnDistance) {
Expand All @@ -96,11 +97,11 @@ public boolean update(float tpf) {
}
final float damage = baseDamage * damageDistanceFactor;

List<AbstractBuff> buffsToApply;
List<AbstractBuffBuilder> buffsToApply;
if (splashBuffsOnly) {
buffsToApply = splashBuffs;
} else {
final CSpellBuff buffControl = spatial.getControl(CSpellBuff.class);
CSpellBuff buffControl = spatial.getControl(CSpellBuff.class);
if (buffControl != null) {
buffsToApply = buffControl.getBuffs();
if (splashBuffs != null) {
Expand All @@ -111,27 +112,33 @@ public boolean update(float tpf) {
}
}

CharacterInteraction.harm(casterInterface, targetInterface, damage, buffsToApply, true);
CharacterInteraction.harm(casterInterface, targetInterface, damage,
buffsToApply, true);

CCharacterPhysics physics =
pair.spatial.getControl(CCharacterPhysics.class);
Float impulseFactor;
if (customImpulse == null) {
impulseFactor = spatial.getUserData(UserDataStrings.IMPULSE_FACTOR);
impulseFactor =
spatial.getUserData(UserDataStrings.IMPULSE_FACTOR);
} else {
impulseFactor = customImpulse;
}
Vector3f impulse;

RigidBodyControl colliderPhysics = spatial.getControl(RigidBodyControl.class);
RigidBodyControl colliderPhysics =
spatial.getControl(RigidBodyControl.class);

if (colliderPhysics != null && !colliderPhysics.isKinematic()) {
impulse = pair.spatial.getLocalTranslation()
.subtract(colliderPhysics.getPhysicsLocation().setY(0)).normalizeLocal()
.subtract(colliderPhysics.getPhysicsLocation().setY(0))
.normalizeLocal()
.multLocal(impulseFactor);
} else {
impulse = pair.spatial.getLocalTranslation().subtract(spatial.getLocalTranslation())
.normalizeLocal().multLocal(impulseFactor).multLocal(distanceFactor);
impulse = pair.spatial.getLocalTranslation()
.subtract(spatial.getLocalTranslation())
.normalizeLocal().multLocal(impulseFactor)
.multLocal(distanceFactor);
}

physics.applyImpulse(impulse);
Expand Down
12 changes: 7 additions & 5 deletions src/arkhados/actions/castspellactions/ACastOnGround.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import arkhados.controls.CSpellCast;
import arkhados.spell.Spell;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import arkhados.util.UserDataStrings;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
Expand All @@ -36,7 +37,8 @@ public class ACastOnGround extends EntityAction {

private WorldManager worldManager;
private Spell spell;
private final List<AbstractBuff> additionalEnterBuffs = new ArrayList<>();
private final List<AbstractBuffBuilder> additionalEnterBuffs
= new ArrayList<>();
// NOTE: Add additionalExitBuffs -list if needed

public ACastOnGround(WorldManager worldManager, Spell spell) {
Expand All @@ -57,15 +59,15 @@ public boolean update(float tpf) {
Spatial entity = worldManager.getEntity(entityId);
CAreaEffect aoeControl =
entity.getControl(CAreaEffect.class);
aoeControl.setOwnerInterface(spatial.getControl(
CInfluenceInterface.class));
for (AbstractBuff buff : additionalEnterBuffs) {
aoeControl.setOwnerInterface(
spatial.getControl(CInfluenceInterface.class));
for (AbstractBuffBuilder buff : additionalEnterBuffs) {
aoeControl.addEnterBuff(buff);
}
return false;
}

public void addEnterBuff(final AbstractBuff buff) {
public void addEnterBuff(AbstractBuffBuilder buff) {
if (buff == null) {
throw new IllegalArgumentException(
"Nulls not allowed in containers");
Expand Down
15 changes: 9 additions & 6 deletions src/arkhados/actions/castspellactions/ACastProjectile.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import arkhados.controls.CSpellBuff;
import arkhados.spell.Spell;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import arkhados.util.UserDataStrings;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
Expand All @@ -38,24 +39,26 @@ public class ACastProjectile extends EntityAction {

private final Spell spell;
private final WorldManager worldManager;
private final List<AbstractBuff> additionalBuffs = new ArrayList<>();
private final List<AbstractBuffBuilder> additionalBuffs = new ArrayList<>();

public ACastProjectile(Spell spell, WorldManager worldManager) {
this.spell = spell;
this.worldManager = worldManager;
}

public void addBuff(final AbstractBuff buff) {
public void addBuff(AbstractBuffBuilder buff) {
additionalBuffs.add(buff);
}

@Override
public boolean update(float tpf) {
CCharacterPhysics physicsControl = spatial.getControl(CCharacterPhysics.class);
CCharacterPhysics physicsControl =
spatial.getControl(CCharacterPhysics.class);
Vector3f targetLocation = physicsControl.getTargetLocation();
Vector3f viewDirection = targetLocation.subtract(
spatial.getLocalTranslation()).normalizeLocal();
spatial.getControl(CCharacterPhysics.class).setViewDirection(viewDirection);
spatial.getControl(CCharacterPhysics.class)
.setViewDirection(viewDirection);

float characterRadius = spatial.getUserData(UserDataStrings.RADIUS);
Vector3f spawnLocation = spatial.getLocalTranslation().add(
Expand Down Expand Up @@ -90,8 +93,8 @@ public boolean update(float tpf) {

CSpellBuff buffControl =
projectile.getControl(CSpellBuff.class);
for (AbstractBuff buff : additionalBuffs) {
buffControl.addBuff(buff);
for (AbstractBuffBuilder buffBuilder : additionalBuffs) {
buffControl.addBuff(buffBuilder);
}

return false;
Expand Down
12 changes: 8 additions & 4 deletions src/arkhados/actions/castspellactions/ACastSelfBuff.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import arkhados.actions.EntityAction;
import arkhados.controls.CInfluenceInterface;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -26,19 +27,22 @@
*/
public class ACastSelfBuff extends EntityAction {

private List<AbstractBuff> buffs = new ArrayList<>();
private List<AbstractBuffBuilder> buffs = new ArrayList<>();

@Override
public boolean update(float tpf) {
public boolean update(float tpf) {
CInfluenceInterface target =
spatial.getControl(CInfluenceInterface.class);
for (AbstractBuff buff : buffs) {
for (AbstractBuffBuilder builder : buffs) {
AbstractBuff buff = builder.build();
buff.setOwnerInterface(target);
buff.attachToCharacter(target);
}

return false;
}

public void addBuff(AbstractBuff buff) {
public void addBuff(AbstractBuffBuilder buff) {
buffs.add(buff);
}
}
5 changes: 3 additions & 2 deletions src/arkhados/actions/castspellactions/AMeleeAttack.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import arkhados.controls.CCharacterPhysics;
import arkhados.controls.CInfluenceInterface;
import arkhados.spell.buffs.AbstractBuff;
import arkhados.spell.buffs.AbstractBuffBuilder;
import arkhados.util.Predicate;
import arkhados.util.Selector;
import arkhados.util.UserDataStrings;
Expand All @@ -35,7 +36,7 @@
*/
public class AMeleeAttack extends EntityAction {

private List<AbstractBuff> buffs = new ArrayList<>();
private List<AbstractBuffBuilder> buffs = new ArrayList<>();
private float damage;
private float range;

Expand All @@ -44,7 +45,7 @@ public AMeleeAttack(float damage, float range) {
this.range = range;
}

public void addBuff(AbstractBuff buff) {
public void addBuff(AbstractBuffBuilder buff) {
buffs.add(buff);
}

Expand Down
Loading

0 comments on commit 8092f49

Please sign in to comment.