package comlib.adk.dummy;

import comlib.adk.dummy.event.AmbulanceCivilianEvent;
import comlib.adk.dummy.util.CivilianManager;
import comlib.adk.team.tactics.AmbulanceTeamTactics;
import comlib.adk.util.action.AmbulanceAction;
import comlib.manager.MessageManager;
import comlib.message.DummyMessage;
import rescuecore2.messages.Message;
import rescuecore2.worldmodel.ChangeSet;

public class DummyAmbulance extends AmbulanceTeamTactics {

    public CivilianManager civilianManager;

    public DummyAmbulance() {
        this.civilianManager = new CivilianManager();
    }

    @Override
    public void postConnect() {
    }

    @Override
    public void registerEvent(MessageManager manager) {
        manager.registerEvent(new AmbulanceCivilianEvent(this.model, this.civilianManager));
    }

    @Override
    public Message think(int time, ChangeSet changed, MessageManager manager) {
        /*
        受信処理→eventによる情報処理
        視覚情報の処理→情報処理完了
        ・上の２つで送る情報をある程度生成
        現在の状態の確認→
        ・埋まっている→救助要請、rest
        ・目標決まってない→情報より対象設定・補充が必要ならば避難場所、move
        ・目標決まってる→通れるか確認、move
        ・対象付近→救助活動
        情報の送信
         */
        this.civilianManager.update(this.model, changed, manager);

        manager.addSendMessage(new DummyMessage(time, 10, 0));
        return AmbulanceAction.rest(this, time);
    }
}

@@ -354,28 +354,266 @@
 re2.
-worldmodel.ChangeSet
+standard.entities.Human;%0Aimport rescuecore2.standard.entities.Refuge;%0Aimport rescuecore2.standard.entities.StandardEntity;%0Aimport rescuecore2.standard.entities.StandardEntityURN;%0Aimport rescuecore2.worldmodel.ChangeSet;%0Aimport rescuecore2.worldmodel.EntityID
 ;%0A%0Ap
@@ -716,16 +716,51 @@
 nager;%0A%0A
+    public EntityID rescueTarget;%0A%0A
     publ
@@ -835,16 +835,50 @@
 ager();%0A
+        this.rescueTarget = null;%0A
     %7D%0A%0A 
@@ -1513,71 +1513,1072 @@
 r);%0A
-%0A        manager.addSendMessage(new DummyMessage(time, 10, 0));
+        if(this.someoneOnBoard()) %7B%0A            if (this.location instanceof Refuge) %7B%0A                this.rescueTarget = null;%0A                return AmbulanceAction.unload(this, time);%0A                /*if(this.rescueTarget != null)%7B%0A                    //this.bus.getOutput().addMessage(this.bus.getAgent().messageFactory.createInformationMessage(this.bus.getMemory().getTime(), (Human)this.bus.getAgent().getModel().getEntity(this.bus.getMemory(AmbulanceMemory.class).getRescueTarget())));%0A                %7D*/%0A            %7D%0A            else %7B%0A                return this.moveRefuge(time);%0A            %7D%0A        %7D%0A        manager.addSendMessage(new DummyMessage(time, 10, 0));%0A        return AmbulanceAction.rest(this, time);%0A    %7D%0A    public boolean someoneOnBoard() %7B%0A        for (StandardEntity next : this.model.getEntitiesOfType(StandardEntityURN.CIVILIAN)) %7B%0A            if (((Human)next).getPosition().equals(this.agentID)) %7B%0A                return true;%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%0A    public Message moveRefuge(int time)%0A    %7B
 %0A   

update Ambulance