Exemplo n.º 1
0
        private static void OnReserveEnvironmentItemRequest(long entityId, int localId, long reservationTimeMs, int senderSerialId)
        {
            EndpointId         sender;
            ReservedEntityData data;

            if (MyEventContext.Current.IsLocallyInvoked)
            {
                sender = new EndpointId(Sync.MyId);
            }
            else
            {
                sender = MyEventContext.Current.Sender;
            }
            bool flag = true;
            KeyValuePair <long, long> key = new KeyValuePair <long, long>(entityId, (long)localId);

            if (!m_reservedEntities.TryGetValue(key, out data))
            {
                ReservedEntityData data2 = new ReservedEntityData {
                    EntityId         = entityId,
                    LocalId          = localId,
                    ReservationTimer = Stopwatch.GetTimestamp() + ((Stopwatch.Frequency * reservationTimeMs) / 0x3e8L),
                    ReserverId       = new MyPlayer.PlayerId(sender.Value, senderSerialId)
                };
                m_reservedEntities.Add(key, data2);
            }
            else if (data.ReserverId == new MyPlayer.PlayerId(sender.Value, senderSerialId))
            {
                data.ReservationTimer = Stopwatch.GetTimestamp() + ((Stopwatch.Frequency * reservationTimeMs) / 0x3e8L);
            }
            else
            {
                flag = false;
            }
            if (MyEventContext.Current.IsLocallyInvoked)
            {
                if (flag)
                {
                    OnReserveEnvironmentItemSuccess(entityId, localId, senderSerialId);
                }
                else
                {
                    OnReserveEnvironmentItemFailure(entityId, localId, senderSerialId);
                }
            }
            else
            {
                Vector3D?nullable;
                if (flag)
                {
                    nullable = null;
                    MyMultiplayer.RaiseStaticEvent <long, int, int>(s => new Action <long, int, int>(MyAiTargetManager.OnReserveEnvironmentItemSuccess), entityId, localId, senderSerialId, sender, nullable);
                }
                else
                {
                    nullable = null;
                    MyMultiplayer.RaiseStaticEvent <long, int, int>(s => new Action <long, int, int>(MyAiTargetManager.OnReserveEnvironmentItemFailure), entityId, localId, senderSerialId, sender, nullable);
                }
            }
        }
Exemplo n.º 2
0
 private static void OnReserveEntityFailure(ref ReserveEntityMsg msg, MyNetworkClient sender)
 {
     if (OnReservationResult != null)
     {
         var reservationData = new ReservedEntityData()
         {
             Type = MyReservedEntityType.ENTITY, EntityId = msg.EntityId, ReserverId = new MyPlayer.PlayerId(0, msg.SenderSerialId)
         };
         OnReservationResult(ref reservationData, false);
     }
 }
 private static void OnReserveEntityFailure(long entityId, int senderSerialId)
 {
     if (OnReservationResult != null)
     {
         var reservationData = new ReservedEntityData()
         {
             Type = MyReservedEntityType.ENTITY, EntityId = entityId, ReserverId = new MyPlayer.PlayerId(0, senderSerialId)
         };
         OnReservationResult(ref reservationData, false);
     }
 }
Exemplo n.º 4
0
 private static void OnReserveEntitySuccess(long entityId, int senderSerialId)
 {
     if (OnReservationResult != null)
     {
         ReservedEntityData entityData = new ReservedEntityData {
             Type       = MyReservedEntityType.ENTITY,
             EntityId   = entityId,
             ReserverId = new MyPlayer.PlayerId(0L, senderSerialId)
         };
         OnReservationResult(ref entityData, true);
     }
 }
Exemplo n.º 5
0
 private static void OnReserveVoxelPositionSuccess(long entityId, Vector3I voxelPosition, int senderSerialId)
 {
     if (OnReservationResult != null)
     {
         ReservedEntityData entityData = new ReservedEntityData {
             Type       = MyReservedEntityType.VOXEL,
             EntityId   = entityId,
             GridPos    = voxelPosition,
             ReserverId = new MyPlayer.PlayerId(0L, senderSerialId)
         };
         OnReservationResult(ref entityData, true);
     }
 }
