コード例 #1
0
ファイル: Actor.cpp プロジェクト: jonmseaman/ProjectWolfGame
void Actor::takeTurn() {
  bool shouldAttack = hasValidTarget() && targetPtr != this && targetPtr->getIsLiving();

  // Aggressive, attacks whatever isn't itself.
  if (!shouldAttack) {
    cycleTarget();
    shouldAttack = hasValidTarget() && targetPtr != this && targetPtr->getIsLiving();
  }
  if (shouldAttack) {
    onAttack();
  }
}
コード例 #2
0
void SVGAnimateTransformElement::applyResultsToTarget()
{
    if (!hasValidTarget())
        return;
    // We accumulate to the target element transform list so there is not much to do here.
    SVGElement* targetElement = this->targetElement();
    if (!targetElement)
        return;

    if (RenderObject* renderer = targetElement->renderer()) {
        renderer->setNeedsTransformUpdate();
        RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
    }

    // ...except in case where we have additional instances in <use> trees.
    const HashSet<SVGElementInstance*>& instances = targetElement->instancesForElement();
    RefPtr<SVGTransformList> transformList = transformListFor(targetElement);
    const HashSet<SVGElementInstance*>::const_iterator end = instances.end();
    for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) {
        SVGElement* shadowTreeElement = (*it)->shadowTreeElement();
        ASSERT(shadowTreeElement);
        if (shadowTreeElement->isStyledTransformable())
            static_cast<SVGStyledTransformableElement*>(shadowTreeElement)->setTransformBaseValue(transformList.get());
        else if (shadowTreeElement->hasTagName(SVGNames::textTag))
            static_cast<SVGTextElement*>(shadowTreeElement)->setTransformBaseValue(transformList.get());
        else if (shadowTreeElement->hasTagName(SVGNames::linearGradientTag) || shadowTreeElement->hasTagName(SVGNames::radialGradientTag))
            static_cast<SVGGradientElement*>(shadowTreeElement)->setGradientTransformBaseValue(transformList.get());
        if (RenderObject* renderer = shadowTreeElement->renderer()) {
            renderer->setNeedsTransformUpdate();
            RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer);
        }
    }
}
コード例 #3
0
void SVGAnimateTransformElement::resetToBaseValue(const String& baseValue)
{
    if (!hasValidTarget())
        return;
    if (baseValue.isEmpty()) {
        ExceptionCode ec;
        RefPtr<SVGTransformList> list = transformListFor(targetElement());
        list->clear(ec);
    } else
        targetElement()->setAttribute(SVGNames::transformAttr, baseValue);
}
コード例 #4
0
ファイル: SVGAnimationElement.cpp プロジェクト: KDE/khtml
void SVGAnimationElement::setTargetAttributeAnimatedValue(const String &value)
{
    if (!hasValidTarget()) {
        return;
    }
    SVGElement *target = targetElement();
    String attributeName = this->attributeName();
    if (!target || attributeName.isEmpty() || value.isNull()) {
        return;
    }

    // We don't want the instance tree to get rebuild. Instances are updated in the loop below.
    if (target->isStyled()) {
        static_cast<SVGStyledElement *>(target)->setInstanceUpdatesBlocked(true);
    }

    ExceptionCode ec;
    bool isCSS = targetAttributeIsCSS();
    if (isCSS) {
        // FIXME: This should set the override style, not the inline style.
        // Sadly override styles are not yet implemented.
        target->style()->setProperty(attributeName, value, "", ec);
    } else {
        // FIXME: This should set the 'presentation' value, not the actual
        // attribute value. Whatever that means in practice.
        target->setAttribute(attributeName, value, ec);
    }

    if (target->isStyled()) {
        static_cast<SVGStyledElement *>(target)->setInstanceUpdatesBlocked(false);
    }

    // If the target element is used in an <use> instance tree, update that as well.
    HashSet<SVGElementInstance *> *instances = document()->accessSVGExtensions()->instancesForElement(target);
    if (!instances) {
        return;
    }
    HashSet<SVGElementInstance *>::iterator end = instances->end();
    for (HashSet<SVGElementInstance *>::iterator it = instances->begin(); it != end; ++it) {
        SVGElement *shadowTreeElement = (*it)->shadowTreeElement();
        ASSERT(shadowTreeElement);
        if (isCSS) {
            shadowTreeElement->style()->setProperty(attributeName, value, "", ec);
        } else {
            shadowTreeElement->setAttribute(attributeName, value, ec);
        }
        (*it)->correspondingUseElement()->setChanged();
    }
}
コード例 #5
0
void SVGAnimateTransformElement::resetToBaseValue(const String& baseValue)
{
    if (!hasValidTarget())
        return;

    if (targetElement()->hasTagName(SVGNames::linearGradientTag) || targetElement()->hasTagName(SVGNames::radialGradientTag)) {
        targetElement()->setAttribute(SVGNames::gradientTransformAttr, baseValue.isEmpty() ? "matrix(1 0 0 1 0 0)" : baseValue);
        return;
    }

    if (baseValue.isEmpty()) {
        ExceptionCode ec;
        RefPtr<SVGTransformList> list = transformListFor(targetElement());
        list->clear(ec);
    } else
        targetElement()->setAttribute(SVGNames::transformAttr, baseValue);
}
コード例 #6
0
void SVGAnimateTransformElement::calculateAnimatedValue(float percentage, unsigned repeat, SVGSMILElement* resultElement)
{
    if (!hasValidTarget())
        return;
    SVGElement* targetElement = resultElement->targetElement();
    RefPtr<SVGTransformList> transformList = transformListFor(targetElement);
    ASSERT(transformList);

    ExceptionCode ec;
    if (!isAdditive())
        transformList->clear(ec);
    if (isAccumulated() && repeat) {
        SVGTransform accumulatedTransform = SVGTransformDistance(m_fromTransform, m_toTransform).scaledDistance(repeat).addToSVGTransform(SVGTransform());
        transformList->appendItem(accumulatedTransform, ec);
    }
    SVGTransform transform = SVGTransformDistance(m_fromTransform, m_toTransform).scaledDistance(percentage).addToSVGTransform(m_fromTransform);
    transformList->appendItem(transform, ec);
}
コード例 #7
0
ファイル: SVGAnimationElement.cpp プロジェクト: KDE/khtml
void SVGAnimationElement::startedActiveInterval()
{
    m_animationValid = false;

    if (!hasValidTarget()) {
        return;
    }

    AnimationMode animationMode = this->animationMode();
    if (animationMode == NoAnimation) {
        return;
    }
    if (animationMode == FromToAnimation) {
        m_animationValid = calculateFromAndToValues(fromValue(), toValue());
    } else if (animationMode == ToAnimation) {
        // For to-animations the from value is the current accumulated value from lower priority animations.
        // The value is not static and is determined during the animation.
        m_animationValid = calculateFromAndToValues(String(), toValue());
    } else if (animationMode == FromByAnimation) {
        m_animationValid = calculateFromAndByValues(fromValue(), byValue());
    } else if (animationMode == ByAnimation) {
        m_animationValid = calculateFromAndByValues(String(), byValue());
    } else if (animationMode == ValuesAnimation) {
        CalcMode calcMode = this->calcMode();
        m_animationValid = m_values.size() > 1
                           && (calcMode == CalcModePaced || !hasAttribute(SVGNames::keyTimesAttr) || hasAttribute(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size()))
                           && (calcMode == CalcModeDiscrete || !m_keyTimes.size() || m_keyTimes.last() == 1.0)
                           && (calcMode != CalcModeSpline || (m_keySplines.size() && (m_keySplines.size() == m_values.size() - 1) || m_keySplines.size() == m_keyPoints.size() - 1))
                           && (!hasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size()));
        if (calcMode == CalcModePaced && m_animationValid) {
            calculateKeyTimesForCalcModePaced();
        }
    } else if (animationMode == PathAnimation) {
        m_animationValid = calcMode() == CalcModePaced || !hasAttribute(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());
    }
}
コード例 #8
0
void SVGAnimateTransformElement::applyResultsToTarget()
{
    if (!hasValidTarget())
        return;
    // We accumulate to the target element transform list so there is not much to do here.
    SVGElement* targetElement = this->targetElement();
    if (targetElement->renderer())
        targetElement->renderer()->setNeedsLayout(true);
    
    // ...except in case where we have additional instances in <use> trees.
    const HashSet<SVGElementInstance*>& instances = targetElement->instancesForElement();
    RefPtr<SVGTransformList> transformList = transformListFor(targetElement);
    const HashSet<SVGElementInstance*>::const_iterator end = instances.end();
    for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) {
        SVGElement* shadowTreeElement = (*it)->shadowTreeElement();
        ASSERT(shadowTreeElement);
        if (shadowTreeElement->isStyledTransformable())
            static_cast<SVGStyledTransformableElement*>(shadowTreeElement)->setTransformBaseValue(transformList.get());
        else if (shadowTreeElement->hasTagName(SVGNames::textTag))
            static_cast<SVGTextElement*>(shadowTreeElement)->setTransformBaseValue(transformList.get());
        if (shadowTreeElement->renderer())
            shadowTreeElement->renderer()->setNeedsLayout(true);
    }
}