⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 firemessage.java

📁 2004年robotcup世界冠军源代码
💻 JAVA
字号:
package MRL.Utilities.MessageManagement;import yab.agent.DisasterSpace;import yab.agent.object.*;import java.util.Map;/** * Created by IntelliJ IDEA. * User: Maryam * Date: Apr 27, 2005 * Time: 4:51:28 PM * To change this template use File | Settings | File Templates. *///saeed 85-2-3public class FireMessage extends Message{    static final int fireStartSize = 9;//    static final int timeSize = 9;    //static final int thresholdSize = 4;    static final int fierynessSize = 4;    private int buildingId;    private int fireStart;    //private int threshold;    private int fieryness;//    private int time;    public FireMessage(Building building)    {        super(Type.FIRE_REPORT, building);        buildingId = building.id;        Building fb = (Building) building;        fireStart = fb.getFireStart();        //threshold = fb.getThreshold();        fieryness = fb.fieryness();//        this.time = building.time();    }    public FireMessage(int buildingId, int fireStart, /* int threshold, */int fieryness, int time, Map virtualToIds)    {        super(Type.FIRE_REPORT, null);        this.buildingId = ((Integer) virtualToIds.get(new Integer(buildingId))).intValue();        this.fireStart = fireStart;        //this.threshold = threshold;        this.fieryness = fieryness;//        this.time = time;    }    public FireMessage(char[] message, Map virtualIdToId) // buildingId - firestart - threshold - fieryness //- time    {        super(Type.FIRE_REPORT, null);        int virtualid = Util.charArrayToint(message, 0, idSize);        Integer integer = (Integer) virtualIdToId.get(new Integer(virtualid));        //if (integer == null)        //	;//System.out.println("INTEGER IS NULL for id" + virtualid);        this.buildingId = integer.intValue();        this.fireStart = Util.charArrayToint(message, idSize, fireStartSize);        //this.threshold = Util.charArrayToint(message, idSize + fireStartSize, thresholdSize);        this.fieryness = Util.charArrayToint(message, idSize + fireStartSize /*+ thresholdSize*/, fierynessSize);//        this.time = Util.charArrayToint(message, idSize + fireStartSize + thresholdSize, timeSize);    }    static protected int staticLength()    {        return idSize + fireStartSize + /*thresholdSize + */fierynessSize;//+ timeSize;    }    public boolean equals(Object m)    {        if (!(m instanceof FireMessage)) return false;        return buildingId == ((FireMessage) m).buildingId;    }    public int getBuildingId()    {        return buildingId;    }    public int hashCode()    {        return buildingId;    }    void updateWorld(DisasterSpace world, int time)    {        obj = world.get(buildingId);        Building fb = (Building) obj;        if (fb.time() < time - 2 )        {            fb.setFireStart(fireStart);            fb.setFieryness(fieryness);        }        fb.setHearTime(time);        world.m_fireSet.put(fb, new Integer(fireStart));    }    char[] toCharArray(Map idToVirtualIds) // buildingId - firestart - threshold //- time    {        char[] result = new char[length()];        char[] temp;        temp = Util.intToCharArray(((Integer) idToVirtualIds.get(new Integer(buildingId))).intValue(), idSize);        Util.copyArray(temp, result, 0, 0, idSize);        temp = Util.intToCharArray(fireStart, fireStartSize);        Util.copyArray(temp, result, 0, idSize, fireStartSize);        //temp = Util.intToCharArray(threshold, thresholdSize);        //Util.copyArray(temp, result, 0, idSize + fireStartSize, thresholdSize);        temp = Util.intToCharArray(fieryness, fierynessSize);        Util.copyArray(temp, result, 0, idSize + fireStartSize /*+ thresholdSize*/, fierynessSize);//        temp = Util.intToCharArray(time, timeSize);//        Util.copyArray(temp, result, 0, idSize + fireStartSize + thresholdSize, timeSize);        return result;    }    protected int length()    {        return staticLength();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -