예제 #1
0
void
System::ExecFrame(double seconds)
{
    if (seconds < 0.01)
    seconds = 0.01;

    STATUS s = DESTROYED;

    if (availability > 0.99)
    s = NOMINAL;
    else if (availability > crit_level)
    s = DEGRADED;
    else
    s = CRITICAL;

    bool repair = false;

    if (components.size() > 0) {
        ListIter<Component> comp = components;
        while (++comp) {
            if (comp->Status() > Component::NOMINAL) {
                repair = true;
                break;
            }
        }
    }

    if (repair) {
        Repair();
    }

    else {
        if (status != s) {
            status = s;
            NetUtil::SendSysStatus(ship, this);
        }

        // collateral damage due to unsafe operation:
        if (power_on && power_level > safety) {
            safety_overload += (float) seconds;

            // inflict some damage now:
            if (safety_overload > 60) {
                safety_overload -= (float) (rand() / (1000 * (power_level-safety)));
                ApplyDamage(15);

                NetUtil::SendSysStatus(ship, this);
            }
        }

        else if (safety_overload > 0) {
            safety_overload -= (float) seconds;
        }
    }
}
예제 #2
0
void
System::ExecMaintFrame(double seconds)
{
    if (components.size() > 0) {
        ListIter<Component> comp = components;
        while (++comp) {
            if (comp->Status() > Component::NOMINAL) {
                comp->ExecMaintFrame(seconds);
            }
        }
    }
}