Exemple #1
0
 @Override
 public void destroy() {
   try {
     CharStats savedCStats = charStats;
     if (charStats == baseCharStats)
       savedCStats = (CharStats) CMClass.getCommon("DefaultCharStats");
     PhyStats savedPStats = phyStats;
     if (phyStats == basePhyStats) savedPStats = (PhyStats) CMClass.getCommon("DefaultPhyStats");
     final CharState savedCState = curState;
     if ((curState == baseState) || (curState == maxState))
       curState = (CharState) CMClass.getCommon("DefaultCharState");
     super.destroy();
     removeFromGame = false;
     charStats = savedCStats;
     phyStats = savedPStats;
     curState = savedCState;
     baseCharStats.reset();
     basePhyStats.reset();
     baseState.reset();
     maxState.reset();
     curState.reset();
     phyStats.reset();
     charStats.reset();
     finalize();
   } catch (final Throwable t) {
     Log.errOut(ID(), t);
   }
 }
Exemple #2
0
 @Override
 public void executeMsg(final Environmental myHost, final CMMsg msg) {
   super.executeMsg(myHost, msg);
   if (msg.amITarget(this) && (msg.targetMinor() == CMMsg.TYP_DRINK)) {
     final MOB mob = msg.source();
     final boolean thirsty = mob.curState().getThirst() <= 0;
     final boolean full =
         !mob.curState().adjThirst(thirstQuenched(), mob.maxState().maxThirst(mob.baseWeight()));
     if (thirsty) mob.tell(L("You are no longer thirsty."));
     else if (full) mob.tell(L("You have drunk all you can."));
   } else if ((msg.tool() == this)
       && (msg.targetMinor() == CMMsg.TYP_FILL)
       && (msg.target() instanceof Container)
       && (((Container) msg.target()).capacity() > 0)) {
     final Container container = (Container) msg.target();
     final Item I = CMClass.getItem("GenLiquidResource");
     I.setName(L("some milk"));
     I.setDisplayText(L("some milk has been left here."));
     I.setDescription(L("It looks like milk"));
     I.setMaterial(RawMaterial.RESOURCE_MILK);
     I.setBaseValue(RawMaterial.CODES.VALUE(RawMaterial.RESOURCE_MILK));
     I.basePhyStats().setWeight(1);
     CMLib.materials().addEffectsToResource(I);
     I.recoverPhyStats();
     I.setContainer(container);
     if (container.owner() != null)
       if (container.owner() instanceof MOB) ((MOB) container.owner()).addItem(I);
       else if (container.owner() instanceof Room)
         ((Room) container.owner()).addItem(I, ItemPossessor.Expire.Resource);
   }
 }
Exemple #3
0
 @Override
 protected void finalize() throws Throwable {
   if (!amDestroyed) destroy();
   amDestroyed = false;
   if (!CMClass.returnMob(this)) {
     amDestroyed = true;
     super.finalize();
   }
 }