Пример #1
0
    public override GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("E-4"));

        plane.GetComponentInChildren <Radar>().gameObject.SetActive(false);
        return(plane);
    }
Пример #2
0
    public override GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("MQ-31"));

        //plane.GetComponentInChildren<RefuelPlane>().enabled = false;
        return(plane);
    }
    public override GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("ABomberAI"));

        plane.name = "ABomberAI";
        return(plane);
    }
    public GameObject AddBomberDoors(Transform aircraft, AIEjectPilot ejector, bool rightDoor)
    {
        GameObject ejectorDoorPrefab;

        Debug.Log("Trying to get ejector door!");
        if (rightDoor)
        {
            ejectorDoorPrefab = UnitCatalogue.GetUnitPrefab("ABomberAI").transform.Find("CockpitPart").Find("ejectPanelRight.002").gameObject;
        }
        else
        {
            ejectorDoorPrefab = UnitCatalogue.GetUnitPrefab("ABomberAI").transform.Find("CockpitPart").Find("ejectPanelLeft.002").gameObject;
        }
        Debug.Log("Got ejector door!");

        GameObject ejectorDoor = Instantiate(ejectorDoorPrefab, aircraft);

        ejectorDoor.transform.localPosition = new Vector3(0, -3.582781f, 7.093267f);
        ejectorDoor.transform.localRotation = Quaternion.Euler(-90, 0, 0);

        ejectorDoor.SetActive(false);
        ejector.canopyObject  = ejectorDoor;
        ejector.canopyBooster = ejectorDoor.GetComponentInChildren <SolidBooster>();
        ejector.OnBegin.AddListener(delegate { ejectorDoor.SetActive(true); });
        return(ejectorDoor);
    }
    public void SetupCrew(int crewAmmount, Rigidbody rb)
    {
        prebailTime  = new MinMax(3, 5);
        bailInterval = new MinMax(0.5f, 1);

        spawnPositions = new Vector3[] { new Vector3(-4.69f, -0.392f, -15.84f), new Vector3(4.69f, -0.392f, -15.84f) };

        Debug.Log("Trying to get ejector seat!");
        GameObject ejectorSeatPrefab = UnitCatalogue.GetUnitPrefab("FA-26B AI").GetComponentInChildren <AIEjectPilot>(true).gameObject;

        Debug.Log("Got ejector seat!");


        crew = new AIEjectPilot[crewAmmount];
        for (int i = 0; i < crewAmmount; i++)
        {
            GameObject ejectorSeat = Instantiate(ejectorSeatPrefab, transform);
            ejectorSeat.transform.localPosition = spawnPositions[UnityEngine.Random.Range(0, spawnPositions.Length)];
            ejectorSeat.transform.localRotation = Quaternion.identity;
            ejectorSeat.transform.parent        = transform;

            AIEjectPilot ejectPilot = ejectorSeat.GetComponent <AIEjectPilot>();
            ejectPilot.parentRb = rb;
            ejectPilot.OnBegin.RemoveAllListeners();

            ejectPilot.booster.burnTime = 0;
            ejectPilot.delay            = new MinMax(0, 0);
            ejectPilot.ejectDelay       = 0;
            ejectPilot.parachuteDelay   = 2;

            crew[i] = ejectPilot;
        }
    }
    public override GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("KC-49"));

        plane.GetComponentInChildren <RefuelPlane>().enabled = false;
        plane.GetComponentInChildren <ModuleTurret>().gameObject.SetActive(false);
        plane.GetComponentInChildren <RefuelGuideLights>().gameObject.SetActive(false);
        return(plane);
    }
