private void F45LockedUpdate(RadarLockData radarLockData) { try { // ulong key = (from p in VTOLVR_Multiplayer.AIDictionaries.allActors where p.Value == lr.currentLock.actor select p.Key).FirstOrDefault(); if (VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.TryGetValue(radarLockData.actor, out lastID)) { Debug.Log(gameObject.name + " F45 radar data found its lock " + radarLockData.actor.name + " at id " + lastID + " with its own uID being " + networkUID); lastLockingMessage.actorUID = lastID; lastLockingMessage.isLocked = radarLockData.locked; lastLockingMessage.senderUID = networkUID; if (Networker.isHost) { NetworkSenderThread.Instance.SendPacketAsHostToAllClients(lastLockingMessage, EP2PSend.k_EP2PSendReliable); } else { NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, lastLockingMessage, EP2PSend.k_EP2PSendReliable); } } else { Debug.LogError("Could not resolve lock at actor " + radarLockData.actor.name); } } catch (Exception ex) { Debug.LogError("Couldn't lock target " + radarLockData.actor.name + $" exception {ex} thrown."); } }
public void MissileUpdate(Packet packet) { lastMessage = ((PacketSingle)packet).message as Message_MissileUpdate; if (lastMessage.networkUID != networkUID) { return; } if (!thisMissile.fired) { RadarLockData lockData = new RadarLockData(); lockData.actor = GetActorAtPosition(lastMessage.targetPosition); lockData.locked = true; lockData.lockingRadar = GetComponentInChildren <LockingRadar>(); //Unsure if these are on a child or not lockData.radarSymbol = GetComponentInChildren <Radar>().radarSymbol; //I'm just guessing they are thisMissile.SetRadarLock(lockData); thisMissile.Fire(); } if (lastMessage.hasMissed) { thisMissile.Detonate(); return; } rigidbody.velocity = lastMessage.velocity.toVector3; rigidbody.rotation = Quaternion.Euler(lastMessage.rotation.toVector3); if (Vector3.Distance(rigidbody.position, lastMessage.position.toVector3) > positionThreshold) { Debug.LogWarning($"Missile ({gameObject.name}) is outside the threshold. Teleporting to position."); rigidbody.position = lastMessage.position.toVector3; } }
public static void Postfix(SAMLauncher __instance, RadarLockData lockData) { if (Networker.isHost) { Debug.Log("A sam has fired, attempting to send it to the client in postfix method."); if (VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.TryGetValue(__instance.actor, out ulong senderUID)) { if (VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.TryGetValue(lockData.actor, out ulong actorUID)) { Debug.Log($"Sending sam launch with a missile uID of {SAMHelper.SAMmissile}, sender uID will be {senderUID}, and the actorUID will be {actorUID}."); NetworkSenderThread.Instance.SendPacketAsHostToAllClients(new Message_SamUpdate(actorUID, SAMHelper.SAMmissile, senderUID), Steamworks.EP2PSend.k_EP2PSendReliable); SAMHelper.SAMmissile = 0; } else { Debug.LogWarning($"Could not resolve SAMLauncher {senderUID}'s target."); } } else { Debug.LogWarning($"Could not resolve a SAMLauncher's uid."); } } }