42 qDebug(
"Active::ActFrequent called, check ShouldAct\
43 return value or add ActFrequent implementation.\nKind: %d, sub: %d.",
49 qDebug(
"Active::DoRareAction called, check ShouldAct and ActInner\
50 return values or add DoRareAction implementation.\nKind: %d, sub: %d.",
57 if ( inv ==
nullptr ) {
61 for (
int i=inv->
Size()-1; i; --i) {
62 const int number = inv->
Number(i);
63 if ( number == 0 )
continue;
65 if ( top_active ==
nullptr )
continue;
66 for (
int j=0; j<number; ++j) {
80 if (
shred !=
nullptr ) {
107 if (
shred ==
nullptr )
return;
109 const int bound = world->
GetBound();
123 if ( x_temp >= 0 )
TryDestroy( x_temp, y_temp, z_temp);
124 if ( (x_temp+=2) <= bound )
TryDestroy( x_temp, y_temp, z_temp);
125 if ( --y_temp >= 0 )
TryDestroy(--x_temp, y_temp, z_temp);
126 if ( (y_temp+=2) <= bound )
TryDestroy( x_temp, y_temp, z_temp);
146 switch ( dmg_kind ) {
167 Block(kind, sub, transp),
174 Block(str, kind, sub, transp),
182 const int bound = world->
GetBound();
184 int for_north = 0, for_west = 0;
185 const int y_start = qMax(
Y()-range, 0);
186 const int y_end = qMin(
Y()+range, bound);
187 const int x_end = qMin(
X()+range, bound);
188 bottom = qMax(
Z()-bottom, 0);
190 for (
int x=qMax(
X()-range, 0); x<=x_end; ++x)
191 for (
int y=y_start; y<=y_end; ++y) {
195 for (
int z=bottom; z<=top; ++z) {
196 const int attractive =
201 if ( y!=
Y() ) for_north += attractive/(
Y()-y);
202 if ( x!=
X() ) for_west += attractive/(
X()-x);
207 if ( qAbs(for_north)>calmness || qAbs(for_west)>calmness ) {
208 SetDir( ( qAbs(for_north)>qAbs(for_west) ) ?
210 ( ( for_west >0 ) ?
WEST :
EAST ) );
221 const int bound = world->
GetBound();
233 Active(kind, sub, transp),
241 Active(str, kind, sub, transp),
255 case WATER:
return tr(
"Snow");
256 case STONE:
return tr(
"Masonry");
265 const int SAFE_FALL_HEIGHT = 5;
267 const int dmg = (
fallHeight - SAFE_FALL_HEIGHT)*10;
void SendSignalAround(QString) const
push_reaction PushResult(dirs) const override
virtual void UpdateLightRadius()
static int CoordInShred(const int x)
Get local coordinate.
Shred * GetNearShred(Shred *, dirs dir) const
static QString SubNameUpper(int sub)
Returns translated substance name with first upper letter.
World provides global physics and shred connection.
virtual void Damage(int dmg, int dmg_kind)
virtual int DamageKind() const
void Move(dirs dir) override
Active * ActiveBlock() overridefinal
QString FullName() const override
bool Gravitate(int range, int down, int up, int calmness)
virtual Inventory * HasInventory()
Block * ShowBlock(int slot) const
void RemShining(Active *)
virtual int Attractive(int sub) const
virtual void ActFrequent()
virtual int LightRadius() const
static bool InBounds(int x, int y, int z)
Lowest nullstone and sky are not in bounds.
virtual int ShouldAct() const
void Shine(int x, int y, int z, int level)
If init is false, light will not spread from non-invisible blocks.
inner_actions
See Shred::PhysEventsRare() for details.
void ReceiveSignal(QString) override
Receive text signal.
Block * GetBlock(int x, int y, int z) const
virtual int DamageLevel() const
Provides declaration for class Inventory for freg.
Active(int sub, int id, int transp=UNDEF)
void DamageAround() const
void Unregister(Active *)
void TryDestroy(int x, int y, int z) const
Damages block and destroys it if it is broken.
Block * ShowBlockInSlot(int slot, int index) const
Don't move block shown by this function.
void SaveAttributes(QDataStream &out) const override
virtual inner_actions ActInner()
void DestroyAndReplace(int x, int y, int z)
Does not check target block durability.
virtual Active * ActiveBlock()
Provides block ability to contain other blocks inside.
void Damage(int dmg, int dmg_kind) override
Shred * GetShred(int i, int j) const
Falling * ShouldFall() overridefinal
bool DirectlyVisible(int x_from, int y_from, int z_from, int x_to, int y_to, int z_to) const
int Damage(int x, int y, int z, int level, int dmg_kind)
Returns damaged block result durability.
Block * GetBlock(const int x, const int y, const int z) const
void ReceivedText(const QString)
Falling(int sub, int id, int transp=UNDEF)
int GetDurability() const
virtual void DoRareAction()
void SetFalling(bool set)
void AddShining(Active *)
virtual void ReceiveSignal(QString)
Receive text signal.
Block without special physics and attributes.
virtual QString InvFullName(int num) const
bool IsSubAround(int sub) const
Returns true if there is at least 1 block of substance sub around.
void Move(dirs dir) override