Пример #7
0
    public override GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("ASF-30"));

        Actor actor = plane.GetComponent <Actor>();

        actor.team = Teams.Allied;
        TargetManager.instance.UnregisterActor(actor);
        TargetManager.instance.RegisterActor(actor);

        return(plane);
    }
    public GameObject AddFACockpit(Transform aircraftTransform, Vector3 position, Vector3 scale)
    {
        Debug.Log("Trying to get cockpit interior!");
        GameObject cockpitPrefab = FindObject(UnitCatalogue.GetUnitPrefab("FA-26B AI").transform, "lowPolyInterior").gameObject;

        Debug.Log("Got cockpit interior!");

        GameObject cockpit = Instantiate(cockpitPrefab, aircraftTransform);

        cockpit.transform.localPosition    = position;
        cockpit.transform.localEulerAngles = new Vector3(-90, 0, -180f);
        cockpit.transform.localScale       = scale;

        return(cockpit);
    }
        void Spawn()
        {
            Debug.Log("Spawning CAP F/A-26B");
            gameObject = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("FA-26B AI"));
            gameObject.AddComponent <FloatingOriginTransform>();
            transform        = gameObject.transform;
            aircraft         = gameObject.GetComponent <AIAircraftSpawn>();
            pilot            = gameObject.GetComponent <AIPilot>();
            rb               = gameObject.GetComponent <Rigidbody>();
            rb.interpolation = RigidbodyInterpolation.Interpolate;
            gameObject.GetComponent <KinematicPlane>().SetToKinematic();

            Loadout loadout = new Loadout();

            loadout.hpLoadout      = new string[] { "af_gun", "af_aim9", "af_aim9", "af_amraamRail", "af_amraam", "af_amraam", "af_amraam", "af_amraam", "af_amraamRail", "af_aim9", "af_aim9", "fa26_droptank", "fa26_droptank", "fa26_droptank", "af_tgp", "" };
            loadout.cmLoadout      = new int[] { 120, 120 };
            loadout.normalizedFuel = 1;
            gameObject.GetComponent <WeaponManager>().EquipWeapons(loadout);
        }
    public AIEjectPilot AddEjectorSeat(Health health, Rigidbody rb, Vector3 position)
    {
        Debug.Log("Trying to get ejector seat!");
        GameObject ejectorSeatPrefab = UnitCatalogue.GetUnitPrefab("FA-26B AI").GetComponentInChildren <AIEjectPilot>(true).gameObject;

        Debug.Log("Got ejector seat!");

        GameObject ejectorSeat = Instantiate(ejectorSeatPrefab, health.transform);

        ejectorSeat.transform.localPosition = position;
        ejectorSeat.transform.localRotation = Quaternion.identity;

        AIEjectPilot ejectPilot = ejectorSeat.GetComponent <AIEjectPilot>();

        health.OnDeath.AddListener(ejectPilot.BeginEjectSequence);
        ejectPilot.parentRb = rb;
        ejectPilot.OnBegin.RemoveAllListeners();
        return(ejectPilot);
    }
Пример #11
0
    /// <summary>
    /// Finds the prefabs which are used for spawning the other players on our client
    /// </summary>
    private static void SetPrefabs()
    {
        UnitCatalogue.UpdateCatalogue();
        av42cPrefab = UnitCatalogue.GetUnitPrefab("AV-42CAI");
        fa26bPrefab = UnitCatalogue.GetUnitPrefab("FA-26B AI");
        f45Prefab   = UnitCatalogue.GetUnitPrefab("F-45A AI");

        if (!av42cPrefab)
        {
            Debug.LogError("Couldn't find the prefab for the AV-42C");
        }
        if (!fa26bPrefab)
        {
            Debug.LogError("Couldn't find the prefab for the F/A-26B");
        }
        if (!f45Prefab)
        {
            Debug.LogError("Couldn't find the prefab for the F-45A");
        }
    }
    public override GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("F-45A AI"));

        return(plane);
    }
