double gregorianDateTimeToMS(VM& vm, const GregorianDateTime& t, double milliSeconds, WTF::TimeType inputTimeType)
{
    double day = dateToDaysFrom1970(t.year(), t.month(), t.monthDay());
    double ms = timeToMS(t.hour(), t.minute(), t.second(), milliSeconds);
    double localTimeResult = (day * WTF::msPerDay) + ms;
    double localToUTCTimeOffset = inputTimeType == LocalTime
        ? localTimeOffset(vm, localTimeResult, inputTimeType).offset : 0;

    return localTimeResult - localToUTCTimeOffset;
}
Exemple #2
0
double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
{
    double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay);
    double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
    double result = (day * WTF::msPerDay) + ms;

    if (!inputIsUTC)
        result -= localTimeOffset(exec, result).offset;

    return result;
}
Exemple #3
0
double gregorianDateTimeToMS(const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
{
    int day = dateToDayInYear(t.year + 1900, t.month, t.monthDay);
    double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
    double result = (day * msPerDay) + ms;

    if (!inputIsUTC) { // convert to UTC
        result -= getUTCOffset();       
        result -= getDSTOffset(result);
    }

    return result;
}
Exemple #4
0
double gregorianDateTimeToMS(ExecState* exec, const GregorianDateTime& t, double milliSeconds, bool inputIsUTC)
{
    double day = dateToDaysFrom1970(t.year + 1900, t.month, t.monthDay);
    double ms = timeToMS(t.hour, t.minute, t.second, milliSeconds);
    double result = (day * WTF::msPerDay) + ms;

    if (!inputIsUTC) { // convert to UTC
        double utcOffset = getUTCOffset(exec);
        result -= utcOffset;
        result -= getDSTOffset(exec, result, utcOffset);
    }

    return result;
}
void ZRUser01(float *myState, float *otherState, float time)
{
//BEGIN::PROC::ZRUser
float opulens[3] = {0.0, -0.6, 0.0};
float Laser[3] = {0.4, 0.0, 0.0};
float shield[3] = {0.0, 0.4, 0.0};
float disrupt[3] = {0.0,0.2,0.0};
float zero[3] = {0.0, 0.0, 0.0};
float difference[3];
float facing[3];
float Asteroid[3] = {0.0, -0.6, 0.0};
int recieved;


switch((int)time)
{
    case 0:
        SphereNumber = !!(myState[0] < 0) + 1;
        Station[0] = (SphereNumber == 1) ? 0.6 : -0.6; //station closer to where you started
        break;
    case 30:
        getUp = (otherState[1] <= 0);
        break;
    case 61:
    case 66:
        Spin = PisRevolving(otherState) ? 1 : 0;
        break;
    case 75: if(PinAsteroid(otherState) == 1) asteroid = 1;
}


Laser[0] = ((SphereNumber == 1) - (PotherHasLaser() == SphereNumber)) ? 0.4 : -0.4;

recieved = (int)PgetMessage();
switch(recieved)
{
    case 6:
        if(!(Station[0] < 0.0) && switchedStation++ < 3)
            Station[0] = -0.6;
        break;
    case 7:
        if(!(Station[0] > 0.0) && switchedStation++ < 3)
            Station[0] = 0.6;
        break;
    case 2:
    case 3:
        if(time < 45)
        asteroid = 1;
        break;
    case 4:
    case 5:
        if(time < 45)
        asteroid = 0;
        break;
}


if(time <= 120)
PsendMessage(4 - 2*asteroid + (Spin == 0));
else
PsendMessage((Station[0] < 0) + 6);

Asteroid[1] = asteroid ? -0.6 : 0.6;


switch(state)
{
    case 0:
        ZRSetPositionTarget(Laser);
        shoot(myState, opulens, 0);
        if(PhaveLaser() || PgetPhase() == 2)
            state = 1;
        break;
        
    case 1:
        if(!getUp) {
            shield[1] = .3;
            disrupt[1] = .3;
        }
        ZRSetPositionTarget(disrupt);
        shoot(myState, opulens, 0);
        if(PotherDisruptorUpgraded() || PdisruptorUpgraded())
            state = 2;
        if(PgetPhase() == 2)
            state = 3;
        break;
        
    case 2:
        ZRSetPositionTarget(shield);
        shoot(myState, opulens, 0);
        if(PotherHasShield() || PhaveShield() || PgetPhase() == 2)
            state = 3;
        break;
    case 3:
        if(PiceHits() < 15 && !asteroid)
            shoot(myState, opulens, (PgetPhase() > 1));
        if(!(PiceMelted()) && asteroid)
        {
            mathVecSubtract(difference, myState, opulens, 3);
            if(mathVecMagnitude(difference, 3) > .8)
                ZRSetPositionTarget(opulens);
            else if(!Spin)
                ZRSetVelocityTarget(zero);
            shoot(myState, opulens, (PgetPhase() > 1));
            return;
        }
        if(Spin){
            ZRSetPositionTarget(Asteroid);
            spin(myState);
        }
        else
            orbit(myState, Asteroid, Station[0] == -0.6);
        if((!Spin && (time + timeToMS(myState, Station) >= 165)) || (Spin && (time >= 156)))
            state = 4;
        break;
    default:
        leaveOrbit(myState, Asteroid, Station);
        mathVecSubtract(facing, otherState, myState, 3);
        mathVecNormalize(facing, 3);
        ZRSetAttitudeTarget(facing);
        if (acos(mathVecInner(&myState[6], facing, 3) / mathVecMagnitude(&myState[6], 3)) < (0.1))
            Ptractor();
        break;
}
//END::PROC::ZRUser
}
void ZRUser01(float *myState, float *otherState, float time)
{
//BEGIN::PROC::ZRUser
float opulens[3] = {0.0, -0.6, 0.0};
float Laser[3] = {0.4, 0.0, 0.0};
float shield[3] = {0.0, 0.4, 0.0};
float zero[3] = {0.0, 0.0, 0.0};
float difference[3];
float Asteroid[3] = {0.0, -0.6, 0.0};
float Station[3] = {0.0, 0.0, 0.0};


switch((int)time)
{
    case 0:
        SphereNumber = !!(myState[0] < 0) + 1;
        break;
    case 30:
        getShield = (otherState[1] <= 0);
        break;
    case 61:
        asteroid = (PinAsteroid(otherState) == 1) ? 1 : 0;
        break;
    case 90:
        asteroid = (PisRevolving(otherState) == 2 && !asteroid) ? 1 : asteroid;
        break;
}


Station[0] = (SphereNumber == 1) ? 0.6 : -0.6; //station closer to where you started
Asteroid[1] = asteroid ? -0.6 : 0.6;
Laser[0] = ((SphereNumber == 1) - (PotherHasLaser() == SphereNumber)) ? 0.4 : -0.4;


switch(state)
{
    case 0:
        ZRSetPositionTarget(Laser);
        shoot(myState, opulens, 0);
        if(PhaveLaser() || PgetPhase() == 2)
            state = 1;
        break;
        
    case 1:
        if(!getShield)
            shield[1] = .3;
        ZRSetPositionTarget(shield);
        shoot(myState, opulens, 0);
        if(PotherHasShield() || PhaveShield() || PgetPhase() == 2)
            state = 2;
        break;
        
    case 2:
        if(PiceHits() < 14 && !asteroid)
            shoot(myState, opulens, (PgetPhase() > 1));
        if(!(PiceMelted()) && asteroid)
        {
            mathVecSubtract(difference, myState, opulens, 3);
            if(mathVecMagnitude(difference, 3) > .8)
                ZRSetPositionTarget(opulens);
            else
                ZRSetVelocityTarget(zero);
            shoot(myState, opulens, (PgetPhase() > 1));
            return;
        }
        orbit(myState, Asteroid, Station[0] == -0.6);
        if(time + timeToMS(myState, Station) >= 165)
            state = 3;
        break;
        
    default:
        ZRSetPositionTarget(Station);
        break;
}
//END::PROC::ZRUser
}