use of ilargia.egdx.logicbricks.component.actuator.Link in project Entitas-Java by Rubentxu.
the class Indexed method initialize.
public static void initialize(Entitas entitas) {
_entitas = entitas;
index = new KeyIndex(-1, null);
// GameEntity contains Sensors entities
_entitas.sensor.addEntityIndex(new PrimaryEntityIndex<SensorEntity, KeyIndex>(Indexed.SensorsEntityIndex, ((e, c) -> {
if (c != null) {
ilargia.egdx.logicbricks.component.sensor.Link link = (ilargia.egdx.logicbricks.component.sensor.Link) c;
return new KeyIndex(link.ownerEntity, link.sensorReference);
}
return new KeyIndex(e.getLink().ownerEntity, e.getLink().sensorReference);
}), _entitas.sensor.getGroup(SensorMatcher.Link())));
// GameEntity contains Actuator entities
_entitas.actuator.addEntityIndex(new PrimaryEntityIndex<ActuatorEntity, KeyIndex>(Indexed.ActuatorsEntityIndex, ((e, c) -> {
if (c != null) {
Link link = (Link) c;
return new KeyIndex(link.ownerEntity, link.actuatorReference);
}
return new KeyIndex(e.getLink().ownerEntity, e.getLink().actuatorReference);
}), _entitas.actuator.getGroup(ActuatorMatcher.Link())));
// Interactive GameEntity index
_entitas.game.addEntityIndex(new PrimaryEntityIndex<GameEntity, Integer>(Indexed.InteractiveEntityIndex, ((e, c) -> e.getCreationIndex()), _entitas.game.getGroup(GameMatcher.Interactive())));
// Tags GameEntity index
_entitas.game.addEntityIndex(new EntityIndex<GameEntity, String>(Indexed.TagEntityIndex, _entitas.game.getGroup(Matcher.AllOf(GameMatcher.Tags(), GameMatcher.Interactive())), ((e, c) -> e.getTags().values.toArray(new String[0]))));
// Sensors context GameEntities
_entitas.game.addEntityIndex(new EntityIndex<GameEntity, Integer>(Indexed.GameEntitiesInSensorIndex, _entitas.game.getGroup(GameMatcher.Interactive()), ((e, c) -> new Integer[0])));
}
use of ilargia.egdx.logicbricks.component.actuator.Link in project Entitas-Java by Rubentxu.
the class ActuatorEntity method addLink.
public ActuatorEntity addLink(String actuatorReference, int ownerEntity, boolean isOpen) {
Link component = (Link) recoverComponent(ActuatorComponentsLookup.Link);
if (component == null) {
component = new Link(actuatorReference, ownerEntity, isOpen);
} else {
component.actuatorReference = actuatorReference;
component.ownerEntity = ownerEntity;
component.isOpen = isOpen;
}
addComponent(ActuatorComponentsLookup.Link, component);
return this;
}
use of ilargia.egdx.logicbricks.component.actuator.Link in project Entitas-Java by Rubentxu.
the class ActuatorEntity method replaceLink.
public ActuatorEntity replaceLink(String actuatorReference, int ownerEntity, boolean isOpen) {
Link component = (Link) recoverComponent(ActuatorComponentsLookup.Link);
if (component == null) {
component = new Link(actuatorReference, ownerEntity, isOpen);
} else {
component.actuatorReference = actuatorReference;
component.ownerEntity = ownerEntity;
component.isOpen = isOpen;
}
replaceComponent(ActuatorComponentsLookup.Link, component);
return this;
}
Aggregations