private void Awake() { samLauncher = GetComponentInChildren <SAMLauncher>(); Networker.SAMUpdate += SamUpdate; samLauncher.LoadAllMissiles(); if (samLauncher.lockingRadars == null) { List <LockingRadar> lockingRadars = new List <LockingRadar>(); Actor lastActor; foreach (var uID in radarUIDS) { Debug.Log($"Try adding uID {uID} to SAM's radars."); if (VTOLVR_Multiplayer.AIDictionaries.allActors.TryGetValue(uID, out lastActor)) { Debug.Log("Got the actor."); foreach (var radar in lastActor.gameObject.GetComponentsInChildren <LockingRadar>()) { lockingRadars.Add(radar); Debug.Log("Added radar to a sam launcher!"); } } else { Debug.LogError($"Could not resolve actor from uID {uID}."); } } samLauncher.lockingRadars = lockingRadars.ToArray(); } }
public static bool Prefix(SAMLauncher __instance) { if (!Networker.isHost) { return(true); } Debug.Log("Beginning sam launch prefix."); int j = 0; Missile[] missiles = (Missile[])Traverse.Create(__instance).Field("missiles").GetValue(); for (int i = 0; i < missiles.Length; i++) { if (missiles[i] != null) { Debug.Log("Found a suitable missile to attach a sender to."); MissileNetworker_Sender missileSender = missiles[i].gameObject.AddComponent <MissileNetworker_Sender>(); missileSender.networkUID = Networker.GenerateNetworkUID(); SAMHelper.SAMmissile = missileSender.networkUID; return(true); } } Debug.Log("Could not find a suitable missile to attach a sender to."); SAMHelper.SAMmissile = 0; return(true); // __state = 0; }
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."); } } }
static void Postfix(AIUnitSpawn __instance) { if (Networker.isHost) { Debug.Log("Setting up new AI."); AIManager.setupAIAircraft(__instance.actor); Debug.Log("Telling client about newly spawned AI."); Actor actor = __instance.actor; if (!actor.isPlayer) { if (actor.name.Contains("Client")) { return; } bool Aggresion = false; if (actor.gameObject.GetComponent <UIDNetworker_Sender>() != null) { Debug.Log("Try sending ai " + actor.name + " to client."); HPInfo[] hPInfos2 = null; int[] cmLoadout = null; UIDNetworker_Sender uidSender = actor.gameObject.GetComponent <UIDNetworker_Sender>(); if (actor.role == Actor.Roles.Air) { WeaponManager wm = actor.gameObject.GetComponent <WeaponManager>(); if (wm != null) { hPInfos2 = PlaneEquippableManager.generateHpInfoListFromWeaponManager(actor.weaponManager, PlaneEquippableManager.HPInfoListGenerateNetworkType.sender, uidSender.networkUID).ToArray(); } } AIUnitSpawn aIUnitSpawn = actor.gameObject.GetComponent <AIUnitSpawn>(); if (aIUnitSpawn == null) { Debug.LogWarning("AI unit spawn is null on ai " + actor.name); } else { Aggresion = aIUnitSpawn.engageEnemies; } bool canBreak = false; PhoneticLetters letters = new PhoneticLetters(); foreach (var Group in VTScenario.current.groups.GetExistingGroups(actor.team)) { foreach (var ID in Group.unitIDs) { if (ID == actor.unitSpawn.unitID) { letters = Group.groupID; canBreak = true; break; } } if (canBreak) { break; } } List <ulong> ids = new List <ulong>(); ulong lastID; SAMLauncher launcher = actor.gameObject.GetComponentInChildren <SAMLauncher>(); if (launcher != null) { foreach (var radar in launcher.lockingRadars) { if (radar.myActor == null) { Debug.LogError("Locking radar on one of the SAM's is literally null."); } if (VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.TryGetValue(radar.myActor, out lastID)) { ids.Add(lastID); // Debug.Log("Aded a radar ID"); } else { Debug.LogError("Couldn't get a locking radar on one of the SAM's, probably a dictionary problem."); } } } ulong[] irIDS = new ulong[0]; IRSAMNetworker_Sender irs = actor.gameObject.GetComponentInChildren <IRSAMNetworker_Sender>(); if (irs != null) { irIDS = irs.irIDs; } Debug.Log("Finally sending AI " + actor.name + " to client all clients."); if (canBreak) { NetworkSenderThread.Instance.SendPacketAsHostToAllClients(new Message_SpawnAIVehicle(actor.name, AIManager.GetUnitNameFromCatalog(actor.unitSpawn.unitName), VTMapManager.WorldToGlobalPoint(actor.gameObject.transform.position), new Vector3D(actor.gameObject.transform.rotation.eulerAngles), uidSender.networkUID, hPInfos2, cmLoadout, 0.65f, Aggresion, actor.unitSpawn.unitSpawner.unitInstanceID, letters, ids.ToArray(), irIDS), EP2PSend.k_EP2PSendReliable); } else { // Debug.Log("It seems that " + actor.name + " is not in a unit group, sending anyways."); NetworkSenderThread.Instance.SendPacketAsHostToAllClients(new Message_SpawnAIVehicle(actor.name, AIManager.GetUnitNameFromCatalog(actor.unitSpawn.unitName), VTMapManager.WorldToGlobalPoint(actor.gameObject.transform.position), new Vector3D(actor.gameObject.transform.rotation.eulerAngles), uidSender.networkUID, hPInfos2, cmLoadout, 0.65f, Aggresion, actor.unitSpawn.unitSpawner.unitInstanceID, ids.ToArray(), irIDS), EP2PSend.k_EP2PSendReliable); } } else { Debug.Log("Could not find the UIDNetworker_Sender"); } } AIManager.TellClientAboutAI(new Steamworks.CSteamID(0)); } }
/// <summary> /// Tell the connected clients about all the vehicles the host has. This code should never be run on a client. /// </summary> /// <param name="steamID">Pass 0 to tell it to every client.</param> public static void TellClientAboutAI(CSteamID steamID) { if (!Networker.isHost) { Debug.LogWarning("The client shouldn't be trying to tell everyone about AI"); return; } Debug.Log("Trying sending AI's to client " + steamID); foreach (var actor in TargetManager.instance.allActors) { if (actor == null) { continue; } if (actor.parentActor != null) { continue; } Debug.Log("Trying sending new stage 1"); if (!actor.isPlayer) { if (actor.name.Contains("Client [") == false) { Debug.Log("Trying sending new stage 2"); bool Aggresion = false; if (actor.gameObject.GetComponent <UIDNetworker_Sender>() != null) { Debug.Log("Try sending ai " + actor.name + " to client."); HPInfo[] hPInfos2 = null; int[] cmLoadout = null; UIDNetworker_Sender uidSender = actor.gameObject.GetComponent <UIDNetworker_Sender>(); List <ulong> subUIDs = new List <ulong>(); foreach (UIDNetworker_Sender subActor in actor.gameObject.GetComponentsInChildren <UIDNetworker_Sender>()) { subUIDs.Add(subActor.networkUID); Debug.Log("Found ID sender with ID " + subActor.networkUID); } if (actor.role == Actor.Roles.Air) { WeaponManager wm = actor.gameObject.GetComponent <WeaponManager>(); if (wm != null) { hPInfos2 = PlaneEquippableManager.generateHpInfoListFromWeaponManager(actor.weaponManager, PlaneEquippableManager.HPInfoListGenerateNetworkType.sender, uidSender.networkUID).ToArray(); } } AIUnitSpawn aIUnitSpawn = actor.gameObject.GetComponent <AIUnitSpawn>(); if (aIUnitSpawn == null) { Debug.LogWarning("AI unit spawn is null on ai " + actor.name); } else { Aggresion = aIUnitSpawn.engageEnemies; } bool canBreak = false; PhoneticLetters letters = new PhoneticLetters(); foreach (var Group in VTScenario.current.groups.GetExistingGroups(actor.team)) { foreach (var ID in Group.unitIDs) { if (aIUnitSpawn != null) { if (ID == actor.unitSpawn.unitID) { letters = Group.groupID; canBreak = true; break; } } } if (canBreak) { break; } } Debug.LogWarning("passed group stuff"); List <ulong> ids = new List <ulong>(); ulong lastID; SAMLauncher launcher = actor.gameObject.GetComponentInChildren <SAMLauncher>(); if (launcher != null) { foreach (var radar in launcher.lockingRadars) { if (radar.myActor == null) { Debug.LogError("Locking radar on one of the SAM's is literally null."); } if (VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.TryGetValue(radar.myActor, out lastID)) { ids.Add(lastID); // Debug.Log("Aded a radar ID"); } else { Debug.LogError("Couldn't get a locking radar on one of the SAM's, probably a dictionary problem."); } } } ulong[] irIDS = new ulong[0]; IRSAMNetworker_Sender irs = actor.gameObject.GetComponentInChildren <IRSAMNetworker_Sender>(); if (irs != null) { irIDS = irs.irIDs; } bool redfor = false; if (actor.team == Teams.Enemy) { redfor = true; } if (steamID != new CSteamID(0)) { Debug.Log("Finally sending AI " + actor.name + " to client " + steamID); Debug.Log("This unit is made from " + subUIDs.Count + " actors! "); if (canBreak) { NetworkSenderThread.Instance.SendPacketToSpecificPlayer(steamID, new Message_SpawnAIVehicle(actor.name, GetUnitNameFromCatalog(actor.unitSpawn.unitName), redfor, VTMapManager.WorldToGlobalPoint(actor.gameObject.transform.position), actor.gameObject.transform.rotation, uidSender.networkUID, subUIDs.ToArray(), hPInfos2, cmLoadout, 0.65f, Aggresion, actor.unitSpawn.unitSpawner.unitInstanceID, letters, ids.ToArray(), irIDS), EP2PSend.k_EP2PSendReliableWithBuffering); } else { // Debug.Log("It seems that " + actor.name + " is not in a unit group, sending anyways."); NetworkSenderThread.Instance.SendPacketToSpecificPlayer(steamID, new Message_SpawnAIVehicle(actor.name, GetUnitNameFromCatalog(actor.unitSpawn.unitName), redfor, VTMapManager.WorldToGlobalPoint(actor.gameObject.transform.position), actor.gameObject.transform.rotation, uidSender.networkUID, subUIDs.ToArray(), hPInfos2, cmLoadout, 0.65f, Aggresion, actor.unitSpawn.unitSpawner.unitInstanceID, ids.ToArray(), irIDS), EP2PSend.k_EP2PSendReliableWithBuffering); } } else { Debug.Log("Finally sending AI " + actor.name + " to client all clients."); Debug.Log("This unit is made from " + subUIDs.Count + " actors! "); if (canBreak) { Networker.addToReliableSendBuffer(new Message_SpawnAIVehicle(actor.name, GetUnitNameFromCatalog(actor.unitSpawn.unitName), redfor, VTMapManager.WorldToGlobalPoint(actor.gameObject.transform.position), actor.gameObject.transform.rotation, uidSender.networkUID, subUIDs.ToArray(), hPInfos2, cmLoadout, 0.65f, Aggresion, actor.unitSpawn.unitSpawner.unitInstanceID, letters, ids.ToArray(), irIDS)); } else { // Debug.Log("It seems that " + actor.name + " is not in a unit group, sending anyways."); Networker.addToReliableSendBuffer(new Message_SpawnAIVehicle(actor.name, GetUnitNameFromCatalog(actor.unitSpawn.unitName), redfor, VTMapManager.WorldToGlobalPoint(actor.gameObject.transform.position), actor.gameObject.transform.rotation, uidSender.networkUID, subUIDs.ToArray(), hPInfos2, cmLoadout, 0.65f, Aggresion, actor.unitSpawn.unitSpawner.unitInstanceID, ids.ToArray(), irIDS)); } } } else { Debug.Log("Could not find the UIDNetworker_Sender"); } } } } }
/// <summary> /// This is used by the client and only the client to spawn ai vehicles. /// </summary> public static void SpawnAIVehicle(Packet packet) // This should never run on the host { if (Networker.isHost) { Debug.LogWarning("Host shouldn't be trying to spawn an ai vehicle."); return; } Message_SpawnAIVehicle message = (Message_SpawnAIVehicle)((PacketSingle)packet).message; if (!PlayerManager.gameLoaded) { Debug.LogWarning("Our game isn't loaded, adding spawn vehicle to queue"); AIsToSpawnQueue.Enqueue(packet); return; } foreach (ulong id in spawnedAI) { if (id == message.rootActorNetworkID) { Debug.Log("Got a spawnAI message for a vehicle we have already added! Name == " + message.unitName + " Returning..."); return; } } spawnedAI.Add(message.rootActorNetworkID); //Debug.Log("Got a new aiSpawn uID."); if (message.unitName == "Player") { Debug.LogWarning("Player shouldn't be sent to someones client...."); return; } Debug.Log("Trying to spawn AI " + message.aiVehicleName); GameObject prefab = UnitCatalogue.GetUnitPrefab(message.unitName); if (prefab == null) { Debug.LogError(message.unitName + " was not found."); return; } GameObject newAI = GameObject.Instantiate(prefab, VTMapManager.GlobalToWorldPoint(message.position), message.rotation); //Debug.Log("Setting vehicle name"); newAI.name = message.aiVehicleName; Actor actor = newAI.GetComponent <Actor>(); if (actor == null) { Debug.LogError("actor is null on object " + newAI.name); } if (message.redfor) { actor.team = Teams.Enemy; } else { actor.team = Teams.Allied; } AirportManager airport = newAI.GetComponent <AirportManager>(); UnitSpawn unitSP = newAI.GetComponent <UnitSpawn>(); GameObject.Destroy(unitSP); if (airport != null) { newAI.AddComponent <UnitSpawn>(); } else { newAI.AddComponent <AICarrierSpawn>(); } unitSP = newAI.GetComponent <UnitSpawn>(); UnitSpawner UnitSpawner = new UnitSpawner(); actor.unitSpawn = unitSP; actor.unitSpawn.unitSpawner = UnitSpawner; unitSP.actor = actor; Traverse.Create(actor.unitSpawn.unitSpawner).Field("_spawnedUnit").SetValue(unitSP); Traverse.Create(actor.unitSpawn.unitSpawner).Field("_spawned").SetValue(true); Traverse.Create(actor.unitSpawn.unitSpawner).Field("_unitInstanceID").SetValue(message.unitInstanceID); // To make objectives work. UnitSpawner.team = actor.team; UnitSpawner.unitName = actor.unitSpawn.unitName; if (!PlayerManager.teamLeftie) { UnitSpawner.team = actor.team; } else { if (actor.team == Teams.Enemy) { foreach (Actor subActor in newAI.GetComponentsInChildren <Actor>()) { subActor.team = Teams.Allied; TargetManager.instance.UnregisterActor(subActor); TargetManager.instance.RegisterActor(subActor); } } else if (actor.team == Teams.Allied) { foreach (Actor subActor in newAI.GetComponentsInChildren <Actor>()) { subActor.team = Teams.Enemy; TargetManager.instance.UnregisterActor(subActor); TargetManager.instance.RegisterActor(subActor); } } UnitSpawner.team = actor.team; if (airport != null) { airport.team = actor.team; SetUpCarrier(newAI, message.rootActorNetworkID, actor.team); } } TargetManager.instance.UnregisterActor(actor); TargetManager.instance.RegisterActor(actor); VTScenario.current.units.AddSpawner(actor.unitSpawn.unitSpawner); if (message.hasGroup) { VTScenario.current.groups.AddUnitToGroup(UnitSpawner, message.unitGroup); } Debug.Log(actor.name + $" has had its unitInstanceID set at value {actor.unitSpawn.unitSpawner.unitInstanceID}."); VTScenario.current.units.AddSpawner(actor.unitSpawn.unitSpawner); Debug.Log($"Spawned new vehicle at {newAI.transform.position}"); newAI.AddComponent <FloatingOriginTransform>(); newAI.transform.position = VTMapManager.GlobalToWorldPoint(message.position); newAI.transform.rotation = message.rotation; Debug.Log("This unit should have " + message.networkIDs.Length + " actors! "); int currentSubActorID = 0; foreach (Actor child in newAI.GetComponentsInChildren <Actor>()) { Debug.Log("setting up actor: " + currentSubActorID); UIDNetworker_Receiver uidReciever = child.gameObject.AddComponent <UIDNetworker_Receiver>(); uidReciever.networkUID = message.networkIDs[currentSubActorID]; if (child.gameObject.GetComponent <Health>() != null) { HealthNetworker_Receiver healthNetworker = child.gameObject.AddComponent <HealthNetworker_Receiver>(); healthNetworker.networkUID = message.networkIDs[currentSubActorID]; //HealthNetworker_Sender healthNetworkerS = newAI.AddComponent<HealthNetworker_Sender>(); //healthNetworkerS.networkUID = message.networkID; // Debug.Log("added health Sender to ai"); // Debug.Log("added health reciever to ai"); } else { Debug.Log(message.aiVehicleName + " has no health?"); } if (child.gameObject.GetComponent <ShipMover>() != null) { ShipNetworker_Receiver shipNetworker = child.gameObject.AddComponent <ShipNetworker_Receiver>(); shipNetworker.networkUID = message.networkIDs[currentSubActorID]; } else if (child.gameObject.GetComponent <GroundUnitMover>() != null) { if (child.gameObject.GetComponent <Rigidbody>() != null) { GroundNetworker_Receiver groundNetworker = child.gameObject.AddComponent <GroundNetworker_Receiver>(); groundNetworker.networkUID = message.networkIDs[currentSubActorID]; } } else if (child.gameObject.GetComponent <Rigidbody>() != null) { Rigidbody rb = child.gameObject.GetComponent <Rigidbody>(); RigidbodyNetworker_Receiver rbNetworker = child.gameObject.AddComponent <RigidbodyNetworker_Receiver>(); rbNetworker.networkUID = message.networkIDs[currentSubActorID]; } if (child.role == Actor.Roles.Air) { PlaneNetworker_Receiver planeReceiver = child.gameObject.AddComponent <PlaneNetworker_Receiver>(); planeReceiver.networkUID = message.networkIDs[currentSubActorID]; AIPilot aIPilot = child.gameObject.GetComponent <AIPilot>(); aIPilot.enabled = false; aIPilot.kPlane.SetToKinematic(); aIPilot.kPlane.enabled = false; aIPilot.commandState = AIPilot.CommandStates.Navigation; aIPilot.kPlane.enabled = true; aIPilot.kPlane.SetVelocity(Vector3.zero); aIPilot.kPlane.SetToDynamic(); RotationToggle wingRotator = aIPilot.wingRotator; if (wingRotator != null) { WingFoldNetworker_Receiver wingFoldReceiver = child.gameObject.AddComponent <WingFoldNetworker_Receiver>(); wingFoldReceiver.networkUID = message.networkIDs[currentSubActorID]; wingFoldReceiver.wingController = wingRotator; } if (aIPilot.isVtol) { //Debug.Log("Adding Tilt Controller to this vehicle " + message.networkID); EngineTiltNetworker_Receiver tiltReceiver = child.gameObject.AddComponent <EngineTiltNetworker_Receiver>(); tiltReceiver.networkUID = message.networkIDs[currentSubActorID]; } if (child.gameObject.GetComponentInChildren <ExteriorLightsController>() != null) { ExtLight_Receiver extLight = child.gameObject.AddComponent <ExtLight_Receiver>(); extLight.networkUID = message.networkIDs[currentSubActorID]; } Rigidbody rb = child.gameObject.GetComponent <Rigidbody>(); foreach (Collider collider in child.gameObject.GetComponentsInChildren <Collider>()) { if (collider) { collider.gameObject.layer = 9; } } Debug.Log("Doing weapon manager shit on " + child.gameObject.name + "."); WeaponManager weaponManager = child.gameObject.GetComponent <WeaponManager>(); if (weaponManager == null) { Debug.LogError(child.gameObject.name + " does not seem to have a weapon maanger on it."); } else { PlaneEquippableManager.SetLoadout(child.gameObject, message.networkIDs[currentSubActorID], message.normalizedFuel, message.hpLoadout, message.cmLoadout); } } AIUnitSpawn aIUnitSpawn = child.gameObject.GetComponent <AIUnitSpawn>(); if (aIUnitSpawn == null) { Debug.LogWarning("AI unit spawn is null on respawned unit " + aIUnitSpawn); } // else // newAI.GetComponent<AIUnitSpawn>().SetEngageEnemies(message.Aggresive); VehicleMover vehicleMover = child.gameObject.GetComponent <VehicleMover>(); if (vehicleMover != null) { vehicleMover.enabled = false; vehicleMover.behavior = GroundUnitMover.Behaviors.Parked; } else { GroundUnitMover ground = child.gameObject.GetComponent <GroundUnitMover>(); if (ground != null) { ground.enabled = false; ground.behavior = GroundUnitMover.Behaviors.Parked; } } Debug.Log("Checking for gun turrets on child " + child.name); if (child.gameObject.GetComponentsInChildren <Actor>().Length <= 1) {//only run this code on units without subunits Debug.Log("This is a child, with " + child.gameObject.GetComponentsInChildren <Actor>().Length + " actors, so it could have guns!"); ulong turretCount = 0; foreach (ModuleTurret moduleTurret in child.gameObject.GetComponentsInChildren <ModuleTurret>()) { TurretNetworker_Receiver tRec = child.gameObject.AddComponent <TurretNetworker_Receiver>(); tRec.networkUID = message.networkIDs[currentSubActorID]; tRec.turretID = turretCount; Debug.Log("Added turret " + turretCount + " to actor " + message.networkIDs[currentSubActorID] + " uid"); turretCount++; } ulong gunCount = 0; foreach (GunTurretAI turretAI in child.gameObject.GetComponentsInChildren <GunTurretAI>()) { turretAI.SetEngageEnemies(false); AAANetworker_Reciever aaaRec = child.gameObject.AddComponent <AAANetworker_Reciever>(); aaaRec.networkUID = message.networkIDs[currentSubActorID]; aaaRec.gunID = gunCount; Debug.Log("Added gun " + gunCount + " to actor " + message.networkIDs[currentSubActorID] + " uid"); gunCount++; } } else { Debug.Log("This isnt a child leaf thing, it has " + child.gameObject.GetComponentsInChildren <Actor>().Length + " actors"); } IRSamLauncher iLauncher = child.gameObject.GetComponent <IRSamLauncher>(); if (iLauncher != null) { //iLauncher.ml.RemoveAllMissiles(); iLauncher.ml.LoadAllMissiles(); iLauncher.SetEngageEnemies(false); MissileNetworker_Receiver mlr; //iLauncher.ml.LoadCount(message.IRSamMissiles.Length); Debug.Log($"Adding IR id's on IR SAM, len = {message.IRSamMissiles.Length}."); for (int i = 0; i < message.IRSamMissiles.Length; i++) { mlr = iLauncher.ml.missiles[i]?.gameObject.AddComponent <MissileNetworker_Receiver>(); mlr.thisML = iLauncher.ml; mlr.networkUID = message.IRSamMissiles[i]; } Debug.Log("Added IR id's."); } Soldier soldier = child.gameObject.GetComponent <Soldier>(); if (soldier != null) { soldier.SetEngageEnemies(false); if (soldier.soldierType == Soldier.SoldierTypes.IRMANPAD) { soldier.SetEngageEnemies(false); IRMissileLauncher ir = soldier.irMissileLauncher; if (ir != null) { //ir.RemoveAllMissiles(); ir.LoadAllMissiles(); MissileNetworker_Receiver mlr; //ir.LoadCount(message.IRSamMissiles.Length); Debug.Log($"Adding IR id's on manpads, len = {message.IRSamMissiles.Length}."); for (int i = 0; i < message.IRSamMissiles.Length; i++) { mlr = ir.missiles[i]?.gameObject.AddComponent <MissileNetworker_Receiver>(); mlr.thisML = ir; mlr.networkUID = message.IRSamMissiles[i]; } Debug.Log("Added IR id's on manpads."); } else { Debug.Log($"Manpad {message.networkIDs} forgot its rocket launcher pepega."); } } } Debug.Log("Checking for SAM launchers"); SAMLauncher launcher = child.gameObject.GetComponent <SAMLauncher>(); if (launcher != null) { Debug.Log("I found a sam launcher!"); SamNetworker_Reciever samNetworker = launcher.gameObject.AddComponent <SamNetworker_Reciever>(); samNetworker.networkUID = message.networkIDs[currentSubActorID]; samNetworker.radarUIDS = message.radarIDs; //Debug.Log($"Added samNetworker to uID {message.networkID}."); launcher.SetEngageEnemies(false); launcher.fireInterval = float.MaxValue; launcher.lockingRadars = null; } /*IRSamLauncher ml = actor.gameObject.GetComponentInChildren<IRSamLauncher>(); * if (ml != null) * { * ml.SetEngageEnemies(false); * MissileNetworker_Receiver lastRec; * for (int i = 0; i < ml.ml.missiles.Length; i++) * { * lastRec = ml.ml.missiles[i].gameObject.AddComponent<MissileNetworker_Receiver>(); * lastRec.networkUID = message.IRSamMissiles[i]; * lastRec.thisML = ml.ml; * } * }*/ //this code for ir missiles was here twice, so i dissable the seccond copy Debug.Log("Checking for locking radars"); foreach (LockingRadar radar in child.GetComponentsInChildren <LockingRadar>()) { if (radar.GetComponent <Actor>() == child) { Debug.Log($"Adding radar receiver to object {child.name} as it is the same game object as this actor."); LockingRadarNetworker_Receiver lastLockingReceiver = child.gameObject.AddComponent <LockingRadarNetworker_Receiver>(); lastLockingReceiver.networkUID = message.networkIDs[currentSubActorID]; Debug.Log("Added locking radar!"); } else if (radar.GetComponentInParent <Actor>() == child) { Debug.Log($"Adding radar receiver to object {child.name} as it is a child of this actor."); LockingRadarNetworker_Receiver lastLockingReceiver = child.gameObject.AddComponent <LockingRadarNetworker_Receiver>(); lastLockingReceiver.networkUID = message.networkIDs[currentSubActorID]; Debug.Log("Added locking radar!"); } else { Debug.Log("This radar is not direct child of this actor, ignoring"); } } AIVehicles.Add(new AI(child.gameObject, message.aiVehicleName, child, message.networkIDs[currentSubActorID])); Debug.Log("Spawned in AI " + child.gameObject.name); if (!VTOLVR_Multiplayer.AIDictionaries.allActors.ContainsKey(message.networkIDs[currentSubActorID])) { VTOLVR_Multiplayer.AIDictionaries.allActors.Add(message.networkIDs[currentSubActorID], child); } if (!VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.ContainsKey(actor)) { VTOLVR_Multiplayer.AIDictionaries.reverseAllActors.Add(child, message.networkIDs[currentSubActorID]); } currentSubActorID++; } }