Ejemplo n.º 1
0
 public LastSeen(Builder_LastSeen builder)
 {
     if (!MyAPIGateway.Entities.TryGetEntityById(builder.EntityId, out this.Entity))
     {
         (new Logger(GetType().Name)).alwaysLog("Entity does not exist in world: " + builder.EntityId, Logger.severity.WARNING);
         return;
     }
     this.LastSeenAt = builder.LastSeenAt.ToTimeSpan();
     this.LastKnownPosition = builder.LastKnownPosition;
     this.LastKnownVelocity = builder.LastKnownVelocity;
     this.LastBroadcast = builder.LastBroadcast.ToTimeSpan();
     this.LastRadar = builder.LastRadar.ToTimeSpan();
     this.LastJam = builder.LastJam.ToTimeSpan();
     if (builder.Info != null)
         this.Info = new RadarInfo(builder.Info);
     this.value_isValid = true;
 }
Ejemplo n.º 2
0
		private LastSeen(LastSeen first, LastSeen second)
		{
			this.Info = RadarInfo.getNewer(first.Info, second.Info);

			LastSeen newer = first.isNewerThan(second) ? first : second;

			this.Entity = newer.Entity;
			this.LastSeenAt = newer.LastSeenAt;
			this.LastKnownPosition = newer.LastKnownPosition;
			this.LastKnownVelocity = newer.LastKnownVelocity;

			this.LastBroadcast = first.LastBroadcast.CompareTo(second.LastBroadcast) > 0 ? first.LastBroadcast : second.LastBroadcast;
			this.LastRadar = first.LastRadar.CompareTo(second.LastBroadcast) > 0 ? first.LastRadar : second.LastRadar;
			this.LastJam = first.LastJam.CompareTo(second.LastBroadcast) > 0 ? first.LastJam : second.LastJam;

			value_isValid = true;
		}
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a LastSeen for an entity that was detected with an active radar scan.
 /// </summary>
 public LastSeen(IMyEntity entity, UpdateTime times, RadarInfo info)
     : this(entity, times)
 {
     this.Info = info;
 }
Ejemplo n.º 4
0
 public bool IsNewerThan(RadarInfo other)
 {
     return this.DetectedAt.CompareTo(other.DetectedAt) > 0;
 }
Ejemplo n.º 5
0
 public static RadarInfo getNewer(RadarInfo first, RadarInfo second)
 {
     if (first == null)
         return second;
     if (second == null)
         return first;
     if (first.IsNewerThan(second))
         return first;
     return second;
 }