v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
101
source/game/interfaces/StarTileEntity.cpp
Normal file
101
source/game/interfaces/StarTileEntity.cpp
Normal file
|
@ -0,0 +1,101 @@
|
|||
#include "StarTileEntity.hpp"
|
||||
#include "StarWorld.hpp"
|
||||
#include "StarRoot.hpp"
|
||||
#include "StarLiquidsDatabase.hpp"
|
||||
#include "StarDataStreamExtra.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
DataStream& operator<<(DataStream& ds, MaterialSpace const& materialSpace) {
|
||||
ds.write(materialSpace.space);
|
||||
ds.write(materialSpace.material);
|
||||
return ds;
|
||||
}
|
||||
|
||||
DataStream& operator>>(DataStream& ds, MaterialSpace& materialSpace) {
|
||||
ds.read(materialSpace.space);
|
||||
ds.read(materialSpace.material);
|
||||
return ds;
|
||||
}
|
||||
|
||||
TileEntity::TileEntity() {
|
||||
setPersistent(true);
|
||||
}
|
||||
|
||||
Vec2F TileEntity::position() const {
|
||||
return Vec2F(tilePosition());
|
||||
}
|
||||
|
||||
List<Vec2I> TileEntity::spaces() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
List<Vec2I> TileEntity::roots() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
List<MaterialSpace> TileEntity::materialSpaces() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
bool TileEntity::damageTiles(List<Vec2I> const&, Vec2F const&, TileDamage const&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TileEntity::isInteractive() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
List<Vec2I> TileEntity::interactiveSpaces() const {
|
||||
return spaces();
|
||||
}
|
||||
|
||||
InteractAction TileEntity::interact(InteractRequest const& request) {
|
||||
_unused(request);
|
||||
return InteractAction();
|
||||
}
|
||||
|
||||
List<QuestArcDescriptor> TileEntity::offeredQuests() const {
|
||||
return {};
|
||||
}
|
||||
|
||||
StringSet TileEntity::turnInQuests() const {
|
||||
return StringSet();
|
||||
}
|
||||
|
||||
Vec2F TileEntity::questIndicatorPosition() const {
|
||||
return position();
|
||||
}
|
||||
|
||||
bool TileEntity::anySpacesOccupied(List<Vec2I> const& spaces) const {
|
||||
Vec2I tp = tilePosition();
|
||||
for (auto pos : spaces) {
|
||||
pos += tp;
|
||||
if (isConnectableMaterial(world()->material(pos, TileLayer::Foreground)))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool TileEntity::allSpacesOccupied(List<Vec2I> const& spaces) const {
|
||||
Vec2I tp = tilePosition();
|
||||
for (auto pos : spaces) {
|
||||
pos += tp;
|
||||
if (!isConnectableMaterial(world()->material(pos, TileLayer::Foreground)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float TileEntity::spacesLiquidFillLevel(List<Vec2I> const& relativeSpaces) const {
|
||||
float total = 0.0f;
|
||||
for (auto pos : relativeSpaces) {
|
||||
pos += tilePosition();
|
||||
total += world()->liquidLevel(pos).level;
|
||||
}
|
||||
return total / relativeSpaces.size();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue