Java 类com.badlogic.gdx.ai.fsm.State 实例源码

项目:Vloxlands    文件:Structure.java   
@SuppressWarnings("unchecked")
@Override
public boolean handleMessage(Telegram msg) {
    if (msg.message == MessageType.YOU_ARE_DISMANTLED.ordinal()) {
        kill();
        Vector3 p = Game.instance.activeIsland.pos;
        ItemDrop i = new ItemDrop(Island.SIZE / 2 - 5, Island.SIZE / 4 * 3 + p.y + 1, Island.SIZE / 2, Item.get("YELLOW_CRYSTAL"), 1);
        island.addEntity(i, false, false);
        return true;
    }

    if (msg.message == MessageType.STRUCTURE_BROADCAST_HANDLED.ordinal()) {
        requestedHumanStates.removeValue((State<Human>) msg.extraInfo, true);
    }

    return false;
}
项目:gdxjam-ugg    文件:GameEntity.java   
public <T extends State> GameEntity changeState(T state){
    if(fsmC == null) fsmC = Mappers.fsm.get(this.entity);
    if(fsmC != null && fsmC.stateMachine.getCurrentState() != state){
        fsmC.stateMachine.changeState(state);
    }
    return this;
}
项目:Vloxlands    文件:Structure.java   
public Structure(float x, float y, float z, String model) {
    super(Math.round(x), Math.round(y), Math.round(z), model);

    nodes = new Array<StructureNode>();
    workers = new Array<Human>();

    int width = (int) Math.ceil(boundingBox.getDimensions().x);
    int depth = (int) Math.ceil(boundingBox.getDimensions().z);

    nodes.add(new StructureNode(NodeType.target, -1, 0, Math.round(depth / 2)));
    nodes.add(new StructureNode(NodeType.target, width, 0, Math.round(depth / 2)));
    nodes.add(new StructureNode(NodeType.target, Math.round(width / 2), 0, -1));
    nodes.add(new StructureNode(NodeType.target, Math.round(width / 2), 0, depth));

    nodes.add(new StructureNode(NodeType.build, 0, 0, Math.round(depth / 2)));
    nodes.add(new StructureNode(NodeType.build, width - 1, 0, Math.round(depth / 2)));
    nodes.add(new StructureNode(NodeType.build, Math.round(width / 2), 0, 0));
    nodes.add(new StructureNode(NodeType.build, Math.round(width / 2), 0, depth - 1));

    inventory = new Inventory();
    buildInventory = new NonStackingInventory(256 /* That should be enough... */);
    costs = new ResourceList();
    requestedHumanStates = new Array<State<Human>>();
    handledHumanStates = new Array<State<Human>>();
    tasks = new Array<Task>();
    taskQueue = new Array<Task>();
    working = true;

    dimensions.x++;
    dimensions.z++;

    setBuilt(false);
}
项目:Vloxlands    文件:Structure.java   
public void broadcast(float delay, State<Human> requestedState, Object... params) {
    Array<Object> array = new Array<Object>(params);
    array.insert(0, this);

    if (!requestedHumanStates.contains(requestedState, true)) requestedHumanStates.add(requestedState);

    MessageDispatcher.getInstance().dispatchMessage(delay, this, null, MessageType.STRUCTURE_BROADCAST.ordinal(), new BroadcastPayload(requestedState, array.items));
}
项目:Vloxlands    文件:Human.java   
public void changeState(State<Human> newState, Object... params) {
    previousStateParams.clear();
    previousStateParams.addAll(stateParams);
    stateParams.clear();
    stateParams.addAll(params);
    stateMachine.changeState(newState);
}
项目:ninja-rabbit    文件:Entity.java   
public Entity(final GraphicsProcessor graphics, final PhysicsProcessor physics, final AudioProcessor audio,
        final State<Entity> initialState) {
    this.graphics = graphics;
    this.physics = physics;
    this.audio = audio;
    stateMachine = new DefaultStateMachine<Entity>(this, initialState);
}
项目:gdxjam-ugg    文件:GameEntity.java   
public State getCurrentState(){
    if(fsmC == null) fsmC = Mappers.fsm.get(this.entity);
    return fsmC == null? null : fsmC.stateMachine.getCurrentState();
}
项目:gdxjam-ugg    文件:FSMComponent.java   
public void changeState (State<GameEntity> state) {
    stateMachine.changeState(state);
}
项目:GDXJam    文件:SquadTatics.java   
private Tatics(State<Entity> entryState){
    this.entryState = entryState;
}
项目:GDXJam    文件:FSMComponent.java   
public void changeState (State<Entity> state) {
    stateMachine.changeState(state);
}
项目:Vloxlands    文件:Structure.java   
public State<Human> getWorkerState() {
    return workerState;
}
项目:Vloxlands    文件:Structure.java   
public void broadcast(State<Human> requestedState, Object... params) {
    broadcast(0, requestedState, params);
}
项目:Vloxlands    文件:Human.java   
public State<Human> getState() {
    return stateMachine.getCurrentState();
}
项目:Vloxlands    文件:SyncedStateMachine.java   
public SyncedStateMachine(E owner, State<E> initialState) {
    super(owner, initialState);
}
项目:Vloxlands    文件:SyncedStateMachine.java   
public SyncedStateMachine(E owner, State<E> initialState, State<E> globalState) {
    super(owner, initialState, globalState);
}
项目:Vloxlands    文件:SyncedStateMachine.java   
@Override
public void changeState(State<E> newState) {
    newStateEntered = false;
    super.changeState(newState);
    newStateEntered = true;
}
项目:Vloxlands    文件:BroadcastPayload.java   
public BroadcastPayload(State<Human> state, Object... params) {
    this.state = state;
    this.params = params;
}
项目:ninja-rabbit    文件:Entity.java   
/**
 * Sets a new {@link State} for this {@link Entity} to be performed in the next execution step
 * for this character.
 *
 * @see StateMachine#changeState(State)
 *
 * @param newState
 *            The state to make the transition to. Each {@link Entity} may define its own.
 *
 */
public void changeState(final State<Entity> newState) {
    stateMachine.changeState(newState);
}
项目:ninja-rabbit    文件:Entity.java   
/**
 * Whether this entity is performing the given state or not.
 *
 * @see StateMachine#isInState(State)
 * @param state
 *            The state to test against the current actions of the entity.
 * @return true if this entity is executing the state; false, otherwise.
 */
public boolean isInState(final State<Entity> state) {
    return state != null && stateMachine.isInState(state);
}
项目:ninja-rabbit    文件:Entity.java   
/**
 * Returns the current state of this {@link Entity}.
 *
 * @see StateMachine#getCurrentState()
 * @return The {@link State} this entity is currently in.
 */
public State<Entity> getCurrentState() {
    return stateMachine.getCurrentState();
}