📄 lockedbyblockademessage.java
字号:
package MRL.Utilities.MessageManagement;
import yab.agent.DisasterSpace;
import yab.agent.object.*;
import java.util.Map;
import java.util.Collections;
import MRL.Utilities.Partitioning.Path;
import MRL.Police.EPoliceForce;
import MRL.Police.EPoliceOffice;
//saeed 85-2-3
public class LockedByBlockadeMessage extends Message
{
int positionId;
int index;
static final int indexSize = 6;
public LockedByBlockadeMessage(int index, MotionlessObject position)
{
super(Type.LOCKEDBYBLOCKADE_REPORT, position);
this.index = index;
this.positionId = position.id;
}
char[] toCharArray(Map idToVirtualId)
{
char[] result = new char[length()];
char[] temp = Util.intToCharArray(index, indexSize);
Util.copyArray(temp, result, 0, 0, indexSize);
temp = Util.intToCharArray(((Integer) (idToVirtualId.get(new Integer(positionId)))).intValue(), idSize);
Util.copyArray(temp, result, 0, indexSize, idSize);
return result;
}
protected int length()
{
return staticLength();
}
protected static int staticLength()
{
return indexSize + idSize;
}
public boolean equals(Object m)
{
if (!(m instanceof LockedByBlockadeMessage)) return false;
return ((LockedByBlockadeMessage) m).positionId == positionId&& ((LockedByBlockadeMessage) m).index == index ;
}
public int hashCode()
{
return positionId;
}
void updateWorld(DisasterSpace world, int time)
{
if (world.self instanceof PoliceForce)
{
EPoliceForce me = (EPoliceForce)world.self;
// Collections.sort(world.agents, yab.agent.Util.idComparator);
Humanoid human = (Humanoid) world.agents.get(index);
/*
if (human.time() < time - 2)
{
Road road = (Road)world.get(positionId);
if (MRL.Utilities.ConstantConditions.NOT_PASSABLE_C.eval(road) && !world.lockedBBAgents.containsKey(human))
world.lockedBBAgents.put(human, road);
if(!me.reportedRoads.contains(road))
me.reportedRoads.add(road);
Path path = world.getContainingPath(road);
if (!path.shouldCheck())return;
path.addReportedBIC();
if (world.workingPartition != null)
{
if (world.workingPartition.ML_OBJS_IN_PART_CND.eval(path))
{
me.task = 0;
me.lastTimeTaskAssigned = time;
}
}
}
*/
Road road = (Road)world.get(positionId);
if (MRL.Utilities.ConstantConditions.SHOULD_CHECK_ROAD_CND.eval(road)){
me.blockData.setLockedByBlockade(human,road);
if(!me.reportedRoads.contains(road))
me.reportedRoads.add(road);
Path path = world.getContainingPath(road);
if (path.checkPathIsOpen())return;
path.addReportedBIC();
// if (world.workingPartition != null)
// {
// if (world.workingPartition.ML_OBJS_IN_PART_CND.eval(path))
// {
// me.task = 0;
// me.lastTimeTaskAssigned = time;
// }
// }
}
}
else if (world.self instanceof PoliceOffice){
EPoliceOffice po = (EPoliceOffice) world.self;
Humanoid human = (Humanoid) world.agents.get(index);
Road road = (Road)world.get(positionId);
if (MRL.Utilities.ConstantConditions.SHOULD_CHECK_ROAD_CND.eval(road)){
po.blockData.setLockedByBlockade( human,road);
}
}
}
public LockedByBlockadeMessage(char[] message, Map virtualIdToId)
{
super(Type.LOCKEDBYBLOCKADE_REPORT, null);
this.index = Util.charArrayToint(message, 0, indexSize);
this.positionId = ((Integer) virtualIdToId.get(new Integer(Util.charArrayToint(message, indexSize, idSize)))).intValue();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -