improve applyTileModifications to be more aggressive
This commit is contained in:
parent
7860262a3b
commit
156c243360
@ -324,19 +324,30 @@ TileModificationList WorldClient::applyTileModifications(TileModificationList co
|
||||
|
||||
// thanks to new prediction: do each one by one so that previous modifications affect placeability
|
||||
|
||||
TileModificationList success;
|
||||
TileModificationList failures;
|
||||
for (auto const& pair : modificationList) {
|
||||
if (!isTileProtected(pair.first)) {
|
||||
auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction);
|
||||
TileModificationList success, failures, temp;
|
||||
TileModificationList const* list = &modificationList;
|
||||
|
||||
if (result.first) {
|
||||
informTilePrediction(pair.first, pair.second);
|
||||
success.append(pair);
|
||||
continue;
|
||||
while (true) {
|
||||
bool yay = false;
|
||||
for (size_t i = 0; i != list->size(); ++i) {
|
||||
auto& pair = list->at(i);
|
||||
if (!isTileProtected(pair.first)) {
|
||||
auto result = WorldImpl::validateTileModification(m_entityMap, pair.first, pair.second, allowEntityOverlap, m_tileGetterFunction);
|
||||
|
||||
if (result.first) {
|
||||
informTilePrediction(pair.first, pair.second);
|
||||
success.append(pair);
|
||||
yay = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
failures.append(pair);
|
||||
}
|
||||
failures.append(pair);
|
||||
if (yay) {
|
||||
list = &(temp = move(failures));
|
||||
continue;
|
||||
}
|
||||
else break;
|
||||
}
|
||||
|
||||
if (!success.empty())
|
||||
|
@ -103,9 +103,10 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {
|
||||
if (*m_lastAimPosition != aimPosition) {
|
||||
diff = geo.diff(*m_lastAimPosition, aimPosition);
|
||||
float magnitude = diff.magnitude();
|
||||
if (magnitude > 32) {
|
||||
m_lastAimPosition = aimPosition + diff.normalized() * 32;
|
||||
magnitude = 32;
|
||||
float limit = max(4.f, 64.f / radius);
|
||||
if (magnitude > limit) {
|
||||
m_lastAimPosition = aimPosition + diff.normalized() * limit;
|
||||
magnitude = limit;
|
||||
}
|
||||
|
||||
steps = (int)ceil(magnitude * (Constants::pi / 2));
|
||||
@ -133,8 +134,8 @@ void MaterialItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {
|
||||
if (!fail) {
|
||||
auto sound = Random::randValueFrom(m_placeSounds, "");
|
||||
if (total && !sound.empty()) {
|
||||
float intensity = clamp((float)total / 20, 0.0f, 1.0f);
|
||||
owner()->addSound(sound, 1.0f + intensity, (1.25f - intensity * 0.75f) * Random::randf(0.9f, 1.1f));
|
||||
float intensity = clamp((float)total / 96, 0.0f, 1.0f);
|
||||
owner()->addSound(sound, 1.0f + intensity, (1.125f - intensity * 0.75f) * Random::randf(0.9f, 1.1f));
|
||||
}
|
||||
FireableItem::fire(mode, shifting, edgeTriggered);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user