Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed world property analysis.
- Loading branch information
Showing
9 changed files
with
220 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/** | ||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team | ||
* http://www.mod-buildcraft.com | ||
* | ||
* BuildCraft is distributed under the terms of the Minecraft Mod Public | ||
* License 1.0, or MMPL. Please check the contents of the license located in | ||
* http://www.mod-buildcraft.com/MMPL-1.0.txt | ||
*/ | ||
package buildcraft.core.robots; | ||
|
||
import buildcraft.api.robots.AIRobot; | ||
import buildcraft.api.robots.DockingStationRegistry; | ||
import buildcraft.api.robots.EntityRobotBase; | ||
import buildcraft.api.robots.IDockingStation; | ||
|
||
public class AIRobotLookForStation extends AIRobot { | ||
|
||
private DockingStation axeDocking = null; | ||
private IStationFilter filter; | ||
|
||
public AIRobotLookForStation(EntityRobotBase iRobot, IStationFilter iFilter) { | ||
super(iRobot); | ||
|
||
filter = iFilter; | ||
} | ||
|
||
@Override | ||
public void start() { | ||
if (robot.getDockingStation() != null | ||
&& filter.matches((DockingStation) robot.getDockingStation())) { | ||
terminate(); | ||
return; | ||
} | ||
|
||
// TODO: replace FetchItemStack and Recharge with this implementation | ||
|
||
double potentialStationDistance = Float.MAX_VALUE; | ||
DockingStation potentialStation = null; | ||
|
||
for (IDockingStation d : DockingStationRegistry.getStations()) { | ||
DockingStation station = (DockingStation) d; | ||
|
||
if (station.reserved() != null) { | ||
continue; | ||
} | ||
|
||
if (filter.matches(station)) { | ||
double dx = robot.posX - d.x(); | ||
double dy = robot.posY - d.y(); | ||
double dz = robot.posZ - d.z(); | ||
double distance = dx * dx + dy + dy + dz * dz; | ||
|
||
if (potentialStation == null || distance < potentialStationDistance) { | ||
potentialStation = station; | ||
potentialStationDistance = distance; | ||
} | ||
} | ||
} | ||
|
||
if (potentialStation != null) { | ||
startDelegateAI(new AIRobotGoToDock(robot, potentialStation)); | ||
} else { | ||
terminate(); | ||
} | ||
} | ||
|
||
@Override | ||
public void delegateAIEnded(AIRobot ai) { | ||
terminate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team | ||
* http://www.mod-buildcraft.com | ||
* | ||
* BuildCraft is distributed under the terms of the Minecraft Mod Public | ||
* License 1.0, or MMPL. Please check the contents of the license located in | ||
* http://www.mod-buildcraft.com/MMPL-1.0.txt | ||
*/ | ||
package buildcraft.core.robots; | ||
|
||
public interface IStationFilter { | ||
|
||
boolean matches(DockingStation station); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.