VoltAir
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Groups Pages
Signals | Public Member Functions | Properties | List of all members
MagneticAttractorLogic Class Reference

Logic which pulls its parent actor in the direction of magnetic Bodys and also attracting them towards our Body. More...

Inheritance diagram for MagneticAttractorLogic:
Logic QObject

Signals

void hasTargetInRangeChanged ()
 Emitted when hasTargetInRange changed. More...
 
void onChanged ()
 Emitted when on changed. More...
 
void strengthChanged ()
 Emitted when strength changed. More...
 
void softnessChanged ()
 Emitted when softness changed. More...
 
void sensorBodyChanged ()
 Emitted when sensorBody changed. More...
 
void activeSoundChanged ()
 Emitted when activeSound changed. More...
 
- Signals inherited from Logic
void activeChanged ()
 Emitted when active changes. More...
 

Public Member Functions

 MagneticAttractorLogic ()
 Construct a MagneticAttractorLogic. More...
 
bool hasTargetInRange () const
 Returns hasTargetInRange. More...
 
void setHasTargetInRange (bool value)
 Sets hasTargetInRange. More...
 
bool isOn () const
 Returns on. More...
 
void setOn (bool value)
 Sets on. More...
 
float getStrength () const
 Returns strength. More...
 
void setStrength (float value)
 Sets strength. More...
 
float getSoftness () const
 Returns softness. More...
 
void setSoftness (float value)
 Sets softness. More...
 
BodygetSensorBody () const
 Returns sensorBody. More...
 
void setSensorBody (Body *value)
 Sets sensorBody. More...
 
const QStringgetActiveSound () const
 Returns activeSound. More...
 
void setActiveSound (const QString &value)
 Sets activeSound. More...
 
Q_INVOKABLE QPointF getCurrentMagneticForce () const
 Returns the sum of magnetic forces currently being exerted by this magnet. More...
 
virtual void init () override
 Implements Logic::init() to perform additional initialization. More...
 
virtual void update () override
 Computes and exerts forces on magnetic objects, if on is true. More...
 
- Public Member Functions inherited from Logic
 Logic (QObject *parent=nullptr)
 Constructs a Logic. More...
 
ActorgetActor () const
 Returns actor. More...
 
bool isActive () const
 Returns active. More...
 
void setActive (bool value)
 Sets active. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
virtual const QMetaObjectmetaObject () const
 
QString objectName () const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const
 
bool blockSignals (bool block)
 
QThreadthread () const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QString &name, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegExp &regExp, QFlags< Qt::FindChildOption > options) const
 
QList< T > findChildren (const QRegularExpression &re, QFlags< Qt::FindChildOption > options) const
 
const QObjectList & children () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const
 
bool disconnect (const QObject *receiver, const char *method) const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const
 
bool inherits (const char *className) const
 
void deleteLater ()
 

Properties

bool hasTargetInRange
 Whether or not a magnetic Body is within range of this magnet. More...
 
bool on
 Whether or not this magnet is on, and should attract magnetic Bodys. More...
 
float strength
 Overall strength of the magnet. More...
 
float softness
 Amount of softness (linearity) of the magnet's attraction. More...
 
Body sensorBody
 Body to use as a sensor for this magnet. More...
 
QString activeSound
 Path to sound to play looped while the magnet is on. More...
 
- Properties inherited from Logic
Actor actor
 Parent actor that is affected by this Logic's behavior. More...
 
bool active
 Whether or not Engine calls update() on this Logic during the Engine::LOGICS_PHASE. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

Logic which pulls its parent actor in the direction of magnetic Bodys and also attracting them towards our Body.

The magnet is controlled by its on, strength, and softness properties. See these properties for their behavior. The magnet can also use a separate sensor Body. Bodys in contact with that sensor Body will be considered in range of the magnet, but the attractive force will be applied to the magnet's parent actor's Body.

While affected by the pull of a non-dynamic magnetic Body, the parent actor will ignore the world's gravity. Gravity will be enabled when magnetism is no longer pulling on the actor.

