Skip to content
This repository has been archived by the owner on Oct 1, 2022. It is now read-only.

Movable Refactoring #563

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
f10bf7d
Create Entity and delegate all calls to Movable's interfaces to the C…
homoroselaps Feb 6, 2017
c7cb40f
Merge branch 'master' into MovableRefactoring
homoroselaps Feb 6, 2017
c5be586
Filled in the boilerplate code for the Components
homoroselaps Feb 16, 2017
a8547e9
missed file
homoroselaps Feb 16, 2017
400bcbd
remove String indexing, switch to Class IdentityHashMap
homoroselaps Mar 27, 2017
3d2fffa
incorporate IScheduleTimerable into Entity
homoroselaps Mar 28, 2017
7353c95
add SimpleBehaviourTree
homoroselaps Mar 28, 2017
94df9bd
Merge remote-tracking branch 'original/master' into MovableRefactoring
homoroselaps Mar 28, 2017
2ca099a
Implement Pathing Code into SteeringComponent
homoroselaps Mar 28, 2017
df49b0f
unify the Movable interface to support future refactorings
homoroselaps Mar 28, 2017
40799ce
remove author
homoroselaps Mar 28, 2017
8396115
Merge branch 'MovableInterface' into MovableRefactoring
homoroselaps Mar 29, 2017
08c034f
lambda behavior tree, basc geologist
homoroselaps Apr 1, 2017
40423a0
Entity lifecycle, convertTo
homoroselaps Apr 3, 2017
5b6bd8a
introduce OnEnable/OnDisable/OnDestroy in Component life cycle
homoroselaps Apr 4, 2017
65fd543
cleanup
homoroselaps Apr 5, 2017
1a7fffb
first draft for bearer behavior tree and component cleanup
homoroselaps Apr 13, 2017
20a7456
fix geologist behavior tree
homoroselaps Apr 13, 2017
1a4e916
first donkey behavior tree and cleanup
homoroselaps Apr 14, 2017
b1f911c
architecture runs, Donkey AI works, too many fixes
homoroselaps Apr 15, 2017
c7b8018
fix AnimationComponent
homoroselaps Apr 15, 2017
7f308b6
support game serialization
homoroselaps Apr 17, 2017
9c0c2da
Clean up code, fix static code inspection issues
homoroselaps Apr 28, 2017
aff376b
Merge remote-tracking branch 'original/master' into MovableRefactoring
homoroselaps Apr 28, 2017
d7ca002
Merge branch 'master' into MovableRefactoring and regenerate replay s…
homoroselaps Aug 31, 2017
adb8826
fix: more than one material got removed at each call
homoroselaps Oct 28, 2017
474fd44
Improve BehaviorTree nodes and design, improve donkey BT
homoroselaps Dec 4, 2017
623daf4
fix run components multiple times per timerEvent, support Notificatio…
homoroselaps Dec 4, 2017
cf110b7
fix Entity called only once
homoroselaps Dec 5, 2017
3c94118
Merge branch 'master' into MovableRefactoring
homoroselaps Dec 6, 2017
f86b87c
implement idle behavior
homoroselaps Dec 6, 2017
186e419
implement basic reaction to push requests, improve handling of entity…
homoroselaps Dec 7, 2017
2005940
Merge branch 'master' into MovableRefactoring
andreas-eberle May 6, 2018
7de0f8f
Fix some method and field names
andreas-eberle May 10, 2018
4027c57
Further renamings
andreas-eberle May 10, 2018
d140c09
Change notification retrieval to use streams instead of iterator
andreas-eberle May 10, 2018
f2bf74d
Refactor MovableWrapper
andreas-eberle May 10, 2018
918c57a
Add test map with specialists
andreas-eberle May 12, 2018
db980d2
Further refactorings and started work on Geologist
andreas-eberle May 12, 2018
116bc1f
Improve debugging node to print debug information in levels and only …
andreas-eberle May 12, 2018
ac76ec4
Add DynamicGuardSelector and make Geologist mostly working
andreas-eberle May 12, 2018
e76340f
Improve stop working behavior of geologist
andreas-eberle May 12, 2018
076a981
Make Notification implement Serializable
andreas-eberle May 12, 2018
1fd9452
Use notification to start and stop work of geologist
andreas-eberle May 13, 2018
54e5d7f
Improve tree readability by including debug message to parameters of …
andreas-eberle May 13, 2018
b3aa62f
Merge remote-tracking branch 'original/master' into MovableRefactoring
homoroselaps Jul 26, 2019
1b7175b
fix notificationCondition, fix chained animation
homoroselaps Jul 27, 2019
7761f6e
fix bearer steeringComponent idleBehavior
homoroselaps Jul 28, 2019
8ddfef7
implement convertTo other entity
homoroselaps Jul 29, 2019
a54b76c
start implementing BuildingWorker
homoroselaps Aug 3, 2019
ea0d6f8
WIP: BuildingWorkerBehaviorComponent
Jul 6, 2020
0642bbb
BuldingWorker Melter is working
Jul 9, 2020
0a3b0e9
presumably all BuildingWorkers work (tested: StoneCutter, Farmer, Shi…
Jul 16, 2020
7fccf39
basic BrickLayer Behavior implemented. not tested yet
Aug 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*******************************************************************************
* Copyright (c) 2015
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*******************************************************************************/
package jsettlers.buildingcreator.job;

public enum EBuildingJobType {
/**
* Waits a given time.
* <p>
* SUCCESS: The time elapsed.
* <p>
* Fail: impossible.
*
* @see BuildingJob#getTime();
*/
WAIT,
/**
* Lets the settler walk in a given direction. The settler may wait.
* <p>
* Parameter: direction
* <p>
* SUCCESS: The settler is at the position
* <p>
* Fail: Should not happen normally.
*/
WALK,
/**
* Shows the settler at a given position.
* <p>
* Parameter: dx, dy
* <p>
* SUCCESS: The settler appeared.
* <p>
* Fail: The settler could not appear at the given position.
*/
SHOW,
/**
* Lets the settler disappear.
* <p>
* Parameter: none
* <p>
* SUCCESS: The settler disappeared instantly.
* <p>
* Fail: impossible
*/
HIDE,

/**
* Sets the material property of the settler.
* <p>
* Parameter: material
* <p>
* SUCCESS: good
* <p>
* Fail: There was no given material at that position.
*/
SET_MATERIAL,

/**
* Picks up the specified material. Does not change the material type assigned to the settler
* <p>
* Parameter: material
* <p>
* SUCCESS: There was a material at that position, one item was removed.
* <p>
* Fail: There was no given material at that position.
*/
TAKE,
/**
* Lets the settler drop the given material to the stack at the positon.
* <p>
* Parameter: material
* <p>
* SUCCESS: When the settler dropped the material.
* <p>
* Fail: If the drop is impossible.
*/
DROP,
/**
* Searches a given search type.
* <p>
* Uses the special {@link BuildingSearchJob} class.
* <p>
* SUCCESS: The settler found the thing he should search and went to it.
* <p>
* Fail: If the searched thing was not found. The settler does not need to go back.
*
* @see BuildingSearchType
*/
SEARCH,
/**
* Goes to the position relative to the building.
* <p>
* SUCCESS: The settler is at the position
* <p>
* Fail: The position is unreachable.
*/
GO_TO,

/**
* Look at
* <p>
* SUCCESS: The settler looks at the given new direction.
* <p>
* Fail: impossible
*/
LOOK_AT,
/**
* Plays an action animation.
* <p>
* Parameter: time - the time the action should take.
* <p>
* SUCCESS: The animation was played.
* <p>
* Fail: something was wrong...
*/
PLAY_ACTION1,
/**
* @see EBuildingJobType#PLAY_ACTION1
*/
PLAY_ACTION2,
PLAY_ACTION3
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*******************************************************************************/
package jsettlers.common;

import jsettlers.common.ai.EPlayerType;

public abstract class CommonConstants {
/**
* A byte value indicating that the given position is visible.
Expand Down Expand Up @@ -69,8 +67,15 @@ public abstract class CommonConstants {
* Option to disable the loading of original maps.
*/
public static boolean DISABLE_ORIGINAL_MAPS = false;

/**
* Disables the checksum test for original maps.
*/
public static boolean DISABLE_ORIGINAL_MAPS_CHECKSUM = false;

/**
* Enables debugging of behavior trees
*/
public static boolean DEBUG_BEHAVIOR_TREES = false;

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* This is a action the user has requested.
* <p>
* Each Action has an active status, that indicates that it is currently executed. When the execution of the action is begun, the flag should be set
* Each action has an active status, that indicates that it is currently executed. When the execution of the action is begun, the flag should be set
* so that the user interface enters a blocking mode, and goes back to normal mode when the action is finished. It is not guaranteed that there is no
* other action being sent during that time, e.g. an cancel-action.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: time (in seconds)
* <p>
* Success: The time elapsed.
* SUCCESS: The time elapsed.
* <p>
* Fail: impossible.
*
Expand All @@ -40,7 +40,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: direction
* <p>
* Success: The settler is at the position
* SUCCESS: The settler is at the position
* <p>
* Fail: Should not happen normally.
*/
Expand All @@ -51,7 +51,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: dx, dy
* <p>
* Success: The settler appeared.
* SUCCESS: The settler appeared.
* <p>
* Fail: The settler could not appear at the given position.
*/
Expand All @@ -62,7 +62,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: none
* <p>
* Success: The settler disappeared instantly.
* SUCCESS: The settler disappeared instantly.
* <p>
* Fail: impossible
*/
Expand All @@ -73,7 +73,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: material
* <p>
* Success: always
* SUCCESS: always
* <p>
* Fail: never
*/
Expand All @@ -84,7 +84,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: material
* <p>
* Success: There was a material at that position, one item was removed.
* SUCCESS: There was a material at that position, one item was removed.
* <p>
* Fail: There was no given material at that position.
*/
Expand All @@ -97,7 +97,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: material
* <p>
* Success: When the settler dropped the material.
* SUCCESS: When the settler dropped the material.
* <p>
* Fail: If the drop is impossible, e.g. because there is already material at that position.
*/
Expand All @@ -112,7 +112,7 @@ public enum EBuildingJobType {
* <p>
* This job always fails if the working radius is 0.
* <p>
* Success: A path to the searched thing has been found.
* SUCCESS: A path to the searched thing has been found.
* <p>
* Fail: If the searched thing was not found.
* <p>
Expand All @@ -132,7 +132,7 @@ public enum EBuildingJobType {
* <p>
* This job always fails if the working radius is 0.
* <p>
* Success: A path to the searched thing has been found.
* SUCCESS: A path to the searched thing has been found.
* <p>
* Fail: If the searched thing was not found.
*
Expand All @@ -149,7 +149,7 @@ public enum EBuildingJobType {
/**
* Goes to the position relative to the building.
* <p>
* Success: The settler is at the position
* SUCCESS: The settler is at the position
* <p>
* Fail: The position is unreachable.
*/
Expand Down Expand Up @@ -178,7 +178,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: direction
* <p>
* Success: The settler looks at the given new direction.
* SUCCESS: The settler looks at the given new direction.
* <p>
* Fail: impossible
*/
Expand All @@ -189,7 +189,7 @@ public enum EBuildingJobType {
* <p>
* Parameter: time (the time the action should take)
* <p>
* Success: The animation was played.
* SUCCESS: The animation was played.
* <p>
* Fail: should not happen.
*/
Expand All @@ -210,7 +210,7 @@ public enum EBuildingJobType {
* <p>
* Parameters: type ({@link jsettlers.common.material.ESearchType})
* <p>
* Success: the given search type has been executed
* SUCCESS: the given search type has been executed
* <p>
* Fail: the given search type couldn't be executed
*/
Expand All @@ -221,7 +221,7 @@ public enum EBuildingJobType {
* <p>
* Parameters: dx, dy, material
* <p>
* Success: There is material at that position.
* SUCCESS: There is material at that position.
* <p>
* Fail: There is no matching material at that position
*/
Expand All @@ -232,7 +232,7 @@ public enum EBuildingJobType {
* <p>
* Parameters: dx, dy, material
* <p>
* Success: The material may be placed at the given position
* SUCCESS: The material may be placed at the given position
* <p>
* Fail: There is a full stack at that position, a wrong stack or it is blocked otherwise.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ private void readSequencesAt(ByteReader reader, int sequenceIndexStart) throws I
int pointerCount = reader.read16();

if (byteCount != pointerCount * 4 + 8) {
throw new IOException("Sequence index block length (" + pointerCount + ") and " + "bytecount (" + byteCount + ") are not consistent.");
throw new IOException("sequence index block length (" + pointerCount + ") and " + "bytecount (" + byteCount + ") are not consistent.");
}

int[] sequenceIndexPointers = new int[pointerCount];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ArraySequence(T[] images) {
/*
* (non-Javadoc)
*
* @see Sequence#length()
* @see sequence#length()
*/
@Override
public int length() {
Expand All @@ -55,7 +55,7 @@ public int length() {
/*
* (non-Javadoc)
*
* @see Sequence#getImageLink(int)
* @see sequence#getImageLink(int)
*/
@Override
public T getImage(int index) {
Expand All @@ -66,7 +66,7 @@ public T getImage(int index) {
/*
* (non-Javadoc)
*
* @see Sequence#getImageSafe(int)
* @see sequence#getImageSafe(int)
*/
@Override
public Image getImageSafe(int index) {
Expand Down
1 change: 1 addition & 0 deletions jsettlers.logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ task unitTest(type: Test) {
dependencies {
implementation project(':jsettlers.common')
implementation project(':jsettlers.network')
implementation 'org.apache.commons:commons-text:1.3'

testImplementation project(':jsettlers.testutils')
testImplementation project(':jsettlers.main.swing')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public String toString() {
}

public ShortPoint2D getBestRatedPoint(PositionRater rater) {
// TODO: Parallel ?
// TODO: parallel ?
int currentBestRating = PositionRater.RATE_INVALID;
ShortPoint2D currentBest = null;
for (int i = 0; i < size; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import jsettlers.input.tasks.ConvertGuiTask;
import jsettlers.logic.map.grid.movable.MovableGrid;
import jsettlers.logic.movable.Movable;
import jsettlers.logic.movable.MovableDataManager;
import jsettlers.logic.movable.interfaces.ILogicMovable;
import jsettlers.network.client.interfaces.ITaskScheduler;

Expand Down Expand Up @@ -60,7 +61,7 @@ public void clear() {
public void removeDeadPioneers() {
Collection<Integer> idsToRemove = new ArrayList<>(pioneerIds.size());
for (Integer pioneerId : pioneerIds) {
if (Movable.getMovableByID(pioneerId) == null) {
if (MovableDataManager.getMovableByID(pioneerId) == null) {
idsToRemove.add(pioneerId);
}
}
Expand Down Expand Up @@ -90,10 +91,11 @@ public void fill(ITaskScheduler taskScheduler, AiStatistics aiStatistics, byte p
}

public PioneerGroup getPioneersWithNoAction() {
List<Integer> pioneersWithNoAction = stream(pioneerIds).filter(pioneerId -> Movable.getMovableByID(pioneerId).getAction() == EMovableAction.NO_ACTION).collect(Collectors.toList());
List<Integer> pioneersWithNoAction = stream(pioneerIds).filter(pioneerId -> MovableDataManager.getMovableByID(pioneerId).getAction() == EMovableAction.NO_ACTION).collect(Collectors.toList());
return new PioneerGroup(pioneersWithNoAction);
}


public void addAll(List<Integer> pioneerIds) {
this.pioneerIds.addAll(pioneerIds);
}
Expand Down
Loading