コード例 #1
0
        public static MTuple Make(GameObject body, AstroObject primaryBody, IPlanetConfig config)
        {
            Rigidbody RB = body.AddComponent <Rigidbody>();

            RB.mass                   = 10000;
            RB.drag                   = 0f;
            RB.angularDrag            = 0f;
            RB.useGravity             = false;
            RB.isKinematic            = true;
            RB.interpolation          = RigidbodyInterpolation.None;
            RB.collisionDetectionMode = CollisionDetectionMode.Discrete;

            OWRigidbody OWRB = body.AddComponent <OWRigidbody>();

            OWRB.SetValue("_kinematicSimulation", true);
            OWRB.SetValue("_autoGenerateCenterOfMass", true);
            OWRB.SetIsTargetable(true);
            OWRB.SetValue("_maintainOriginalCenterOfMass", true);
            OWRB.SetValue("_rigidbody", RB);

            InitialMotion IM = body.AddComponent <InitialMotion>();

            IM.SetPrimaryBody(primaryBody.GetAttachedOWRigidbody());
            IM.SetValue("_orbitAngle", config.OrbitAngle);
            IM.SetValue("_isGlobalAxis", false);
            IM.SetValue("_initAngularSpeed", 0.02f);
            IM.SetValue("_initLinearSpeed", 0f);

            DetectorBuilder.Make(body, primaryBody);

            AstroObject AO = body.AddComponent <AstroObject>();

            AO.SetValue("_type", AstroObject.Type.Planet);
            AO.SetValue("_name", AstroObject.Name.None);
            AO.SetValue("_primaryBody", primaryBody);
            if (config.HasGravity)
            {
                GravityVolume GV = GravityBuilder.Make(body, config.SurfaceAcceleration, config.GroundSize, config.GroundSize);
                AO.SetValue("_gravityVolume", GV);
            }

            if (config.IsTidallyLocked)
            {
                RotateToAstroObject RTAO = body.AddComponent <RotateToAstroObject>();
                RTAO.SetValue("_astroObjectLock", primaryBody);
            }

            Logger.Log("Finished building base", Logger.LogType.Log);
            return(new MTuple(AO, OWRB));
        }
コード例 #2
0
        public static void Make(GameObject body, AstroObject primaryBody, float angularSpeed, bool hasGravity, float surfaceAccel, float groundSize, bool hasOrbit)
        {
            if (hasOrbit)
            {
                Rigidbody RB = body.AddComponent <Rigidbody>();
                RB.mass                   = 10000;
                RB.drag                   = 0f;
                RB.angularDrag            = 0f;
                RB.useGravity             = false;
                RB.isKinematic            = true;
                RB.interpolation          = RigidbodyInterpolation.None;
                RB.collisionDetectionMode = CollisionDetectionMode.Discrete;

                MainClass.OWRB = body.AddComponent <OWRigidbody>();
                MainClass.OWRB.SetValue("_kinematicSimulation", true);
                MainClass.OWRB.SetValue("_autoGenerateCenterOfMass", true);
                MainClass.OWRB.SetIsTargetable(true);
                MainClass.OWRB.SetValue("_maintainOriginalCenterOfMass", true);

                InitialMotion IM = body.AddComponent <InitialMotion>();
                IM.SetPrimaryBody(primaryBody.GetAttachedOWRigidbody());
                IM.SetValue("_orbitAngle", 0f);
                IM.SetValue("_isGlobalAxis", false);
                IM.SetValue("_initAngularSpeed", angularSpeed);
                IM.SetValue("_initLinearSpeed", 0f);
                IM.SetValue("_isGlobalAxis", false);

                MakeFieldDetector.Make(body);
            }

            if (hasGravity)
            {
                GravityVolume GV = MakeGravityWell.Make(body, surfaceAccel, groundSize, groundSize);
            }


            AstroObject AO = body.AddComponent <AstroObject>();

            AO.SetValue("_type", AstroObject.Type.Planet);
            AO.SetValue("_name", AstroObject.Name.InvisiblePlanet);
            AO.SetPrimaryBody(primaryBody);
            if (hasGravity)
            {
                GravityVolume GV = MakeGravityWell.Make(body, surfaceAccel, groundSize, groundSize);
                AO.SetValue("_gravityVolume", GV);
            }
        }
コード例 #3
0
        public static void Make(GameObject body, AstroObject primaryBody)
        {
            GameObject detectorGO = new GameObject();

            detectorGO.SetActive(false);
            detectorGO.name             = "FieldDetector";
            detectorGO.transform.parent = body.transform;
            detectorGO.layer            = 20;

            ConstantForceDetector CFD = detectorGO.AddComponent <ConstantForceDetector>();

            ForceVolume[] temp = new ForceVolume[1];
            temp[0] = primaryBody.GetAttachedOWRigidbody().GetAttachedGravityVolume();
            CFD.SetValue("_detectableFields", temp);
            CFD.SetValue("_inheritElement0", true);

            detectorGO.SetActive(true);
            Logger.Log("Finished building detector", Logger.LogType.Log);
        }