Пример #13
0
    public static void SetUpCarrier(GameObject carrier, ulong id, Teams team)
    {
        AirportManager airport = carrier.GetComponent <AirportManager>();

        if (airport != null)
        {
            airport.airportName = carrierNames[(int)id % carrierNames.Length] + " " + id;
            if (Networker.isClient)
            {
                VTMapManager.fetch.airports.Add(airport);
            }

            GameObject carrierPrefab = UnitCatalogue.GetUnitPrefab("AlliedCarrier");
            if (airport.voiceProfile == null)
            {
                if (carrierPrefab != null)
                {
                    airport.voiceProfile = carrierPrefab.GetComponent <AirportManager>().voiceProfile;
                    Debug.Log("Set ATC voice!");
                }
                else
                {
                    Debug.Log("Could not find carrier...");
                }
            }

            if (airport.vtolOnlyLanding == false)
            {//this stops inapropriate code from running on either the LHA or the Cruiser, and causing problems
                if (airport.carrierOlsTransform == null)
                {
                    GameObject olsTransform = new GameObject();
                    olsTransform.transform.parent        = carrier.transform;
                    olsTransform.transform.position      = airport.runways[0].transform.position + airport.runways[0].transform.forward * 30;
                    olsTransform.transform.localRotation = Quaternion.Euler(-3.5f, 180f, 0f);
                    airport.carrierOlsTransform          = olsTransform.transform;
                }

                if (airport.ols == null)
                {
                    if (carrierPrefab != null)
                    {
                        GameObject olsObject = GameObject.Instantiate(carrierPrefab.GetComponent <AirportManager>().ols.gameObject);
                        olsObject.transform.parent        = carrier.transform;
                        olsObject.transform.localPosition = new Vector3(-25f, 19.7f, 45f);
                        olsObject.transform.localRotation = Quaternion.Euler(-3.5f, 180, 0);

                        OpticalLandingSystem ols = olsObject.GetComponent <OpticalLandingSystem>();
                        airport.ols            = ols;
                        airport.runways[0].ols = ols;

                        Debug.Log("Stole the OLS!");
                    }
                    else
                    {
                        Debug.Log("Could not find carrier...");
                    }
                }

                Actor actor = carrier.GetComponent <Actor>();
                if (actor != null)
                {
                    actor.iconType              = UnitIconManager.MapIconTypes.Carrier;
                    actor.useIconRotation       = true;
                    actor.iconRotationReference = airport.runways[0].transform;
                }
            }
            else
            {
                Debug.Log("This is a cruiser or an LHA, no need to set up runways or landing systems");
            }

            if (airport.carrierCables.Length == 0)
            {
                airport.carrierCables = carrier.GetComponentsInChildren <CarrierCable>();
                Debug.Log("Assigned the carrier wires!");
            }

            int catCount = 1;
            foreach (CarrierCatapult catapult in carrier.GetComponentsInChildren <CarrierCatapult>())
            {
                if (catapult.catapultDesignation == 0)
                {
                    catapult.catapultDesignation = catCount;
                    catCount++;
                }
            }

            if (airport.surfaceColliders.Length == 0)
            {
                airport.surfaceColliders = carrier.GetComponentsInChildren <Collider>();
                Debug.Log("Assigned the surface colliders!");
            }

            airport.waveOffCheckDist = 400;
            airport.waveOffMinDist   = 200;
            airport.waveOffAoA.max   = 12;
            airport.waveOffAoA.min   = 7;

            if (carrier.GetComponentInChildren <ReArmingPoint>() == null)
            {
                Debug.Log("Carrier had no rearming points, adding my own!");
                foreach (AirportManager.ParkingSpace parkingSpace in airport.parkingSpaces)
                {
                    GameObject    rearmingGameObject = new GameObject();
                    ReArmingPoint rearmingPoint      = rearmingGameObject.AddComponent <ReArmingPoint>();
                    rearmingGameObject.transform.parent        = parkingSpace.transform;
                    rearmingGameObject.transform.localPosition = Vector3.zero;
                    rearmingGameObject.transform.localRotation = Quaternion.identity;
                    rearmingPoint.team      = team;
                    rearmingPoint.radius    = 18.93f;
                    rearmingPoint.canArm    = true;
                    rearmingPoint.canRefuel = true;
                }
            }
            else
            {
                Debug.Log("Carrier already had rearming points");
            }
        }
    }
Пример #14
0
    /// <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++;
        }
    }
    public virtual GameObject SpawnAircraft()
    {
        GameObject plane = GameObject.Instantiate(UnitCatalogue.GetUnitPrefab("AV-42CAI"));//E-4 //KC-49 //ABomberAI //MQ-31

        return(plane);
    }