Exemplo n.º 6
0
 private static void OnReserveEnvironmentItemSuccess(long entityId, int localId, int senderSerialId)
 {
     if (OnReservationResult != null)
     {
         ReservedEntityData entityData = new ReservedEntityData {
             Type       = MyReservedEntityType.ENVIRONMENT_ITEM,
             EntityId   = entityId,
             LocalId    = localId,
             ReserverId = new MyPlayer.PlayerId(0L, senderSerialId)
         };
         OnReservationResult(ref entityData, true);
     }
 }
Exemplo n.º 7
0
 private static void OnReserveVoxelPositionFailure(ref ReserveVoxelPositionMsg msg, MyNetworkClient sender)
 {
     if (OnReservationResult != null)
     {
         var reservationData = new ReservedEntityData()
         {
             Type       = MyReservedEntityType.VOXEL,
             EntityId   = msg.EntityId,
             GridPos    = msg.VoxelPos,
             ReserverId = new MyPlayer.PlayerId(0, msg.SenderSerialId)
         };
         OnReservationResult(ref reservationData, false);
     }
 }
Exemplo n.º 8
0
 private static void OnReserveEnvironmentItemSuccess(ref ReserveEnvironmentItemMsg msg, MyNetworkClient sender)
 {
     if (OnReservationResult != null)
     {
         var reservationData = new ReservedEntityData()
         {
             Type       = MyReservedEntityType.ENVIRONMENT_ITEM,
             EntityId   = msg.EntityId,
             LocalId    = msg.LocalId,
             ReserverId = new MyPlayer.PlayerId(0, msg.SenderSerialId)
         };
         OnReservationResult(ref reservationData, true);
     }
 }
 private static void OnReserveVoxelPositionFailure(long entityId, Vector3I voxelPosition, int senderSerialId)
 {
     if (OnReservationResult != null)
     {
         var reservationData = new ReservedEntityData()
         {
             Type       = MyReservedEntityType.VOXEL,
             EntityId   = entityId,
             GridPos    = voxelPosition,
             ReserverId = new MyPlayer.PlayerId(0, senderSerialId)
         };
         OnReservationResult(ref reservationData, false);
     }
 }
Exemplo n.º 10
0
 private static void OnReserveEnvironmentItemFailure(long entityId, int localId, int senderSerialId)
 {
     if (OnReservationResult != null)
     {
         var reservationData = new ReservedEntityData()
         {
             Type       = MyReservedEntityType.ENVIRONMENT_ITEM,
             EntityId   = entityId,
             LocalId    = localId,
             ReserverId = new MyPlayer.PlayerId(0, senderSerialId)
         };
         OnReservationResult(ref reservationData, false);
     }
 }
Exemplo n.º 11
0
        private static void OnReserveEntityFailure(long entityId, int senderSerialId)
		{
			if (OnReservationResult != null)
			{
                var reservationData = new ReservedEntityData() { Type = MyReservedEntityType.ENTITY, EntityId = entityId, ReserverId = new MyPlayer.PlayerId(0, senderSerialId) };
				OnReservationResult(ref reservationData, false);
			}
		}
Exemplo n.º 12
0
        private static void OnReserveVoxelPositionFailure(long entityId, Vector3I voxelPosition, int senderSerialId)
		{
			if (OnReservationResult != null)
			{
				var reservationData = new ReservedEntityData()
				{
					Type = MyReservedEntityType.VOXEL,
                    EntityId = entityId,
                    GridPos = voxelPosition,
                    ReserverId = new MyPlayer.PlayerId(0, senderSerialId)
				};
				OnReservationResult(ref reservationData, false);
			}
		}
Exemplo n.º 13
0
		private static void OnReserveVoxelPositionFailure(ref ReserveVoxelPositionMsg msg, MyNetworkClient sender)
		{
			if (OnReservationResult != null)
			{
				var reservationData = new ReservedEntityData()
				{
					Type = MyReservedEntityType.VOXEL,
					EntityId = msg.EntityId,
					GridPos = msg.VoxelPos,
					ReserverId = new MyPlayer.PlayerId(0, msg.SenderSerialId)
				};
				OnReservationResult(ref reservationData, false);
			}
		}
Exemplo n.º 14
0
		private static void OnReserveEnvironmentItemFailure(ref ReserveEnvironmentItemMsg msg, MyNetworkClient sender)
		{
			if (OnReservationResult != null)
			{
				var reservationData = new ReservedEntityData()
				{
					Type = MyReservedEntityType.ENVIRONMENT_ITEM,
					EntityId = msg.EntityId,
					LocalId = msg.LocalId,
					ReserverId = new MyPlayer.PlayerId(0, msg.SenderSerialId)
				};
				OnReservationResult(ref reservationData, false);
			}
		}
Exemplo n.º 15
0
		private static void OnReserveEntitySuccess(ref ReserveEntityMsg msg, MyNetworkClient sender)
		{
			if (OnReservationResult != null)
			{
				var reservationData = new ReservedEntityData() { Type = MyReservedEntityType.ENTITY, EntityId = msg.EntityId, ReserverId = new MyPlayer.PlayerId(0, msg.SenderSerialId) };
				OnReservationResult(ref reservationData, true);
			}
		}
Exemplo n.º 16
0
        private static void OnReserveEnvironmentItemFailure(long entityId, int localId, int senderSerialId)
		{
			if (OnReservationResult != null)
			{
				var reservationData = new ReservedEntityData()
				{
					Type = MyReservedEntityType.ENVIRONMENT_ITEM,
                    EntityId = entityId,
                    LocalId = localId,
                    ReserverId = new MyPlayer.PlayerId(0, senderSerialId)
				};
				OnReservationResult(ref reservationData, false);
			}
		}
Exemplo n.º 17
0
        private static void OnReserveVoxelPositionRequest(long entityId, Vector3I voxelPosition, long reservationTimeMs, int senderSerialId)
        {
            EndpointId sender;

            if (MyEventContext.Current.IsLocallyInvoked)
            {
                sender = new EndpointId(Sync.MyId);
            }
            else
            {
                sender = MyEventContext.Current.Sender;
            }
            bool        flag   = true;
            MyVoxelBase result = null;

            if (MySession.Static.VoxelMaps.Instances.TryGetValue(entityId, out result))
            {
                ReservedEntityData        data;
                Vector3I                  vectori = result.StorageMax - result.StorageMin;
                KeyValuePair <long, long> key     = new KeyValuePair <long, long>(entityId, (long)((voxelPosition.X + (voxelPosition.Y * vectori.X)) + ((voxelPosition.Z * vectori.X) * vectori.Y)));
                if (!m_reservedEntities.TryGetValue(key, out data))
                {
                    ReservedEntityData data2 = new ReservedEntityData {
                        EntityId         = entityId,
                        GridPos          = voxelPosition,
                        ReservationTimer = Stopwatch.GetTimestamp() + ((Stopwatch.Frequency * reservationTimeMs) / 0x3e8L),
                        ReserverId       = new MyPlayer.PlayerId(sender.Value, senderSerialId)
                    };
                    m_reservedEntities.Add(key, data2);
                }
                else if (data.ReserverId == new MyPlayer.PlayerId(sender.Value, senderSerialId))
                {
                    data.ReservationTimer = Stopwatch.GetTimestamp() + ((Stopwatch.Frequency * reservationTimeMs) / 0x3e8L);
                }
                else
                {
                    flag = false;
                }
                if (MyEventContext.Current.IsLocallyInvoked)
                {
                    if (flag)
                    {
                        OnReserveVoxelPositionSuccess(entityId, voxelPosition, senderSerialId);
                    }
                    else
                    {
                        OnReserveVoxelPositionFailure(entityId, voxelPosition, senderSerialId);
                    }
                }
                else
                {
                    Vector3D?nullable;
                    if (flag)
                    {
                        nullable = null;
                        MyMultiplayer.RaiseStaticEvent <long, Vector3I, int>(s => new Action <long, Vector3I, int>(MyAiTargetManager.OnReserveVoxelPositionSuccess), entityId, voxelPosition, senderSerialId, sender, nullable);
                    }
                    else
                    {
                        nullable = null;
                        MyMultiplayer.RaiseStaticEvent <long, Vector3I, int>(s => new Action <long, Vector3I, int>(MyAiTargetManager.OnReserveVoxelPositionFailure), entityId, voxelPosition, senderSerialId, sender, nullable);
                    }
                }
            }
        }