mirror of
https://github.com/chylex/Hardcore-Ender-Expansion.git
synced 2025-04-10 20:15:42 +02:00
Add parameterized Causatum event triggering
This commit is contained in:
parent
f67e70c551
commit
46c0214625
src/main/java/chylex/hee/mechanics/causatum
@ -4,6 +4,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import chylex.hee.game.save.SaveData;
|
||||
import chylex.hee.game.save.handlers.PlayerDataHandler;
|
||||
import chylex.hee.game.save.types.player.CausatumFile;
|
||||
@ -28,13 +29,17 @@ public final class CausatumEventHandler{
|
||||
return inst != null && inst.getState() == EventState.WAITING;
|
||||
}
|
||||
|
||||
public static boolean tryStartEvent(EntityPlayerMP player, EventTypes type){
|
||||
public static boolean tryStartEvent(EntityPlayerMP player, EventTypes type, Object[] params){
|
||||
if (hasActiveEvent(player))return false;
|
||||
|
||||
instance.activeEvents.put(PlayerDataHandler.getID(player),type.createEvent(player));
|
||||
instance.activeEvents.put(PlayerDataHandler.getID(player),type.createEvent(player,params));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean tryStartEvent(EntityPlayerMP player, EventTypes type){
|
||||
return tryStartEvent(player,type,ArrayUtils.EMPTY_OBJECT_ARRAY);
|
||||
}
|
||||
|
||||
private Map<String,CausatumEventInstance> activeEvents = new HashMap<>(4);
|
||||
private int nextAttemptTimer;
|
||||
|
||||
|
@ -43,6 +43,12 @@ public abstract class CausatumEventInstance{
|
||||
public CausatumEventInstance createEvent(EntityPlayerMP player){
|
||||
return eventConstructor.apply(this,player);
|
||||
}
|
||||
|
||||
public CausatumEventInstance createEvent(EntityPlayerMP player, Object[] params){
|
||||
CausatumEventInstance inst = createEvent(player);
|
||||
inst.onParams(params);
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
|
||||
public enum EventState{
|
||||
@ -103,6 +109,8 @@ public abstract class CausatumEventInstance{
|
||||
return state;
|
||||
}
|
||||
|
||||
protected void onParams(Object...params){}
|
||||
|
||||
protected abstract void onUpdate();
|
||||
protected abstract void onPlayerDisconnected();
|
||||
protected abstract void onPlayerDied();
|
||||
|
Loading…
Reference in New Issue
Block a user