-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose settlement events (#31)
* expose set and buffer block events * expose request raster target event * create new vector references in block event constructors * don't expose internal vector references
- Loading branch information
Showing
10 changed files
with
419 additions
and
50 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
52 changes: 52 additions & 0 deletions
52
src/main/java/org/terasology/dynamicCities/construction/events/BufferBlockEvent.java
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,52 @@ | ||
/* | ||
* Copyright 2017 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.dynamicCities.construction.events; | ||
|
||
import org.terasology.entitySystem.event.ConsumableEvent; | ||
import org.terasology.math.geom.Vector3i; | ||
import org.terasology.world.block.Block; | ||
|
||
/** | ||
* Sent when a building has been rasterized and a given block should be buffered | ||
*/ | ||
public class BufferBlockEvent implements ConsumableEvent { | ||
public final Block block; | ||
private Vector3i pos = Vector3i.zero(); | ||
private boolean consumed; | ||
|
||
public BufferBlockEvent(Vector3i pos, Block block) { | ||
this.pos = new Vector3i(pos); | ||
this.block = block; | ||
} | ||
|
||
@Override | ||
public boolean isConsumed() { | ||
return consumed; | ||
} | ||
|
||
@Override | ||
public void consume() { | ||
consumed = true; | ||
} | ||
|
||
public Vector3i getPos() { | ||
return new Vector3i(pos); | ||
} | ||
|
||
public void setPos(Vector3i pos) { | ||
this.pos.set(pos); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/org/terasology/dynamicCities/construction/events/RequestRasterTargetEvent.java
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,46 @@ | ||
/* | ||
* Copyright 2017 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.dynamicCities.construction.events; | ||
|
||
import org.terasology.cities.BlockTheme; | ||
import org.terasology.cities.raster.RasterTarget; | ||
import org.terasology.entitySystem.event.ConsumableEvent; | ||
import org.terasology.math.geom.Rect2i; | ||
|
||
/** | ||
* Emitted when DynamicCities needs a {@link org.terasology.cities.raster.RasterTarget} for rasterizing buildings | ||
*/ | ||
public class RequestRasterTargetEvent implements ConsumableEvent { | ||
public RasterTarget rasterTarget; | ||
public BlockTheme theme; | ||
public Rect2i shape; | ||
private boolean consumed; | ||
|
||
public RequestRasterTargetEvent(BlockTheme theme, Rect2i shape) { | ||
this.shape = shape; | ||
this.theme = theme; | ||
} | ||
|
||
@Override | ||
public boolean isConsumed() { | ||
return consumed; | ||
} | ||
|
||
@Override | ||
public void consume() { | ||
consumed = true; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/org/terasology/dynamicCities/construction/events/SetBlockEvent.java
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,52 @@ | ||
/* | ||
* Copyright 2017 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.dynamicCities.construction.events; | ||
|
||
import org.terasology.entitySystem.event.ConsumableEvent; | ||
import org.terasology.math.geom.Vector3i; | ||
import org.terasology.world.block.Block; | ||
|
||
/** | ||
* Sent when a building has been rasterized and a given block should be set directly | ||
*/ | ||
public class SetBlockEvent implements ConsumableEvent { | ||
private boolean consumed; | ||
public Block block; | ||
private Vector3i pos; | ||
|
||
public SetBlockEvent(Vector3i pos, Block block) { | ||
this.pos = new Vector3i(pos); | ||
this.block = block; | ||
} | ||
|
||
@Override | ||
public boolean isConsumed() { | ||
return consumed; | ||
} | ||
|
||
@Override | ||
public void consume() { | ||
consumed = true; | ||
} | ||
|
||
public Vector3i getPos() { | ||
return new Vector3i(pos); | ||
} | ||
|
||
public void setPos(Vector3i pos) { | ||
this.pos.set(pos); | ||
} | ||
} |
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.