A rotation offset also provides a way for the parent actor to smoothly orient its Graphics towards the most potent force affecting it.

Constructor & Destructor Documentation

MagneticAttractorLogic::MagneticAttractorLogic ( )

Construct a MagneticAttractorLogic.

Member Function Documentation

void MagneticAttractorLogic::activeSoundChanged ( )
signal

Emitted when activeSound changed.

const QString& MagneticAttractorLogic::getActiveSound ( ) const
inline

Returns activeSound.

Q_INVOKABLE QPointF MagneticAttractorLogic::getCurrentMagneticForce ( ) const

Returns the sum of magnetic forces currently being exerted by this magnet.

Body* MagneticAttractorLogic::getSensorBody ( ) const
inline

Returns sensorBody.

float MagneticAttractorLogic::getSoftness ( ) const
inline

Returns softness.

float MagneticAttractorLogic::getStrength ( ) const
inline

Returns strength.

bool MagneticAttractorLogic::hasTargetInRange ( ) const
inline

Returns hasTargetInRange.

void MagneticAttractorLogic::hasTargetInRangeChanged ( )
signal

Emitted when hasTargetInRange changed.

virtual void MagneticAttractorLogic::init ( )
overridevirtual

Implements Logic::init() to perform additional initialization.

Reimplemented from Logic.

bool MagneticAttractorLogic::isOn ( ) const
inline

Returns on.

void MagneticAttractorLogic::onChanged ( )
signal

Emitted when on changed.

void MagneticAttractorLogic::sensorBodyChanged ( )
signal

Emitted when sensorBody changed.

void MagneticAttractorLogic::setActiveSound ( const QString value)

Sets activeSound.

Parameters
valueQString to set activeSound to
void MagneticAttractorLogic::setHasTargetInRange ( bool  value)

Sets hasTargetInRange.

Parameters
valueBoolean to set hasTargetInRange to
void MagneticAttractorLogic::setOn ( bool  value)

Sets on.

Parameters
valueBoolean to set on to
void MagneticAttractorLogic::setSensorBody ( Body value)

Sets sensorBody.

Parameters
valueBody to set sensorBody to
void MagneticAttractorLogic::setSoftness ( float  value)

Sets softness.

Parameters
valueFloat to set softness to
void MagneticAttractorLogic::setStrength ( float  value)

Sets strength.

Parameters
valueFloat to set strength to
void MagneticAttractorLogic::softnessChanged ( )
signal

Emitted when softness changed.

void MagneticAttractorLogic::strengthChanged ( )
signal

Emitted when strength changed.

virtual void MagneticAttractorLogic::update ( )
overridevirtual

Computes and exerts forces on magnetic objects, if on is true.

Reimplemented from Logic.

Property Documentation

QString MagneticAttractorLogic::activeSound
readwrite

Path to sound to play looped while the magnet is on.

bool MagneticAttractorLogic::hasTargetInRange
readwrite

Whether or not a magnetic Body is within range of this magnet.

A Body is in range if it is in contact with this actor's Body, or sensorBody if it is set.

bool MagneticAttractorLogic::on
readwrite

Whether or not this magnet is on, and should attract magnetic Bodys.

This should be set in response to player input to turn the magnet on and off. This property is distinct from the Logic::active property.

Body MagneticAttractorLogic::sensorBody
readwrite

Body to use as a sensor for this magnet.

If this is nullptr, this Logic's actor's Body will be used instead. Bodys in contact with the current sensor Body will be considered within range of this magnet.

float MagneticAttractorLogic::softness
readwrite

Amount of softness (linearity) of the magnet's attraction.

This should be set to a value between 0.0f and 1.0f. 0.0f applies inverse square distance attenuation, which is physically real. 1.0f applies inverse linear distance attenuation, which feels slightly softer and less jarring but less physically accurate.

float MagneticAttractorLogic::strength
readwrite

Overall strength of the magnet.