public static DistributedMatchEngine.Timestamp ConvertTimestamp(double timeInSeconds) { DistributedMatchEngine.Timestamp ts; int nanos; long sec = (long)(timeInSeconds); // Truncate. double remainder = timeInSeconds - (double)sec; nanos = (int)(remainder * 1e9); ts = new DistributedMatchEngine.Timestamp { seconds = sec.ToString(), nanos = nanos }; return(ts); }
public static DistributedMatchEngine.Timestamp ConvertTimestamp(double timeInMilliseconds) { DistributedMatchEngine.Timestamp ts; int nanos; long seconds = (int)timeInMilliseconds; // Truncate. double remainder = timeInMilliseconds - seconds; nanos = (int)(remainder * 1e9); // NOTE: GRPC's REST interface expects string for all UInt64 proto types. ts = new DistributedMatchEngine.Timestamp { seconds = seconds.ToString(), nanos = nanos }; return(ts); }
public static DistributedMatchEngine.Loc ConvertUnityLocationToDMELoc(UnityEngine.LocationInfo info) { DistributedMatchEngine.Timestamp ts = ConvertTimestamp(info.timestamp); Loc loc = new Loc { latitude = info.latitude, longitude = info.longitude, horizontal_accuracy = info.horizontalAccuracy, vertical_accuracy = info.verticalAccuracy, altitude = info.altitude, course = 0f, speed = 0f, timestamp = ts }; return(loc); }