private void DrawOdysseyDebugMenu() { if (GUILayout.Button("Spawn Odyssey")) { GameObject gameObject = OdysseyMod.CreateOdyssey(); odyssey = gameObject.GetComponent <OdysseySubmarine>(); gameObject.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 6f; gameObject.transform.LookAt(Player.main.transform); } if (GUILayout.Button("Connect to odyssey on cursor")) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit)) { if (hit.rigidbody.gameObject.name.ToLower().Contains("odyssey")) { odyssey = hit.rigidbody.gameObject.GetComponent <OdysseySubmarine>(); } } } if (GUILayout.Button("Odyssey Count")) { OdysseySubmarine[] submarines = FindObjectsOfType <OdysseySubmarine>(); Log.Print("Found " + submarines.Length + " Odysseys"); } if (GUILayout.Button("Delete All Odysseys")) { OdysseySubmarine[] submarines = FindObjectsOfType <OdysseySubmarine>(); Log.Print("Found " + submarines.Length + " Odysseys to delete"); foreach (OdysseySubmarine s in submarines) { Destroy(s.gameObject); } } if (odyssey == null) { GUILayout.Box("No Odyssey Connected"); return; } }
/** * If the component requires other custom components then do it here. * Read the comment on Components.OdyseeySeializationFixer if you wish to understand why this horrible system exists. */ public static void SetUpOdyssey(GameObject submarine) { OdysseySubmarine odysseySubmarine = submarine.GetComponent <OdysseySubmarine>(); Transform applyForceLocation = submarine.FindChild("PointsOfInterest").FindChild("ForceAppliedLocation").transform; MovementController movementController = submarine.GetOrAddComponent <MovementController>(); movementController.ApplyForceLocation = applyForceLocation; GameObject doorLeft = submarine.FindChild("PointsOfInterest").FindChild("LeftDoorFlap"); doorLeft.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>(); HingeJointDoor hingeDoorLeft = doorLeft.GetOrAddComponent <HingeJointDoor>(); hingeDoorLeft.OverwriteTargetVelocity = true; hingeDoorLeft.TargetVelocity = 130f; hingeDoorLeft.TriggerToEverything = false; hingeDoorLeft.TriggerToPlayer = true; hingeDoorLeft.TriggerToVehicles = false; hingeDoorLeft.OpenSound = CyclopsDefaultAssets.PLAYER_HATCH_OPEN; hingeDoorLeft.CloseSound = CyclopsDefaultAssets.PLAYER_HATCH_CLOSE; GameObject doorRight = submarine.FindChild("PointsOfInterest").FindChild("RightDoorFlap"); doorRight.GetComponentInChildren <HingeJoint>().connectedBody = submarine.GetComponent <Rigidbody>(); HingeJointDoor hingeDoorRight = doorRight.GetOrAddComponent <HingeJointDoor>(); hingeDoorRight.OverwriteTargetVelocity = true; hingeDoorRight.TargetVelocity = 130f; hingeDoorRight.TriggerToEverything = false; hingeDoorRight.TriggerToPlayer = true; hingeDoorRight.TriggerToVehicles = false; hingeDoorRight.OpenSound = CyclopsDefaultAssets.PLAYER_HATCH_OPEN; hingeDoorRight.CloseSound = CyclopsDefaultAssets.PLAYER_HATCH_CLOSE; GameObject entrancePosition = submarine.FindChild("PointsOfInterest").FindChild("EntranceTeleportSpot"); GameObject entranceHatch = submarine.FindChild("PointsOfInterest").FindChild("Enter"); EntranceHatch entranceHatchTeleport = entranceHatch.GetOrAddComponent <EntranceHatch>(); entranceHatchTeleport.HoverText = "Board Odyssey"; entranceHatchTeleport.HoverHandReticle = HandReticle.IconType.Hand; entranceHatchTeleport.TeleportTarget = entrancePosition; entranceHatchTeleport.Submarine = odysseySubmarine; entranceHatchTeleport.EnteringSubmarine = true; GameObject leavePosition = submarine.FindChild("PointsOfInterest").FindChild("ExitTeleportSpot"); GameObject leaveHatch = submarine.FindChild("PointsOfInterest").FindChild("Exit"); EntranceHatch leaveHatchTeleport = leaveHatch.GetOrAddComponent <EntranceHatch>(); leaveHatchTeleport.HoverText = "Disembark Odyssey"; leaveHatchTeleport.HoverHandReticle = HandReticle.IconType.Hand; leaveHatchTeleport.TeleportTarget = leavePosition; leaveHatchTeleport.Submarine = odysseySubmarine; leaveHatchTeleport.EnteringSubmarine = false; GameObject steeringConsolePOI = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole"); GameObject playerParentWhilePiloting = submarine.FindChild("PointsOfInterest").FindChild("SteeringConsole").FindChild("PlayerLockedWhileSteeringPosition"); SteeringConsole steeringConsole = steeringConsolePOI.GetOrAddComponent <SteeringConsole>(); steeringConsole.MovementController = submarine.GetComponent <MovementController>(); steeringConsole.ParentWhilePilotingGO = playerParentWhilePiloting; steeringConsole.LeftHandIKTarget = null; steeringConsole.RightHandIKTarget = null; steeringConsole.Submarine = odysseySubmarine; CyclopsCollisionSounds collisionSounds = submarine.GetOrAddComponent <CyclopsCollisionSounds>(); MovementData normalSpeedMovementData = new MovementData { ForwardAccelerationSpeed = 10f, BackwardsAccelerationSpeed = 8f, AscendDescendSpeed = 15f, RotationSpeed = 0.7f }; EngineManager engineManager = submarine.GetOrAddComponent <EngineManager>(); engineManager.SetMovementDataForEngineState(EngineState.SLOW, normalSpeedMovementData); engineManager.SetMovementDataForEngineState(EngineState.NORMAL, normalSpeedMovementData); engineManager.SetMovementDataForEngineState(EngineState.FAST, normalSpeedMovementData); engineManager.SetMovementDataForEngineState(EngineState.SPECIAL, normalSpeedMovementData); CyclopsStartupPowerDownSequence cyclopsStartupPowerDownSequence = submarine.GetOrAddComponent <CyclopsStartupPowerDownSequence>(); CyclopsEngineStateChangedCallouts cyclopsEngineStateChangedCallouts = submarine.GetOrAddComponent <CyclopsEngineStateChangedCallouts>(); movementController.EngineManager = engineManager; CyclopsWelcomeCallout cyclopsWelcomeCallout = submarine.GetOrAddComponent <CyclopsWelcomeCallout>(); CyclopsEngineSound cyclopsEngineSound = submarine.GetOrAddComponent <CyclopsEngineSound>(); cyclopsEngineSound.RampUpSpeed = 0.2f; cyclopsEngineSound.RampDownSpeed = 0.2f; movementController.EngineSound = cyclopsEngineSound; OxygenReplenishment oxygenReplenishment = submarine.GetOrAddComponent <OxygenReplenishment>(); oxygenReplenishment.OxygenPerSecond = 15f; oxygenReplenishment.OxygenEnergyCost = 0.1f; }