-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathEntityFactory.java
92 lines (82 loc) · 2.42 KB
/
EntityFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package jalse.entities;
import java.util.UUID;
import jalse.actions.ActionEngine;
/**
* An entity factory is used to control the creation, transfer and killing of {@link Entity}. This
* should only be used by {@link EntityContainer}s and only at the parent level of the
* {@link Entity} they are managing. <br>
* <br>
* The main aim of the factory is to ensure the {@link Entity} (and sub-tree) state is maintained.
* It should be the aim of the {@link EntityContainer} calling the factory to ensure references are
* removed at their level.
*
* @author Elliot Ford
*
* @see DefaultEntityContainer
* @see DefaultEntityFactory
*
*/
public interface EntityFactory {
/**
* Exports an entity (removing all references).
*
* @param e
* Entity to detach.
*/
void exportEntity(Entity e);
/**
* Creates a new entity with the specified ID and parent container.
*
* @param id
* Entity ID.
* @param target
* Parent container.
* @return Newly created entity.
*/
Entity newEntity(UUID id, EntityContainer target);
/**
* Sets the engine to supply to new entities.
*
* @param engine
* Action engine.
*/
void setEngine(ActionEngine engine);
/**
* Imports the entity into the factory.
*
* @param e
* Entity to import.
* @param target
* Target container.
* @return Whether the entity was imported.
*/
boolean tryImportEntity(Entity e, EntityContainer target);
/**
* Kills the specified entity.
*
* @param e
* Entity to kill.
* @return Whether the entity was killed.
*/
boolean tryKillEntity(Entity e);
/**
* Tries to take the entity from within the tree if possible.
*
* @param e
* Entity to take.
* @param target
* Target container.
* @return Whether the entity could be taken from within the tree.
*/
boolean tryTakeFromTree(Entity e, EntityContainer target);
/**
* Checks if the two containers are within the same tree (for in tree transfer or export).
*
* @param source
* Source container.
* @param target
* Target container.
* @return Whether they're within the same tree.
*/
boolean withinSameTree(EntityContainer source, EntityContainer target);
}