@Override public void onDeath(Creature actor, Creature killer) { Player player = actor.getPlayer(); if (player == null) { return; } player.removeListener(this); _quest.notifyDeath(killer, actor, QuestState.this); }
public Creature mateWith(Creature partner) { Creature child; if (mateWait != 0) { return null; } subEnergy(mateCost); if (partner.isWillingToMateWith(this)) { Genome childGenes = genes.crossoverWithAndMutate(partner.genes); mateWait = mateDelay; partner.mateWait = mateDelay; partner.subEnergy(mateCost); child = new Creature(world, color, childGenes); return child; } else { return null; } }
@Override public void onKill(Creature actor, Creature victim) { if (!victim.isPlayer()) { return; } Player actorPlayer = (Player) actor; List<Player> players = null; switch (_quest.getParty()) { case Quest.PARTY_NONE: players = Collections.singletonList(actorPlayer); break; case Quest.PARTY_ALL: if (actorPlayer.getParty() == null) { players = Collections.singletonList(actorPlayer); } else { players = new ArrayList<Player>(actorPlayer.getParty().getMemberCount()); for (Player member : actorPlayer.getParty().getPartyMembers()) { if (member.isInRange(actorPlayer, Creature.INTERACTION_DISTANCE)) { players.add(member); } } } break; default: players = Collections.emptyList(); break; } for (Player player : players) { QuestState questState = player.getQuestState(_quest.getClass()); if ((questState != null) && !questState.isCompleted()) { _quest.notifyKill((Player) victim, questState); } } }