public static void RequestSpawn(Packet packet, CSteamID sender) //Run by Host Only { Message_RequestSpawn lastMessage = (Message_RequestSpawn)((PacketSingle)packet).message; Debug.Log("A player has requested for a spawn point"); if (!Networker.hostLoaded) { Debug.Log("The host isn't ready yet, adding to queue"); spawnRequestQueue.Enqueue(lastMessage); return; } if (spawnPoints == null || spawnPoints.Count == 0) { Debug.LogError("Spawn points was null, we won't be able to find any spawn point then"); return; } Transform spawn = FindFreeSpawn(lastMessage.teaml); if (Networker.isHost) { Debug.Log("Telling connected client about AI units"); AIManager.TellClientAboutAI(new CSteamID(lastMessage.senderSteamID)); } GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); Debug.Log("The players spawn will be " + spawn); NetworkSenderThread.Instance.SendPacketToSpecificPlayer(sender, new Message_RequestSpawn_Result(new Vector3D(localVehicle.transform.position), localVehicle.transform.rotation, Networker.GenerateNetworkUID(), players.Count), EP2PSend.k_EP2PSendReliable); }
/// <summary> /// When the client receives a P2P message of their spawn point, /// this will move them to that location before sending their vehicle /// to the host. This will call the function that spawns the local /// vehicle. /// </summary> /// <param name="packet">The message sent over the network</param> public static void RequestSpawn_Result(Packet packet) //Run by Clients Only { Debug.Log("The host has sent back our spawn point"); Message_RequestSpawn_Result result = (Message_RequestSpawn_Result)((PacketSingle)packet).message; Debug.Log($"We need to move to {result.position} : {result.rotation}"); GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); if (localVehicle == null) { Debug.LogError("The local vehicle was null"); return; } localVehicle.transform.position = result.position.toVector3; localVehicle.transform.rotation = result.rotation; PlayerVehicle currentVehiclet = PilotSaveManager.currentVehicle; localVehicle.transform.TransformPoint(currentVehiclet.playerSpawnOffset); if (carrierStart) { if (!carrierFound) { storedSpawnMessage = packet; return; } } SpawnLocalVehicleAndInformOtherClients(localVehicle, localVehicle.transform.position, localVehicle.transform.rotation, result.vehicleUID, result.playerCount); localUID = result.vehicleUID; Time.timeScale = 1.0f; }
public static List <HPInfo> generateLocalHpInfoList(ulong UID = 0) { GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); WeaponManager localWeaponManager = localVehicle.GetComponent <WeaponManager>(); return(generateHpInfoListFromWeaponManager(localWeaponManager, HPInfoListGenerateNetworkType.generate, UID)); }
public override void LateUpdate(FlybyCameraMFDPage mfdPage) { if (SCamPlus.tgpMFD != null) { mfdPage.flybyCam.transform.position = SCamPlus.tgpMFD.targetingCamera.transform.position; mfdPage.flybyCam.transform.rotation = Quaternion.Slerp(SCamPlus.lastRotation, SCamPlus.tgpMFD.targetingCamera.transform.rotation, Time.deltaTime * 1); SCamPlus.lastRotation = mfdPage.flybyCam.transform.rotation; mfdPage.flybyCam.fieldOfView = SCamPlus.tgpMFD.targetingCamera.fieldOfView; mfdPage.behaviorText.text = "SmoothTGP"; } else { SCamPlus.tgpMFD = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <TargetingMFDPage>(); if (mfdPage.weaponManager.opticalTargeter != null) { mfdPage.flybyCam.transform.position = mfdPage.weaponManager.opticalTargeter.sensorTurret.pitchTransform.position; mfdPage.flybyCam.transform.rotation = mfdPage.weaponManager.opticalTargeter.sensorTurret.pitchTransform.rotation; mfdPage.flybyCam.fieldOfView = 60; mfdPage.behaviorText.text = "TGPOff"; } else { mfdPage.behaviorText.text = "NoTGP"; } } }
private IEnumerator SetupScene() { while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene) { yield return(null); } chat.Create3DChat(VTOLAPI.GetPlayersVehicleGameObject(), VTOLAPI.GetPlayersVehicleEnum(), VTOLScenes.Akutan); manager.Start(); }
private IEnumerator SetupScene() { while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene) { yield return(null); } aircrarftType = VTOLAPI.GetPlayersVehicleEnum(); tgpMFD = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <TargetingMFDPage>(); player = VTOLAPI.GetPlayersVehicleGameObject().GetComponent <Actor>(); aceMaxDistance = Mathf.Tan((90 - aceFovRange.min) * Mathf.Deg2Rad) * 30; }
public override void LateUpdate(FlybyCameraMFDPage mfdPage) { if (SCamPlus.extCamManager != null) { Camera currentCam = SCamPlus.extCamManager.cameras[SCamPlus.extCamManager.camIdx]; mfdPage.flybyCam.transform.position = currentCam.transform.position; mfdPage.flybyCam.transform.rotation = currentCam.transform.rotation; mfdPage.flybyCam.fieldOfView = currentCam.fieldOfView; mfdPage.behaviorText.text = "ExtCam"; } else { SCamPlus.extCamManager = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <ExternalCamManager>(); mfdPage.behaviorText.text = "NoExtCam"; } }
//This method is called every frame by Unity. Here you'll probably put most of your code void Update() { try { if (plane == null) { plane = VTOLAPI.GetPlayersVehicleGameObject(); return; } if (VTOLAPI.GetPlayersVehicleEnum().Equals(VTOLVehicles.F45A)) { UltraInstinct(plane); } } catch (Exception) { } }
private IEnumerator main() { while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene) { yield return(null); } WeaponManager wm = VTOLAPI.GetPlayersVehicleGameObject().GetComponent <WeaponManager>(); wma = wm; // wm.resourcePath = Environment.CurrentDirectory + "\\VTOLVR_ModLoader\\mods\\AEAT\\nukey"; VTOLAPI.GetPlayersVehicleGameObject().AddComponent <BOOM>(); Loadout cloadout = new Loadout(); cloadout.normalizedFuel = 0.65f; cloadout.hpLoadout = new string[] { null, null, "Nuke", }; cloadout.cmLoadout = new int[] { 1000, 1000 }; Loadout loadout = new Loadout(); loadout.normalizedFuel = 0.65f; loadout.hpLoadout = new string[] { "fa26_gun" }; if (!triggered) { // wm.EquipWeapons(loadout); EquipCustomWeapons(sloadout, wm); } Debug.Log("did hax0r"); }
public static bool Prefix(ref CampaignSave __result, string campaignID) { if (!(VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) || AEAT.trueSave == null) { //Debug.Log("Not spoofing this save."); return(true); } Debug.Log(AEAT.trueSave.campaignID + " will be used as a campaign save."); __result = AEAT.trueSave; if (!AEAT.buttonMade) { Debug.Log(AEAT.path + " is AEAT.path"); VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path; LoadoutConfigurator config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0]; config.wm.resourcePath = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath; PilotSaveManager.currentVehicle.equipsResourcePath = "hpequips/" + AEAT.path; List <string> marsh = new List <string>(); List <GameObject> ketkev = new List <GameObject>(); foreach (var gameobject in Resources.LoadAll <GameObject>("hpequips/" + AEAT.path)) { if (!AllowedEquips.allowedEquips.Contains(gameobject.name)) { //Debug.Log("Unauthorized gameobject " + gameobject.name); continue; } marsh.Add(gameobject.name); ketkev.Add(gameobject); } Traverse.Create(config).Field("unlockedWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); Traverse.Create(config).Field("allWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); config.lockedHardpoints = new List <int>(); VTResources.GetScenario(PilotSaveManager.currentScenario.scenarioID, PilotSaveManager.currentCampaign).allowedEquips = marsh; __result.availableWeapons = marsh; Debug.Log("Set allowedEquips."); PilotSaveManager.currentVehicle.allEquipPrefabs = ketkev; // Don't need to reinit the config because this is prefixing the init statement } return(false); }
public void Rearm() { Debug.Log("Rearm!"); GameObject vehicle = VTOLAPI.GetPlayersVehicleGameObject(); WeaponManager wm = vehicle.GetComponentInChildren <WeaponManager>(); CountermeasureManager cm = vehicle.GetComponentInChildren <CountermeasureManager>(); Message_WeaponSet_Result rearm = new Message_WeaponSet_Result( PlaneEquippableManager.generateHpInfoListFromWeaponManager(wm, PlaneEquippableManager.HPInfoListGenerateNetworkType.generate, PlayerManager.localUID).ToArray(), PlaneEquippableManager.generateCounterMeasuresFromCmManager(cm).ToArray(), PlaneEquippableManager.generateLocalFuelValue(), PlayerManager.localUID); if (Networker.isHost) { NetworkSenderThread.Instance.SendPacketAsHostToAllClients(rearm, Steamworks.EP2PSend.k_EP2PSendReliable); } else { NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, rearm, Steamworks.EP2PSend.k_EP2PSendReliable); } }
public static void Postfix(RearmingUnitSpawn __instance) { if (PilotSaveManager.currentScenario.equipConfigurable == false) { return; } VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path; LoadoutConfigurator config = (LoadoutConfigurator)Traverse.Create(__instance).Field("config").GetValue(); config.wm.resourcePath = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath; Debug.Log(AEAT.path); PilotSaveManager.currentVehicle.equipsResourcePath = "hpequips/" + AEAT.path; List <string> marsh = new List <string>(); List <GameObject> ketkev = new List <GameObject>(); Dictionary <string, EqInfo> lol = new Dictionary <string, EqInfo>(); foreach (var gameobject in Resources.LoadAll <GameObject>("hpequips/" + AEAT.path)) { if (!AllowedEquips.allowedEquips.Contains(gameobject.name)) { Debug.Log("Unauthorized gameobject " + gameobject.name); continue; } marsh.Add(gameobject.name); ketkev.Add(gameobject); lol.Add(gameobject.name, new EqInfo(gameobject, AEAT.path)); } config.availableEquipStrings = marsh; PilotSaveManager.currentVehicle.allEquipPrefabs = ketkev; Traverse.Create(config).Field("unlockedWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); Traverse.Create(config).Field("allWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); config.Initialize(PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID), false); if (config.fullInfo != null) { config.fullInfo.CloseInfo(); } }
public static void Postfix(MFDPTacticalSituationDisplay __instance, ref TSDContactIcon __result) { if (VTOLAPI.GetPlayersVehicleEnum() == VTOLVehicles.F45A) { GameObject f45 = VTOLAPI.GetPlayersVehicleGameObject(); GameObject soiButton = GetChildWithName(f45, "ScaleButton (1)"); GameObject hvrObj = GetChildWithName(soiButton, "hvrObj"); tsdTraverse = Traverse.Create(__instance); GameObject contactHvrObj = UnityEngine.Object.Instantiate(hvrObj, __result.transform); float scaler = 1.3f; Vector2 hvrObjOrigSize = contactHvrObj.GetComponent <Image>().rectTransform.sizeDelta; contactHvrObj.GetComponent <Image>().rectTransform.sizeDelta *= scaler; __result.gameObject.SetActive(false); VRInteractable interact = __result.gameObject.AddComponent <VRInteractable>(); interact.interactableName = "Select"; interact.button = VRInteractable.Buttons.Trigger; interact.radius = 0; interact.useRect = true; interact.rect.center = Vector3.zero; interact.rect.extents = new Vector3(10, 10, 20); interact.requireMotion = false; interact.toggle = false; interact.tapOrHold = false; interact.sqrRadius = 0; interact.OnInteract = new UnityEvent(); interact.OnInteract.AddListener(f45.GetComponentInChildren <MFDPortalManager>().PlayInputSound); interact.OnInteract.AddListener(delegate { moveCursor(__instance, interact.gameObject); }); VRIHoverToggle hoverToggle = __result.gameObject.AddComponent <VRIHoverToggle>(); hoverToggle.hoverObj = contactHvrObj; __result.gameObject.SetActive(true); } }
/// <summary> /// This gives all the people waiting their spawn points /// </summary> private static void SpawnRequestQueue() //Run by Host Only { Debug.Log($"Giving {spawnRequestQueue.Count} people their spawns"); Transform lastSpawn; while (spawnRequestQueue.Count > 0) { Message_RequestSpawn lastMessage = spawnRequestQueue.Dequeue(); lastSpawn = FindFreeSpawn(lastMessage.teaml); Debug.Log("The players spawn will be " + lastSpawn); if (Networker.isHost) { Debug.Log("Telling connected client about AI units"); AIManager.TellClientAboutAI(new CSteamID(lastMessage.senderSteamID)); } GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); NetworkSenderThread.Instance.SendPacketToSpecificPlayer( new CSteamID(lastMessage.senderSteamID), new Message_RequestSpawn_Result(new Vector3D(localVehicle.transform.position), localVehicle.transform.rotation, Networker.GenerateNetworkUID(), players.Count), EP2PSend.k_EP2PSendReliable); } }
public IEnumerator main() { while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene) { yield return(null); } buttonMade = false; Debug.Log("AAAAAAAA"); wm = VTOLAPI.GetPlayersVehicleGameObject().GetComponent <WeaponManager>(); flightAssist = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <FlightAssist>(); Main.flightAssist.assistEnabled = false; { Main.MFDP = wm.gameObject.GetComponentInChildren <MFDPortalManager>(); MFDPStoresManagement MFDP = (MFDPStoresManagement)Main.MFDP.gameObject.GetComponentInChildren <MFDPortalManager>().pages[5]; Debug.Log("got MFPD"); GameObject toCopy = null; foreach (var resource in Resources.FindObjectsOfTypeAll <VRInteractable>()) { if (resource.interactableName == "Weapon Bay Door Overrides") { toCopy = resource.gameObject; break; } } if (toCopy == null) { Debug.LogError("To copy is null"); } //THANK YOU TEMPERZ87 FOR BUTTON CODE //create button object GameObject emptyButton = Instantiate(toCopy, MFDP.displayObj.gameObject.transform); //get transform object (position) RectTransform rt = emptyButton.GetComponent <RectTransform>(); Main.text1 = emptyButton.gameObject.GetComponentInChildren <Text>(); rt.localPosition = new Vector3(rt.localPosition.x - 50, rt.localPosition.y, rt.localPosition.z); rt.localScale = new Vector3(rt.localScale.x * 0.85f, rt.localScale.y * 0.85f, rt.localScale.z * 0.85f); rt.GetComponentInChildren <Image>().color = Color.black; Debug.Log("instantiate"); VRInteractable interactable = emptyButton.GetComponentInChildren <VRInteractable>(); Debug.Log("vr interactable"); Text text = emptyButton.GetComponentInChildren <Text>(); Debug.Log("text"); text.text = "FltAst"; Debug.Log("flightassist"); interactable.OnInteract = new UnityEvent(); Debug.Log("new UnityEvent()"); interactable.interactableName = "Toggle Flight Assist"; Debug.Log("toggle Flight Assist"); interactable.OnInteract.AddListener(new UnityAction(() => { Main.flightAssist.assistEnabled = !Main.flightAssist.assistEnabled; Main.MFDP.PlayInputSound(); Main.text1.color = Main.flightAssist.assistEnabled ? Color.green : Color.red; })); Debug.Log("listener"); Main.text1.color = Main.flightAssist.assistEnabled ? Color.green : Color.red; GameObject emptyButton2 = Instantiate(toCopy, MFDP.displayObj.gameObject.transform); RectTransform rt2 = emptyButton2.GetComponent <RectTransform>(); rt2.localPosition = new Vector3(rt2.localPosition.x - 85, rt.localPosition.y, rt.localPosition.z); rt2.localScale = new Vector3(rt2.localScale.x * 0.85f, rt2.localScale.y * 0.85f, rt2.localScale.z * 0.85f); rt2.GetComponentInChildren <Image>().color = Color.black; Debug.Log("instantiate"); VRInteractable interactable2 = emptyButton2.GetComponentInChildren <VRInteractable>(); Debug.Log("vr interactable"); text2 = emptyButton2.GetComponentInChildren <Text>(); Debug.Log("text"); text2.text = "Thrust"; Debug.Log("Thrust Event"); interactable2.OnInteract = new UnityEvent(); Debug.Log("new UnityEvent()"); interactable2.interactableName = "Toggle Ultra Thrust"; Debug.Log("Create Thrust Listener"); interactable2.OnInteract.AddListener(new UnityAction(() => { enableSuperThrust = !enableSuperThrust; Main.MFDP.PlayInputSound(); Main.text2.color = enableSuperThrust ? Color.green : Color.red; })); Main.text2.color = enableSuperThrust ? Color.green : Color.red; } }
IEnumerator RespawnTimer() { Debug.Log("Starting respawn timer."); yield return(new WaitForSeconds(15)); Debug.Log("Finished respawn timer."); ReArmingPoint[] rearmPoints = GameObject.FindObjectsOfType <ReArmingPoint>(); ReArmingPoint rearmPoint = rearmPoints[Random.Range(0, rearmPoints.Length - 1)]; float lastRadius = 0; if (PlayerManager.carrierStart) { foreach (ReArmingPoint rep in rearmPoints) { if (rep.team == Teams.Allied) { if (rep.radius < 19.0f) { rearmPoint = rep; } } } } else { foreach (ReArmingPoint rep in rearmPoints) { Debug.Log("finding rearm pt"); if (rep.team == Teams.Allied && rep.CheckIsClear(actor)) { if (rep.radius > lastRadius) { rearmPoint = rep; lastRadius = rep.radius; } } } } //UnEject(); //PutPlayerBackInAircraft(); //RepairAircraft(); //foreach (GearAnimator gear in gears) { // gear.ExtendImmediate(); //} //GetComponent<Rigidbody>().velocity = Vector3.zero; //transform.position = rearmPoint.transform.position + Vector3.up * 10; //transform.rotation = rearmPoint.transform.rotation; Destroy(VTOLAPI.GetPlayersVehicleGameObject()); Destroy(detacher.cameraRig); Destroy(detacher.gameObject); Destroy(ejection.gameObject); Destroy(BlackoutEffect.instance); Destroy(GetComponent <PlayerSpawn>()); foreach (EngineEffects effect in effects) { Destroy(effect); } //as much stuff as im destroying, some stuff is most likely getting through, future people, look into this AudioController.instance.ClearAllOpenings(); UnitIconManager.instance.UnregisterAll(); TargetManager.instance.detectedByAllies.Clear(); TargetManager.instance.detectedByEnemies.Clear(); foreach (var actor in TargetManager.instance.allActors) { if (actor != null) { actor.discovered = false; actor.drawIcon = true; //actor.DiscoverActor(); actor.permanentDiscovery = true; Traverse.Create(actor).Field("detectedByAllied").SetValue(false); Traverse.Create(actor).Field("detectedByEnemy").SetValue(false); if (actor.team == Teams.Allied) { actor.DetectActor(Teams.Allied); actor.UpdateKnownPosition(actor.team); } //actor.DiscoverActor(); <----------------breaks and only works on every 2nd spawn // UnitIconManager.instance.RegisterIcon(actor, 0.07f * actor.iconScale, actor.iconOffset); } } GameObject newPlayer = Instantiate(PilotSaveManager.currentVehicle.vehiclePrefab); FlightSceneManager.instance.playerActor = newPlayer.GetComponent <Actor>(); FlightSceneManager.instance.playerActor.flightInfo.PauseGCalculations(); FlightSceneManager.instance.playerActor.flightInfo.OverrideRecordedAcceleration(Vector3.zero); rearmPoint.voiceProfile.PlayMessage(GroundCrewVoiceProfile.GroundCrewMessages.Success); PilotSaveManager.currentScenario.totalBudget = 999999; PilotSaveManager.currentScenario.initialSpending = 0; PilotSaveManager.currentScenario.inFlightSpending = 0; PilotSaveManager.currentScenario.equipConfigurable = true; Rigidbody rb = newPlayer.GetComponent <Rigidbody>(); rb.detectCollisions = false; rearmPoint.BeginReArm(); rb.velocity = Vector3.zero; rb.detectCollisions = true; PlayerManager.SetupLocalAircraft(newPlayer, newPlayer.transform.position, newPlayer.transform.rotation, networkUID); lastMessage.UID = networkUID; lastMessage.isLeftie = PlayerManager.teamLeftie; if (Networker.isHost) { NetworkSenderThread.Instance.SendPacketAsHostToAllClients(lastMessage, Steamworks.EP2PSend.k_EP2PSendUnreliableNoDelay); } else { NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, lastMessage, Steamworks.EP2PSend.k_EP2PSendUnreliableNoDelay); } }
public static bool Prefix(HPEquippable equip) { if (PilotSaveManager.currentScenario.equipConfigurable == false) { return(true); } if (!AEAT.buttonMade && VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) { foreach (var controller in GameObject.FindObjectsOfType <VRHandController>()) { if (!controller.isLeft) { GameObject button = GameObject.Instantiate(GameObject.Find("RecenterCanvas")); button.transform.SetParent(controller.transform); button.transform.localPosition = new Vector3(0.101411f, 0.02100047f, -0.128024f); button.transform.localRotation = Quaternion.Euler(-5.834f, 283.583f, 328.957f); button.transform.localScale = new Vector3(button.transform.localScale.x * -1, button.transform.localScale.y * -1, button.transform.localScale.z); VRInteractable bInteractable = button.GetComponentInChildren <VRInteractable>(); Text text = button.GetComponentInChildren <Text>(); text.transform.localScale = text.transform.localScale * 0.75f; AEAT.path = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath.ToLower(); AEAT.path = AEAT.path.Remove(0, 9); text.text = "A.E.A.T. Super Menu"; bInteractable.interactableName = "Switch vehicle weapons\n (Current Weapons: " + AEAT.path + ")"; bInteractable.OnInteract = new UnityEngine.Events.UnityEvent(); bInteractable.transform.localPosition = new Vector3(-141f, -62f, -3f); Transform roundButtonBase1 = bInteractable.transform.parent.Find("roundButtonBase"); roundButtonBase1.localPosition = new Vector3(-141f, -62f, -3f); LoadoutConfigurator config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0]; VehicleConfigSceneSetup setup = Resources.FindObjectsOfTypeAll <VehicleConfigSceneSetup>()[0]; Traverse setupHelper = Traverse.Create(setup); bInteractable.OnInteract.AddListener(delegate { if (config == null) { config = Resources.FindObjectsOfTypeAll <LoadoutConfigurator>()[0]; } switch (AEAT.path.ToLower()) { case "abomber": AEAT.path = "afighter"; break; case "afighter": AEAT.path = "asf-30"; break; case "asf-30": AEAT.path = "asf-33"; break; case "asf-33": AEAT.path = "ebomber"; break; case "ebomber": AEAT.path = "eucav"; break; case "eucav": AEAT.path = "f45a"; break; case "f45a": AEAT.path = "gav-25"; break; case "gav-25": AEAT.path = "j4"; break; case "j4": AEAT.path = "mq-31"; break; case "mq-31": AEAT.path = "vtol"; break; case "vtol": AEAT.path = "abomber"; break; default: Debug.LogWarning("Uncaught case in vehicle switcher: " + AEAT.path); AEAT.path = "vtol"; break; } //text.text = "Weapons: " + AEAT.path; bInteractable.interactableName = "Switch vehicle weapons\n (Current Weapons: " + AEAT.path + ")"; Debug.Log(AEAT.path + " is AEAT.path"); //Debug.Log(text.text + " is weapons text"); VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath = "hpequips/" + AEAT.path; config.wm.resourcePath = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <WeaponManager>().resourcePath; Debug.Log(AEAT.path); PilotSaveManager.currentVehicle.equipsResourcePath = "hpequips/" + AEAT.path; List <string> marsh = new List <string>(); List <GameObject> ketkev = new List <GameObject>(); Dictionary <string, EqInfo> lol = new Dictionary <string, EqInfo>(); foreach (var gameobject in Resources.LoadAll <GameObject>("hpequips/" + AEAT.path)) { if (!AllowedEquips.allowedEquips.Contains(gameobject.name)) { Debug.Log("Unauthorized gameobject " + gameobject.name); continue; } marsh.Add(gameobject.name); ketkev.Add(gameobject); } config.availableEquipStrings = marsh; PilotSaveManager.currentVehicle.allEquipPrefabs = ketkev; Traverse.Create(config).Field("unlockedWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); Traverse.Create(config).Field("allWeaponPrefabs").SetValue(new Dictionary <string, EqInfo>()); config.lockedHardpoints = new List <int>(); // making sure all hardpoints are unlocked for (int i = 0; i < config.wm.hardpointTransforms.Length; i++) { config.Detach(i); } config.Initialize(PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID), false); if (config.fullInfo != null) { config.fullInfo.CloseInfo(); } }); Debug.Log("Made right hand bottom button."); button = GameObject.Instantiate(bInteractable.gameObject, bInteractable.transform.parent); Debug.Log("Current vehicle name is " + PilotSaveManager.currentVehicle.name); button.transform.localPosition = new Vector3(147f, -62f, -3f); VRInteractable bInteractable2 = button.GetComponent <VRInteractable>(); //Text text2 = button.GetComponentInChildren<Text>(); //text2.transform.localScale = text2.transform.localScale * 0.75f; //text2.text = PilotSaveManager.currentVehicle.name; bInteractable2.interactableName = "Switch Vehicles"; bInteractable2.OnInteract = new UnityEvent(); foreach (var vehicle in VTResources.GetPlayerVehicles()) { Debug.Log(vehicle.name); Debug.Log(vehicle.vehicleName); } bInteractable2.OnInteract.AddListener(delegate { if (PilotSaveManager.currentVehicle.name == "AV-42C") { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("F/A-26B"); } else if (PilotSaveManager.currentVehicle.name == "FA-26B") { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("F-45A"); } else { PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle("AV-42C"); } //text2.text = PilotSaveManager.currentVehicle.vehicleName; AEAT.selectedVehicle = PilotSaveManager.currentVehicle; if (VTOLAPI.currentScene == VTOLScenes.VehicleConfiguration) { AEAT.buttonMade = false; Debug.Log("Resetting up scene."); SceneManager.LoadScene("VehicleConfiguration"); } }); Transform bigButton2 = GameObject.Instantiate(roundButtonBase1, roundButtonBase1.parent); bigButton2.localPosition = bInteractable2.transform.localPosition; AEAT.trueSave = PilotSaveManager.current.GetVehicleSave(PilotSaveManager.currentVehicle.vehicleName).GetCampaignSave(PilotSaveManager.currentCampaign.campaignID); Debug.Log("Made right hand top button, and true save's id is " + AEAT.trueSave.campaignID); break; } } AEAT.buttonMade = true; } equip.allowedHardpoints = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30"; equip.unitCost = 0f; return(true); }
private void SceneLoaded(VTOLScenes scene) { chat.Create3DChat(VTOLAPI.GetPlayersVehicleGameObject(), VTOLAPI.GetPlayersVehicleEnum(), scene); manager.Start(); }
private IEnumerator main() { while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene) { yield return(null); } // Main code here buttonMade = false; Debug.Log("AAAAAAAA"); wm = VTOLAPI.GetPlayersVehicleGameObject().GetComponent <WeaponManager>(); inf = VTOLAPI.GetPlayersVehicleGameObject().AddComponent <infAmmo>(); inf.enabled = false; paired = VTOLAPI.GetPlayersVehicleGameObject().AddComponent <PairedGuns>(); paired.enabled = false; if (VTOLAPI.GetPlayersVehicleEnum() != VTOLVehicles.F45A) { WeaponManagerUI wmUI = wm.ui; Debug.Log("wmUI"); mfd = wmUI.mfdPage; if (mfd == null) { Debug.LogError("OOPIES."); } mfd.OnActivatePage.AddListener(new UnityAction(() => { lastMFD = mfd.mfd; Debug.Log("="); MFDPage.MFDButtonInfo[] allButtons = mfd.buttons; MFDPage.MFDButtonInfo newButton = new MFDPage.MFDButtonInfo(); newButton.button = MFD.MFDButtons.T4; newButton.toolTip = "Toggle infinite ammo"; newButton.label = "infAmmo"; newButton.OnPress.AddListener(new UnityAction(() => { AEAT.inf.enabled = !AEAT.inf.enabled; mfd.mfd.buttons[13].GetComponentInChildren <Text>().color = AEAT.inf.enabled ? Color.green : Color.red; })); if (mfd.mfd == null) { Debug.LogError("FOUND YA!"); } MFDPage.MFDButtonInfo newButton2 = new MFDPage.MFDButtonInfo(); newButton2.button = MFD.MFDButtons.T2; newButton2.toolTip = "Pair all guns"; newButton2.label = "pairGuns"; newButton2.OnPress.AddListener(new UnityAction(() => { AEAT.paired.enabled = !AEAT.paired.enabled; Debug.Log("Button pressed."); mfd.mfd.buttons[11].GetComponentInChildren <Text>().color = AEAT.paired.enabled && wm.equippedGun ? Color.green : Color.red; })); mfd.SetPageButton(newButton); mfd.SetPageButton(newButton2); mfd.mfd.buttons[13].GetComponentInChildren <Text>().color = AEAT.inf.enabled ? Color.green : Color.red; mfd.mfd.buttons[11].GetComponentInChildren <Text>().color = AEAT.paired.enabled ? Color.green : Color.red; })); mfd.OnDeactivatePage.AddListener(new UnityAction(() => { if (lastMFD != null) { lastMFD.buttons[13].GetComponentInChildren <Text>().color = Color.white; lastMFD.buttons[11].GetComponentInChildren <Text>().color = Color.white; lastMFD = null; } })); } else { AEAT.MFDP = wm.gameObject.GetComponentInChildren <MFDPortalManager>(); MFDPStoresManagement MFDP = (MFDPStoresManagement)AEAT.MFDP.gameObject.GetComponentInChildren <MFDPortalManager>().pages[5]; Debug.Log("got MFPD"); GameObject toCopy = null; foreach (var resource in Resources.FindObjectsOfTypeAll <VRInteractable>()) { if (resource.interactableName == "Weapon Bay Door Overrides") { toCopy = resource.gameObject; break; } } if (toCopy == null) { Debug.LogError("To copy is null"); } GameObject emptyButton = Instantiate(toCopy, MFDP.displayObj.gameObject.transform); RectTransform rt = emptyButton.GetComponent <RectTransform>(); AEAT.text1 = emptyButton.gameObject.GetComponentInChildren <Text>(); rt.localPosition = new Vector3(rt.localPosition.x - 50, rt.localPosition.y, rt.localPosition.z); rt.localScale = new Vector3(rt.localScale.x * 0.85f, rt.localScale.y * 0.85f, rt.localScale.z * 0.85f); rt.GetComponentInChildren <Image>().color = Color.black; Debug.Log("instantiate"); VRInteractable interactable = emptyButton.GetComponentInChildren <VRInteractable>(); Debug.Log("vr interactable"); Text text = emptyButton.GetComponentInChildren <Text>(); Debug.Log("text"); text.text = "infAmmo"; Debug.Log("infAmmo"); interactable.OnInteract = new UnityEvent(); Debug.Log("new UnityEvent()"); interactable.interactableName = "Toggle infinite ammo"; Debug.Log("toggle infinite ammo"); interactable.OnInteract.AddListener(new UnityAction(() => { AEAT.inf.enabled = !AEAT.inf.enabled; AEAT.MFDP.PlayInputSound(); AEAT.text1.color = AEAT.inf.enabled ? Color.green : Color.red; })); Debug.Log("listener"); AEAT.text1.color = AEAT.inf.enabled ? Color.green : Color.red; GameObject emptyButton2 = Instantiate(toCopy, MFDP.displayObj.gameObject.transform); RectTransform rt2 = emptyButton2.GetComponent <RectTransform>(); rt2.localPosition = new Vector3(rt2.localPosition.x - 85, rt.localPosition.y, rt.localPosition.z); rt2.localScale = new Vector3(rt2.localScale.x * 0.85f, rt2.localScale.y * 0.85f, rt2.localScale.z * 0.85f); rt2.GetComponentInChildren <Image>().color = Color.black; Debug.Log("instantiate"); VRInteractable interactable2 = emptyButton2.GetComponentInChildren <VRInteractable>(); Debug.Log("vr interactable"); text2 = emptyButton2.GetComponentInChildren <Text>(); Debug.Log("text"); text2.text = "pairGuns"; Debug.Log("pairGuns"); interactable2.OnInteract = new UnityEvent(); Debug.Log("new UnityEvent()"); interactable2.interactableName = "Pair All Guns"; Debug.Log("Pair all guns"); interactable2.OnInteract.AddListener(new UnityAction(() => { AEAT.paired.enabled = !AEAT.paired.enabled; AEAT.MFDP.PlayInputSound(); AEAT.text2.color = AEAT.paired.enabled ? Color.green : Color.red; })); AEAT.text2.color = AEAT.paired.enabled ? Color.green : Color.red; } }
static bool Prefix(AeroController.ControlSurfaceTransform __instance) { if (__instance.transform == null || (!__instance.transform.root.GetComponent <Actor>().isPlayer&& __instance.transform.root.GetComponent <Actor>().team == Teams.Enemy)) { return(true); } switch (__instance.transform.name) { case "canardLeft": { var leftCanard = __instance.transform.parent; _fakeLeftCan = GameObject.Instantiate(leftCanard.gameObject, leftCanard.parent, true); _fakeLeftCan.transform.name = "FakeCanardLeft"; _fakeLeftCan.transform.localPosition = leftCanard.transform.localPosition; _fakeLeftCan.transform.localRotation = leftCanard.transform.localRotation; _fakeLeftCan.transform.localScale = leftCanard.transform.localScale; _fakeLeftCan.transform.localPosition = new Vector3(1.01f, 1.12f, 8.16f); _fakeLeftCan.transform.Rotate(0f, 0f, 4.679f, Space.Self); _fakeLeftCan.transform.localScale = new Vector3(1.615172f, 1.488211f, 1f); foreach (Wing w in _fakeLeftCan.GetComponentsInChildren <Wing>(true)) { Destroy(w); } CreateControlSurface( VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <AeroController>(true), _fakeLeftCan.transform, __instance); var meshes = leftCanard.GetComponentsInChildren <MeshRenderer>(); foreach (var mesh in meshes) { mesh.enabled = false; } Debug.Log("F35 - Copied left"); break; } case "canardRight": { var rightCanard = __instance.transform.parent; _fakeRightCan = GameObject.Instantiate(rightCanard.gameObject, rightCanard.parent, true); _fakeRightCan.transform.name = "fakeCanardRight"; _fakeRightCan.transform.localPosition = rightCanard.transform.localPosition; _fakeRightCan.transform.localRotation = rightCanard.transform.localRotation; _fakeRightCan.transform.localScale = rightCanard.transform.localScale; _fakeRightCan.transform.localPosition = new Vector3(-1.01f, 1.12f, 8.16f); _fakeRightCan.transform.Rotate(0f, 0f, -4.679f, Space.Self); _fakeRightCan.transform.localScale = new Vector3(1.615172f, 1.488211f, 1f); _fakeRightCan.transform.localPosition = new Vector3(-1.01f, 1.12f, 8.16f); _fakeRightCan.transform.Rotate(0f, 0f, -4.679f, Space.Self); _fakeRightCan.transform.localScale = new Vector3(1.615172f, 1.488211f, 1f); foreach (var w in _fakeRightCan.GetComponentsInChildren <Wing>(true)) { Destroy(w); } CreateControlSurface( VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <AeroController>(true), _fakeRightCan.transform, __instance); var meshes = rightCanard.GetComponentsInChildren <MeshRenderer>(); foreach (var mesh in meshes) { mesh.enabled = false; } Debug.Log("F35 - Copied right"); break; } } return(true); }
private IEnumerator WaitForScenario() { if (!runlogger) { while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady) { yield return(null); } // Delaying start of capture process for two seconds to let the game catch up. yield return(new WaitForSeconds(2)); mapManager = VTMapManager.fetch; actorProcessor.support = support; heightmapGeneration.support = support; support.mm = mapManager; support.WriteLog("Map ID:"); support.WriteLog(mapManager.map.mapID); if (customScene) { VTMapCustom[] customMaps = FindObjectsOfType <VTMapCustom>(); foreach (VTMapCustom map in customMaps) { if (mapManager.map.mapID == map.mapID) { support.WriteLog("I THINK I CAN I THINK I CAN I THINK I CAN!"); gameHeightmap = map.heightMap; } } } else { gameHeightmap = mapManager.fallbackHeightmap; } heightmapGeneration.gameHeightmap = gameHeightmap; support.WriteLog("Scenario Ready!"); support.WriteLog("Getting Players Vehicle"); currentVehicle = VTOLAPI.GetPlayersVehicleGameObject(); support.WriteLog("Creating TacView Directory"); System.IO.Directory.CreateDirectory("TacViewDataLogs\\" + DateTime.UtcNow.ToString("yyyy-MM-dd HHmm")); TacViewFolder = "TacViewDataLogs\\" + DateTime.UtcNow.ToString("yyyy-MM-dd HHmm") + "\\"; path = @TacViewFolder + "datalog.acmi"; acmi = new ACMI(); support.WriteLog("Creating TacView File"); // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(acmi.acmi21Header()); } // Setting the current recording time support.WriteLog("Writing Reference Time"); string timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ"); using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine("0,RecordingTime=" + timestamp); } support.WriteLog($"Env Name: {VTScenario.current.envName}"); //Setting a custom hour to simulate the time of day based on the current scenario if (VTScenario.current.envName == "day") { using (StreamWriter sw = File.AppendText(path)) { timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd"); string minsec = DateTime.UtcNow.ToString("mm:ss"); timestamp += $"T13:{minsec}Z"; sw.WriteLine("0,ReferenceTime=" + timestamp); } } else if (VTScenario.current.envName == "morning") { using (StreamWriter sw = File.AppendText(path)) { timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd"); string minsec = DateTime.UtcNow.ToString("mm:ss"); timestamp += $"T06:{minsec}Z"; sw.WriteLine("0,ReferenceTime=" + timestamp); } } else if (VTScenario.current.envName == "night") { using (StreamWriter sw = File.AppendText(path)) { timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd"); string minsec = DateTime.UtcNow.ToString("mm:ss"); timestamp += $"T23:{minsec}Z"; sw.WriteLine("0,ReferenceTime=" + timestamp); } } else { support.WriteLog($"Unknown Scenario Env (day/morning/night) {VTScenario.current.envName}"); using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine("0,ReferenceTime=" + timestamp); } } // Custom Scene is set for anything not on the Akutan map support.WriteLog($"Custom Scene: {customScene}"); getGlobalMissionProperties(); getObjectives(); //// Elapsed time isn't used for anything anymore apparently... I'll keep it around for a reminder of better times. ////missionElapsedTime = FlightSceneManager.instance.missionElapsedTime; support.WriteLog("Running Logger"); runlogger = true; // Start the function to save the mission data StartCoroutine(writeString()); //// Get the heightmap info (Requires the map manager for the built in map) heightmapGeneration.getHeightMap(customScene, TacViewFolder, mapManager); // Get the airports getAirports(); } }
public string Register(Actor actor, string username) { if (GetTwitchPilot(username) == null) { if (IsActorTaken(actor)) { return(username + ", that vehicle is already taken."); } else { if (actor.gameObject == VTOLAPI.GetPlayersVehicleGameObject()) { return("You aren't allowed to control the player."); } else { ActorType type = GetActorType(actor); string message = "you have control!"; TwitchPilotBase pilot = null; switch (type) { case ActorType.Plane: TwitchPilotAircraft temp = new TwitchPilotAircraft(); pilot = temp; break; case ActorType.Boat: TwitchPilotBoat temp2 = new TwitchPilotBoat(); pilot = temp2; pilot.nameTagHeight = 50; pilot.fontSize = 50; message = "you have boat!"; break; case ActorType.Carrier: TwitchPilotCarrier temp3 = new TwitchPilotCarrier(); pilot = temp3; pilot.nameTagHeight = 50; pilot.fontSize = 50; message = "you have boat!"; break; case ActorType.DroneCarrier: TwitchPilotDroneCarrier temp4 = new TwitchPilotDroneCarrier(); pilot = temp4; pilot.nameTagHeight = 50; pilot.fontSize = 50; message = "you have boat!"; break; case ActorType.Tank: TwitchPilotTank temp5 = new TwitchPilotTank(); pilot = temp5; message = "PANZER VOR!"; break; case ActorType.Artillery: TwitchPilotArty temp6 = new TwitchPilotArty(); pilot = temp6; break; default: TwitchPilotBase temp7 = new TwitchPilotBase(); pilot = temp7; break; } pilot.actor = actor; pilot.wm = pilot.actor.weaponManager; pilot.username = username; pilot.player = VTOLAPI.GetPlayersVehicleGameObject(); pilot.Start(); pilots.Add(pilot); return(username + ", " + message); } } } else { return(username + ", you already have control of a vehicle."); } }
public static List <Player> players = new List <Player>(); //This is the list of players /// <summary> /// This runs when the map has finished loading and hopefully /// when the player first can interact with the vehicle. /// </summary> public static IEnumerator MapLoaded() { Debug.Log("map loading started"); while (VTMapManager.fetch == null || !VTMapManager.fetch.scenarioReady || FlightSceneManager.instance.switchingScene) { yield return(null); } Debug.Log("The map has loaded"); gameLoaded = true; // As a client, when the map has loaded we are going to request a spawn point from the host SetPrefabs(); carrierStart = FlightSceneManager.instance.playerActor.unitSpawn.unitSpawner.linkedToCarrier; if (!Networker.isHost) { FlightSceneManager.instance.playerActor.gameObject.transform.parent = null; Debug.Log($"Sending spawn request to host, host id: {Networker.hostID}, client id: {SteamUser.GetSteamID().m_SteamID}"); Debug.Log("Killing all units currently on the map."); List <Actor> allActors = new List <Actor>(); foreach (var actor in TargetManager.instance.allActors) { if (!actor.isPlayer) { allActors.Add(actor); } } foreach (var actor in allActors) { TargetManager.instance.UnregisterActor(actor); GameObject.Destroy(actor.gameObject); } VTScenario.current.units.units.Clear(); VTScenario.current.units.alliedUnits.Clear(); VTScenario.current.units.enemyUnits.Clear(); VTScenario.current.groups.DestroyAll(); if (teamLeftie) { foreach (AirportManager airportManager in VTMapManager.fetch.airports) { if (airportManager.team == Teams.Allied) { airportManager.team = Teams.Enemy; } else if (airportManager.team == Teams.Enemy) { airportManager.team = Teams.Allied; } } } var rearmPoints = GameObject.FindObjectsOfType <ReArmingPoint>(); //back up option below if (teamLeftie) { foreach (ReArmingPoint rep in rearmPoints) { if (rep.team == Teams.Allied) { rep.team = Teams.Enemy; rep.canArm = true; rep.canRefuel = true; } else if (rep.team == Teams.Enemy) { rep.team = Teams.Allied; rep.canArm = true; rep.canRefuel = true; } } } Message_RequestSpawn msg = new Message_RequestSpawn(teamLeftie, SteamUser.GetSteamID().m_SteamID); NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, msg, EP2PSend.k_EP2PSendReliable); /*foreach (var actor in TargetManager.instance.allActors) * { * VTScenario.current.units.AddSpawner(actor.unitSpawn.unitSpawner); * }*/ } else { Debug.Log("Starting map loaded host routines"); Networker.hostLoaded = true; Networker.hostReady = true; foreach (var actor in TargetManager.instance.allActors) { AIManager.setupAIAircraft(actor); } NetworkSenderThread.Instance.SendPacketAsHostToAllClients(new Message_HostLoaded(true), EP2PSend.k_EP2PSendReliable); GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); if (localVehicle != null) { GenerateSpawns(localVehicle.transform); localUID = Networker.GenerateNetworkUID(); UIDNetworker_Sender hostSender = localVehicle.AddComponent <UIDNetworker_Sender>(); hostSender.networkUID = localUID; Debug.Log($"The host's uID is {localUID}"); Transform hostTrans = localVehicle.transform; ///uncomment to randomise host spawn// /// localVehicle.transform.position = hostTrans.position; SpawnLocalVehicleAndInformOtherClients(localVehicle, hostTrans.transform.position, hostTrans.transform.rotation, localUID, 0); } else { Debug.Log("Local vehicle for host was null"); } if (spawnRequestQueue.Count != 0) { SpawnRequestQueue(); } Networker.alreadyInGame = true; } while (AIManager.AIsToSpawnQueue.Count > 0) { AIManager.SpawnAIVehicle(AIManager.AIsToSpawnQueue.Dequeue()); } SpawnPlayersInPlayerSpawnQueue(); if (!Networker.isHost) { // If the player is not the host, they only need a receiver? Debug.Log($"Player not the host, adding world data receiver"); worldData = new GameObject(); worldData.AddComponent <WorldDataNetworker_Receiver>(); } else { // If the player is the host, setup the sender so they can send world data Debug.Log($"Player is the host, setting up the world data sender"); worldData = new GameObject(); worldData.AddComponent <WorldDataNetworker_Sender>(); } }
/// <summary> /// When the user has received a message of spawn player vehicle, /// this creates the player vehicle and removes any thing which shouldn't /// be on it. /// </summary> /// <param name="packet">The message</param> public static void SpawnPlayerVehicle(Packet packet, CSteamID sender) //Both, but never spawns the local vehicle, only executes spawn vehicle messages from other clients { // We don't actually need the "sender" id, unless we're a client and want to check that the packet came from the host // which we're not doing right now. Message_SpawnPlayerVehicle message = (Message_SpawnPlayerVehicle)((PacketSingle)packet).message; if (message.networkID == PlayerManager.localUID) { return; } Debug.Log($"Recived a Spawn Vehicle Message from: {message.csteamID}"); CSteamID spawnerSteamId = new CSteamID(message.csteamID); if (!gameLoaded) { Debug.LogWarning("Our game isn't loaded, adding spawn vehicle to queue"); playersToSpawnQueue.Enqueue(packet); playersToSpawnIdQueue.Enqueue(sender); return; } //foreach (ulong id in spawnedVehicles) //{ // if (id == message.csteamID) // { // Debug.Log("Got a spawnedVehicle message for a vehicle we have already added! Returning...."); // return; // } //} //spawnedVehicles.Add(message.csteamID); Debug.Log("Got a new spawnVehicle uID."); if (Networker.isHost) { //Debug.Log("Generating UIDS for any missiles the new vehicle has"); for (int i = 0; i < message.hpLoadout.Length; i++) { for (int j = 0; j < message.hpLoadout[i].missileUIDS.Length; j++) { if (message.hpLoadout[i].missileUIDS[j] != 0) { //Storing the old one ulong clientsUID = message.hpLoadout[i].missileUIDS[j]; //Generating a new global UID for that missile message.hpLoadout[i].missileUIDS[j] = Networker.GenerateNetworkUID(); //Sending it back to that client NetworkSenderThread.Instance.SendPacketToSpecificPlayer(spawnerSteamId, new Message_RequestNetworkUID(clientsUID, message.hpLoadout[i].missileUIDS[j]), EP2PSend.k_EP2PSendReliable); } } } Debug.Log("Telling other clients about new player and new player about other clients. Player count = " + players.Count); for (int i = 0; i < players.Count; i++) { if (players[i].cSteamID == SteamUser.GetSteamID()) { //Debug.LogWarning("Skiping this one as it's the host"); //Send the host player to the new player. //Debug.Log($"Running host code to tell new player about host vehicle."); GameObject localVehicle = VTOLAPI.GetPlayersVehicleGameObject(); WeaponManager localWeaponManager = localVehicle.GetComponent <WeaponManager>(); List <HPInfo> hpInfos = PlaneEquippableManager.generateHpInfoListFromWeaponManager(localWeaponManager, PlaneEquippableManager.HPInfoListGenerateNetworkType.sender); CountermeasureManager cmManager = localVehicle.GetComponentInChildren <CountermeasureManager>(); List <int> cm = PlaneEquippableManager.generateCounterMeasuresFromCmManager(cmManager); float fuel = PlaneEquippableManager.generateLocalFuelValue(); NetworkSenderThread.Instance.SendPacketToSpecificPlayer(spawnerSteamId, new Message_SpawnPlayerVehicle( players[i].vehicleType, VTMapManager.WorldToGlobalPoint(players[i].vehicle.transform.position), players[i].vehicle.transform.rotation, players[i].cSteamID.m_SteamID, players[i].vehicleUID, hpInfos.ToArray(), cm.ToArray(), fuel, players[i].leftie), EP2PSend.k_EP2PSendReliable); //Debug.Log($"We have told the new player about the host and NOT the other way around."); //Debug.Log($"We don't need to resync the host weapons, that's guaranteed to already be up to date."); continue; } if (players[i].vehicle != null) { PlaneNetworker_Receiver existingPlayersPR = players[i].vehicle.GetComponent <PlaneNetworker_Receiver>(); //We first send the new player to an existing spawned in player NetworkSenderThread.Instance.SendPacketToSpecificPlayer(players[i].cSteamID, message, EP2PSend.k_EP2PSendReliable); //Then we send this current player to the new player. NetworkSenderThread.Instance.SendPacketToSpecificPlayer(spawnerSteamId, new Message_SpawnPlayerVehicle( players[i].vehicleType, VTMapManager.WorldToGlobalPoint(players[i].vehicle.transform.position), players[i].vehicle.transform.rotation, players[i].cSteamID.m_SteamID, players[i].vehicleUID, existingPlayersPR.GenerateHPInfo(), existingPlayersPR.GetCMS(), existingPlayersPR.GetFuel(), players[i].leftie), EP2PSend.k_EP2PSendReliable); //Debug.Log($"We have told {players[i].cSteamID.m_SteamID} about the new player ({message.csteamID}) and the other way round."); //We ask the existing player what their load out just incase the host's player receiver was out of sync. NetworkSenderThread.Instance.SendPacketToSpecificPlayer(players[i].cSteamID, new Message(MessageType.WeaponsSet), EP2PSend.k_EP2PSendReliable); //Debug.Log($"We have asked {players[i].cSteamID.m_SteamID} what their current weapons are, and now waiting for a responce."); // marsh typo response lmao } else { Debug.Log("players[" + i + "].vehicle is null"); } } } if (Networker.isHost) { Debug.Log("Telling connected client about AI units"); AIManager.TellClientAboutAI(spawnerSteamId); } AddToPlayerList(new Player(spawnerSteamId, null, message.vehicle, message.networkID, message.leftie)); GameObject puppet = SpawnRepresentation(message.networkID, message.position, message.rotation, message.leftie); if (puppet != null) { PlaneEquippableManager.SetLoadout(puppet, message.networkID, message.normalizedFuel, message.hpLoadout, message.cmLoadout); } }
public override void Start(FlybyCameraMFDPage mfdPage) { tgpMFD = VTOLAPI.GetPlayersVehicleGameObject().GetComponentInChildren <TargetingMFDPage>(); }
IEnumerator RespawnTimer() { Debug.Log("Starting respawn timer."); GameObject button = Multiplayer.CreateVehicleButton(); yield return(new WaitForSeconds(respawnTimer)); Destroy(button); Debug.Log("Finished respawn timer."); ReArmingPoint[] rearmPoints = GameObject.FindObjectsOfType <ReArmingPoint>(); ReArmingPoint rearmPoint = rearmPoints[Random.Range(0, rearmPoints.Length - 1)]; float lastRadius = 0; if (PlayerManager.carrierStart) { foreach (ReArmingPoint rep in rearmPoints) { if (rep.team == Teams.Allied) { if (rep.radius > 17.8f && rep.radius < 19.0f) { rearmPoint = rep; } } } } else { foreach (ReArmingPoint rep in rearmPoints) { Debug.Log("finding rearm pt"); if (rep.team == Teams.Allied && rep.CheckIsClear(actor)) { if (rep.radius > lastRadius) { rearmPoint = rep; lastRadius = rep.radius; } } } } //UnEject(); //PutPlayerBackInAircraft(); //RepairAircraft(); //foreach (GearAnimator gear in gears) { // gear.ExtendImmediate(); //} //GetComponent<Rigidbody>().velocity = Vector3.zero; //transform.position = rearmPoint.transform.position + Vector3.up * 10; //transform.rotation = rearmPoint.transform.rotation; Destroy(VTOLAPI.GetPlayersVehicleGameObject()); Destroy(detacher.cameraRig); Destroy(detacher.gameObject); Destroy(ejection.gameObject); Destroy(BlackoutEffect.instance); Destroy(GetComponent <PlayerSpawn>()); foreach (EngineEffects effect in effects) { Destroy(effect); } //as much stuff as im destroying, some stuff is most likely getting through, future people, look into this AudioController.instance.ClearAllOpenings(); UnitIconManager.instance.UnregisterAll(); TargetManager.instance.detectedByAllies.Clear(); TargetManager.instance.detectedByEnemies.Clear(); foreach (var actor in TargetManager.instance.allActors) { if (actor != null) { actor.discovered = false; actor.drawIcon = true; //actor.DiscoverActor(); actor.permanentDiscovery = true; Traverse.Create(actor).Field("detectedByAllied").SetValue(false); Traverse.Create(actor).Field("detectedByEnemy").SetValue(false); if (actor.team == Teams.Allied) { actor.DetectActor(Teams.Allied); actor.UpdateKnownPosition(actor.team); } //actor.DiscoverActor(); <----------------breaks and only works on every 2nd spawn // UnitIconManager.instance.RegisterIcon(actor, 0.07f * actor.iconScale, actor.iconOffset); } } if (PlayerManager.selectedVehicle == "FA-26B") { PlayerManager.selectedVehicle = "F/A-26B"; } PilotSaveManager.currentVehicle = VTResources.GetPlayerVehicle(PlayerManager.selectedVehicle); string campID; if (PlayerManager.selectedVehicle == "AV-42C") { campID = "av42cQuickFlight"; } else if (PlayerManager.selectedVehicle == "F/A-26B") { campID = "fa26bFreeFlight"; } else { campID = "f45-quickFlight"; } Campaign campref = VTResources.GetBuiltInCampaign(campID).ToIngameCampaign(); PilotSaveManager.currentCampaign = campref; if (PilotSaveManager.currentVehicle == null) { Debug.LogError("current vehicle is null"); } GameObject newPlayer = Instantiate(PilotSaveManager.currentVehicle.vehiclePrefab); if (newPlayer == null) { Debug.LogError("new vehicle is null"); } newPlayer.GetComponent <Actor>().designation = FlightSceneManager.instance.playerActor.designation;//reassigning designation FlightSceneManager.instance.playerActor = newPlayer.GetComponent <Actor>(); FlightSceneManager.instance.playerActor.flightInfo.PauseGCalculations(); FlightSceneManager.instance.playerActor.flightInfo.OverrideRecordedAcceleration(Vector3.zero); rearmPoint.voiceProfile.PlayMessage(GroundCrewVoiceProfile.GroundCrewMessages.Success); PilotSaveManager.currentScenario.totalBudget = 999999; PilotSaveManager.currentScenario.initialSpending = 0; PilotSaveManager.currentScenario.inFlightSpending = 0; PilotSaveManager.currentScenario.equipConfigurable = true; PlayerVehicleSetup pvSetup = newPlayer.GetComponent <PlayerVehicleSetup>(); pvSetup.SetupForFlight(); Rigidbody rb = newPlayer.GetComponent <Rigidbody>(); GearAnimator gearAnim = newPlayer.GetComponent <GearAnimator>(); if (gearAnim != null) { if (gearAnim.state != GearAnimator.GearStates.Extended) { gearAnim.ExtendImmediate(); } } // PlayerManager.StartRearm(rearmPoint); //rb.velocity = Vector3.zero; //rb.detectCollisions = true; PlayerManager.SpawnLocalVehicleAndInformOtherClients(newPlayer, newPlayer.transform.position, newPlayer.transform.rotation, networkUID); //PlayerManager.SetupLocalAircraft(newPlayer, newPlayer.transform.position, newPlayer.transform.rotation, networkUID); lastMessage.UID = networkUID; lastMessage.isLeftie = PlayerManager.teamLeftie; lastMessage.tagName = Steamworks.SteamFriends.GetPersonaName(); lastMessage.vehicle = VTOLAPI.GetPlayersVehicleEnum(); if (Networker.isHost) { NetworkSenderThread.Instance.SendPacketAsHostToAllClients(lastMessage, Steamworks.EP2PSend.k_EP2PSendReliable); } else { NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, lastMessage, Steamworks.EP2PSend.k_EP2PSendReliable); } }