Search in sources :

Example 1 with IWantToQuit

use of com.microsoft.Malmo.MissionHandlerInterfaces.IWantToQuit in project malmo by Microsoft.

the class RewardForStructureCopyingImplementation method prepare.

/**
 * Called once before the mission starts - use for any necessary initialisation.
 * @param missionInit
 */
@Override
public void prepare(MissionInit missionInit) {
    super.prepare(missionInit);
    MinecraftForge.EVENT_BUS.register(this);
    MalmoMod.MalmoMessageHandler.registerForMessage(this, MalmoMessageType.SERVER_BUILDBATTLEREWARD);
    if (this.rscparams.getAddQuitProducer() != null) {
        // In order to trigger the end of the mission, we need to hook into the quit handlers.
        MissionBehaviour mb = parentBehaviour();
        final String quitDescription = this.rscparams.getAddQuitProducer().getDescription();
        mb.addQuitProducer(new IWantToQuit() {

            @Override
            public void prepare(MissionInit missionInit) {
            }

            @Override
            public String getOutcome() {
                return quitDescription;
            }

            @Override
            public boolean doIWantToQuit(MissionInit missionInit) {
                return RewardForStructureCopyingImplementation.this.structureHasBeenCompleted;
            }

            @Override
            public void cleanup() {
            }
        });
    }
}
Also used : IWantToQuit(com.microsoft.Malmo.MissionHandlerInterfaces.IWantToQuit) MissionInit(com.microsoft.Malmo.Schemas.MissionInit)

Example 2 with IWantToQuit

use of com.microsoft.Malmo.MissionHandlerInterfaces.IWantToQuit in project malmo by Microsoft.

the class MissionQuitCommandsImplementation method install.

// ------------- ICommandHandler methods -----------
@Override
public void install(MissionInit missionInit) {
    // In order to trigger the end of the mission, we need to hook into the quit handlers.
    MissionBehaviour mb = parentBehaviour();
    mb.addQuitProducer(new IWantToQuit() {

        @Override
        public void prepare(MissionInit missionInit) {
        }

        @Override
        public String getOutcome() {
            return MissionQuitCommandsImplementation.this.quitcomParams.getQuitDescription();
        }

        @Override
        public boolean doIWantToQuit(MissionInit missionInit) {
            return MissionQuitCommandsImplementation.this.iWantToQuit;
        }

        @Override
        public void cleanup() {
        }
    });
}
Also used : IWantToQuit(com.microsoft.Malmo.MissionHandlerInterfaces.IWantToQuit) MissionInit(com.microsoft.Malmo.Schemas.MissionInit)

Aggregations

IWantToQuit (com.microsoft.Malmo.MissionHandlerInterfaces.IWantToQuit)2 MissionInit (com.microsoft.Malmo.Schemas.MissionInit)2