diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-10 01:46:24 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-10 01:46:24 +0000 |
commit | d4f8d1c8fde01a58bc757b588c9850e69225bc24 (patch) | |
tree | 76b0ba82fca051d95a7570e13c9a58f648ed45bf | |
parent | 1a1842473c826f4cf327d336b30a1f874e0e470b (diff) |
Corrected a small bug in Entity::print(),
added nudge randomizer option.
-rw-r--r-- | src/core/entity.cc | 22 | ||||
-rw-r--r-- | src/core/entity.h | 3 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/core/entity.cc b/src/core/entity.cc index 5c1fe5c..7d538a0 100644 --- a/src/core/entity.cc +++ b/src/core/entity.cc @@ -291,7 +291,7 @@ void Entity::print() const con_print << " ^Nmodule type ^B" << moduletype() << std::endl; // print entity flags - con_print << " ^Nflags ^B"; + con_print << " ^Nflags ^B"; if (has_flag(NonSolid)) { con_print << " nonsolid"; } @@ -311,6 +311,9 @@ void Entity::print() const if (inventory()) { con_print << " ^Ninventory ^Byes" << std::endl; } + if (slots()) { + con_print << " ^Nslots ^Byes" << std::endl; + } if (faction()) { con_print << " ^Nfaction ^B" << faction()->label() << std::endl; } @@ -843,7 +846,7 @@ void EntityDynamic::set_state(int state) } } -void EntityDynamic::nudge() +void EntityDynamic::nudge(const bool randomize) { if (!zone()) { return; @@ -857,12 +860,15 @@ void EntityDynamic::nudge() const float r = radius() + other->radius(); if ( d < r ) { - // nudge into randomize direction - math::Axis nudge_axis(axis()); - nudge_axis.change_direction(math::randomf(60.0f) - 30.0f); - nudge_axis.change_pitch(math::randomf(60.0f) - 30.0f); - set_location(location() + nudge_axis.forward() * (r - d + 0.001f)); - + if (randomize) { + // nudge into randomize direction + math::Axis nudge_axis(axis()); + nudge_axis.change_direction(math::randomf(60.0f) - 30.0f); + nudge_axis.change_pitch(math::randomf(60.0f) - 30.0f); + set_location(location() + nudge_axis.forward() * (r - d + 0.001f)); + } else { + set_location(location() + axis().forward() * (r - d + 0.001f)); + } // restart search it = zone()->content().begin(); } diff --git a/src/core/entity.h b/src/core/entity.h index de4f210..f5a6d52 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -681,8 +681,9 @@ public: /** * @brief nudge the entity out of the radius of other entities in its current zune + * @param randomize if false, nudge according to axus.forward(), if false, nudge along a random axis */ - void nudge(); + void nudge(const bool randomize = true); /** * @brief physics collision callback |