Esempio n. 1
0
        public static void Make(GameObject body)
        {
            GameObject RFVolume = new GameObject();

            RFVolume.name             = "RFVolume";
            RFVolume.transform.parent = body.transform;
            RFVolume.layer            = 19;
            RFVolume.SetActive(false);

            SphereCollider RF_SC = RFVolume.AddComponent <SphereCollider>();

            RF_SC.isTrigger = true;
            RF_SC.radius    = 600f;

            ReferenceFrameVolume RF_RFV = RFVolume.AddComponent <ReferenceFrameVolume>();
            ReferenceFrame       test   = new ReferenceFrame(MainClass.OWRB);

            test.SetValue("_minSuitTargetDistance", 300);
            test.SetValue("_maxTargetDistance", 0);
            test.SetValue("_autopilotArrivalDistance", 1000);
            test.SetValue("_autoAlignmentDistance", 1000);
            test.SetValue("_hideLandingModePrompt", false);
            test.SetValue("_matchAngularVelocity", true);
            test.SetValue("_minMatchAngularVelocityDistance", 70);
            test.SetValue("_maxMatchAngularVelocityDistance", 400);
            test.SetValue("_bracketsRadius", 300);
            RF_RFV.SetValue("_referenceFrame", test);
            RF_RFV.SetValue("_minColliderRadius", 300);
            RF_RFV.SetValue("_maxColliderRadius", 2000);
            RF_RFV.SetValue("_isPrimaryVolume", true);
            RF_RFV.SetValue("_isCloseRangeVolume", false);
            RFVolume.SetActive(true);
        }
Esempio n. 2
0
        public static void Make(GameObject body, OWRigidbody rigidbody, IPlanetConfig config)
        {
            GameObject rfGO = new GameObject("RFVolume");

            rfGO.transform.parent = body.transform;
            rfGO.layer            = 19;
            rfGO.SetActive(false);

            SphereCollider SC = rfGO.AddComponent <SphereCollider>();

            SC.isTrigger = true;
            SC.radius    = config.AtmoEndSize * 2;

            ReferenceFrameVolume RFV = rfGO.AddComponent <ReferenceFrameVolume>();

            ReferenceFrame RV = new ReferenceFrame(rigidbody);

            RV.SetValue("_minSuitTargetDistance", 300);
            RV.SetValue("_maxTargetDistance", 0);
            RV.SetValue("_autopilotArrivalDistance", 1000);
            RV.SetValue("_autoAlignmentDistance", 1000);
            //Utility.AddDebugShape.AddSphere(rfGO, 1000, new Color32(0, 255, 0, 128));
            RV.SetValue("_hideLandingModePrompt", false);
            RV.SetValue("_matchAngularVelocity", true);
            RV.SetValue("_minMatchAngularVelocityDistance", 70);
            RV.SetValue("_maxMatchAngularVelocityDistance", 400);
            RV.SetValue("_bracketsRadius", 300);

            RFV.SetValue("_referenceFrame", RV);
            RFV.SetValue("_minColliderRadius", 300);
            RFV.SetValue("_maxColliderRadius", config.AtmoEndSize * 2);
            RFV.SetValue("_isPrimaryVolume", true);
            RFV.SetValue("_isCloseRangeVolume", false);

            rfGO.SetActive(true);
            Logger.Log("Finished building rfvolume", Logger.LogType.Log);
        }
