📄 requestpartitionchangingmessage.java
字号:
package MRL.Utilities.MessageManagement;
import yab.agent.DisasterSpace;
import yab.agent.object.*;
import java.util.Map;
import java.util.Collections;
import java.util.List;
import java.util.ArrayList;
import MRL.Utilities.Partitioning.Partition;
//saeed 85-2-3
public class RequestPartitionChangingMessage extends Message
{
int index;
static final int indexSize = 4;
public RequestPartitionChangingMessage(int index)
{
super(Type.REQUESTPARTITIONCHANGING_REPORT, null);
this.index = index;
}
char[] toCharArray(Map ids)
{
char[] result = new char[length()];
char[] temp = Util.intToCharArray(index, indexSize);
Util.copyArray(temp, result, 0, 0, indexSize);
return result;
}
protected int length()
{
return staticLength();
}
protected static int staticLength()
{
return indexSize;
}
public boolean equals(Object m)
{
if (!(m instanceof RequestPartitionChangingMessage)) return false;
return ((RequestPartitionChangingMessage) m).index == index;
}
public int hashCode()
{
return index;
}
void updateWorld(DisasterSpace world, int time)
{
if (world.self instanceof PoliceOffice)
{
Collections.sort(world.policeForces, yab.agent.Util.idComparator);
Humanoid agent = (Humanoid) world.policeForces.get(index);
//TODO:
/*
if(!(agent instanceof PoliceForce)) return;
int newPartID = getNewPartIDUsingUnclearedParts(world, index); // Assigns Police Force To Partition With Max ScoreDelta And Locked Agents
if (newPartID != -1) {
Partition partition = world.partitioner.getPartition(newPartID);
messagepool.SetPartition((PoliceForce)agent,partition);
}
*/
}
}
public RequestPartitionChangingMessage(char[] message)
{
super(Type.REQUESTPARTITIONCHANGING_REPORT, null);
this.index = Util.charArrayToint(message, 0, indexSize);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -