bool ValueSuffixDisplayDelegate::fromText(const juce::String& inText,
                                              float& outValue) const
    {
        char buffer[128];
        std::memset(buffer, 0, 128);
        std::strncpy(buffer, inText.toUTF8(), 128);

        char* temp = buffer;
        while ((temp = std::strchr(temp, ',')) != 0)
        {
            *temp++ = '.';
        }

        float factor = 1.;
        if (std::strchr(buffer, 'K') != 0 || std::strchr(buffer, 'k') != 0)
        {
            factor = 1000.;
        }

        float plainValue;
        if (sscanf(buffer, "%g %*s", &plainValue) == 1)
        {
            outValue = ranged(0.f, 1.f, mTaper->getNormalized(factor * plainValue));
            return true;
        }
        return false;
    }
Exemplo n.º 2
0
void Actor::die() {
    
    // any on-death actions should happen here.
    // class removal/cleanup/GC should happen at a higher level
    
    
    static ActorEvent ae;
    ae.a = this;
    ae.type = ActorEvent::DEATH_EVENT;
    
    ofNotifyEvent(ActorEvent::actorEvent, ae);
    
    
    
    // TODO:remove all items in possesion

    Weapon * w = melee();
    if (w!=NULL) {
        delete w;
    };
    
    w = offHand();
    if (w!=NULL) {
        delete w;
    };
    
    w = ranged();
    if (w!=NULL) {
        delete w;
    };
    
    delete this;
    
   
}
Exemplo n.º 3
0
Weapon * Actor::activeWeapon() {
    if (weaponSet==0) {
        return melee();
    } else {
        return ranged();
    }
    return NULL;
}
Exemplo n.º 4
0
bool Actor::tooFarForRanged() {
    if (target==NULL) return false;
    
    Weapon * w = ranged();
    
    if (w!=NULL) {
        return target->getPos().distance(getPos()) > w->data.range / FEET_PER_TILE;
    }
    return true;
    
}
 float LogParameterTaper::getNormalized(float inPlainValue) const
 {
     const float val = ranged(mMinValue, mMinValue + mFullRange, inPlainValue);
     const float res = std::pow((val - mMinValue) / mFullRange, mNormalizeFactor);
     return mInvert ? 1.f - res : res;
 }