Esempio n. 3
0
        public static bool Moon_ChangeQuantumState(
            QuantumMoon __instance,
            ref bool __result,
            bool skipInstantVisibilityCheck,
            bool ____isPlayerInside,
            bool ____hasSunCollapsed,
            float ____playerWarpTime,
            ref int ____stateIndex,
            ref int ____collapseToIndex,
            QuantumOrbit[] ____orbits,
            float ____sphereCheckRadius,
            VisibilityTracker ____visibilityTracker,
            OWRigidbody ____moonBody,
            ConstantForceDetector ____constantForceDetector,
            ref bool ____useInitialMotion,
            ref int ____lastStateIndex,
            ref int[] ____stateSkipCounts,
            AudioSignal ____quantumSignal,
            ReferenceFrameVolume ____referenceFrameVolume,
            GameObject[] ____deactivateAtEye
            )
        {
            if (QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck) && !QuantumManager.Instance.Shrine.IsPlayerInDarkness())
            {
                if (!skipInstantVisibilityCheck)
                {
                    var method = new StackTrace().GetFrame(3).GetMethod();
                    DebugLog.ToConsole($"Warning - Tried to change moon state while still observed. Called by {method.DeclaringType}.{method.Name}", MessageType.Warning);
                }
                __result = false;
                return(false);
            }
            var flag = false;

            if (____isPlayerInside && ____hasSunCollapsed)
            {
                __result = false;
                return(false);
            }
            if (Time.time - ____playerWarpTime < 1f)
            {
                __result = false;
                return(false);
            }
            if (____stateIndex == 5 && ____isPlayerInside && !__instance.IsPlayerEntangled())
            {
                __result = false;
                return(false);
            }
            for (var i = 0; i < 10; i++)
            {
                var stateIndex = (____collapseToIndex == -1) ? (int)__instance.GetType().GetMethod("GetRandomStateIndex", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, null) : ____collapseToIndex;
                var orbitIndex = -1;
                for (var j = 0; j < ____orbits.Length; j++)
                {
                    if (____orbits[j].GetStateIndex() == stateIndex)
                    {
                        orbitIndex = j;
                        break;
                    }
                }
                if (orbitIndex == -1)
                {
                    DebugLog.ToConsole($"Error - QM failed to find orbit for state {stateIndex}", MessageType.Error);
                }
                var orbitRadius  = (orbitIndex == -1) ? 10000f : ____orbits[orbitIndex].GetOrbitRadius();
                var owRigidbody  = (orbitIndex == -1) ? Locator.GetAstroObject(AstroObject.Name.Sun).GetOWRigidbody() : ____orbits[orbitIndex].GetAttachedOWRigidbody();
                var onUnitSphere = UnityEngine.Random.onUnitSphere;
                if (stateIndex == 5)
                {
                    onUnitSphere.y = 0f;
                    onUnitSphere.Normalize();
                }
                var position = (onUnitSphere * orbitRadius) + owRigidbody.GetWorldCenterOfMass();
                if (!Physics.CheckSphere(position, ____sphereCheckRadius, OWLayerMask.physicalMask) || ____collapseToIndex != -1)
                {
                    ____visibilityTracker.transform.position = position;
                    if (!Physics.autoSyncTransforms)
                    {
                        Physics.SyncTransforms();
                    }
                    if (__instance.IsPlayerEntangled() || !QuantumManager.IsVisibleUsingCameraFrustum((ShapeVisibilityTracker)____visibilityTracker, skipInstantVisibilityCheck))
                    {
                        ____moonBody.transform.position = position;
                        if (!Physics.autoSyncTransforms)
                        {
                            Physics.SyncTransforms();
                        }
                        ____visibilityTracker.transform.localPosition = Vector3.zero;
                        ____constantForceDetector.AddConstantVolume(owRigidbody.GetAttachedGravityVolume(), true, true);
                        var velocity = owRigidbody.GetVelocity();
                        if (____useInitialMotion)
                        {
                            var initialMotion = owRigidbody.GetComponent <InitialMotion>();
                            velocity             = (initialMotion == null) ? Vector3.zero : initialMotion.GetInitVelocity();
                            ____useInitialMotion = false;
                        }
                        var orbitAngle = UnityEngine.Random.Range(0, 360);
                        ____moonBody.SetVelocity(OWPhysics.CalculateOrbitVelocity(owRigidbody, ____moonBody, orbitAngle) + velocity);
                        ____lastStateIndex  = ____stateIndex;
                        ____stateIndex      = stateIndex;
                        ____collapseToIndex = -1;
                        flag = true;
                        for (var k = 0; k < ____stateSkipCounts.Length; k++)
                        {
                            ____stateSkipCounts[k] = (k != ____stateIndex) ? (____stateSkipCounts[k] + 1) : 0;
                        }
                        QSBEventManager.FireEvent(EventNames.QSBMoonStateChange, stateIndex, onUnitSphere, orbitAngle);
                        break;
                    }
                    ____visibilityTracker.transform.localPosition = Vector3.zero;
                }
                else
                {
                    DebugLog.ToConsole("Warning - Quantum moon orbit position occupied! Aborting collapse.", MessageType.Warning);
                }
            }
            if (flag)
            {
                if (____isPlayerInside)
                {
                    __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { ____stateIndex });
                }
                else
                {
                    __instance.GetType().GetMethod("SetSurfaceState", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { -1 });
                    ____quantumSignal.SetSignalActivation(____stateIndex != 5, 2f);
                }
                ____referenceFrameVolume.gameObject.SetActive(____stateIndex != 5);
                ____moonBody.SetIsTargetable(____stateIndex != 5);
                for (var l = 0; l < ____deactivateAtEye.Length; l++)
                {
                    ____deactivateAtEye[l].SetActive(____stateIndex != 5);
                }
                GlobalMessenger <OWRigidbody> .FireEvent("QuantumMoonChangeState", ____moonBody);

                __result = true;
                return(false);
            }
            __result = false;
            return(false);
        }