コード例 #1
0
        public override void OnMeshBuild()
        {
            Dictionary <String, Double> densities = new Dictionary <String, Double>();

            for (Int32 i = 0; i < _landControls.Length; i++)
            {
                if (!(lcScatterListField.GetValue(_landControls[i]) is Double[] lcScatterList))
                {
                    continue;
                }

                for (Int32 j = 0; j < _landControls[i].scatters.Length; j++)
                {
                    if (lcScatterList[j] <= 0)
                    {
                        continue;
                    }

                    PQSLandControl.LandClassScatter scatter = _landControls[i].scatters[j];
                    if (densities.ContainsKey(scatter.scatterName))
                    {
                        densities[scatter.scatterName] = lcScatterList[j];
                    }
                    else
                    {
                        densities.Add(scatter.scatterName, lcScatterList[j]);
                    }
                }
            }
            _quad.gameObject.AddOrGetComponent <DensityContainer>().densities = densities;
        }
コード例 #2
0
                    // Default Constructor
                    public LandClassScatterLoader()
                    {
                        scatter = new PQSLandControl.LandClassScatter();

                        // Initialize default parameters
                        scatter.maxCache      = 512;
                        scatter.maxCacheDelta = 32;
                        scatter.maxSpeed      = 1000;
                    }
コード例 #3
0
ファイル: Scatter.cs プロジェクト: Gerry1135/Kopernicus
            /// <summary>
            /// Create colliders for the scatter
            /// </summary>
            void Start()
            {
                // Register us as the parental object for the scatter
                PQSLandControl landControl = transform.parent.GetComponentInChildren <PQSLandControl>();

                PQSLandControl.LandClassScatter scatter = landControl.scatters.First(s => s.scatterName == name.Split(' ').Last());
                scatter.GetType().GetField("scatterParent", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(scatter, gameObject);

                // The ConfigNode is lost, so find it again!
                PSystemBody body = PSystemManager.Instance.systemPrefab.GetComponentsInChildren <PSystemBody>(true).First(b => b.name == transform.parent.name);

                experiment = body.pqsVersion.gameObject.GetChild(name).GetComponent <Scatter>().experiment;
            }
コード例 #4
0
                    // Runtime constructor
                    public LandClassScatterLoader(PQSLandControl.LandClassScatter scatter)
                    {
                        if (scatter != null)
                        {
                            this.scatter = scatter;
                        }
                        else
                        {
                            this.scatter = new PQSLandControl.LandClassScatter();

                            // Initialize default parameters
                            scatter.maxCache      = 512;
                            scatter.maxCacheDelta = 32;
                            scatter.maxSpeed      = 1000;
                        }
                    }
コード例 #5
0
            /// <summary>
            /// Create colliders for the scatter
            /// </summary>
            void Start()
            {
                // Register us as the parental object for the scatter
                landControl             = transform.parent.GetComponent <PQSLandControl>();
                transform.parent        = landControl.sphere.transform;
                transform.localPosition = Vector3.zero;
                transform.localRotation = Quaternion.identity;
                transform.localScale    = Vector3.one;
                scatter = landControl.scatters.FirstOrDefault(s => s.scatterName == scatter.scatterName); // I hate Unity
                typeof(PQSLandControl.LandClassScatter).GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                .FirstOrDefault(f => f.FieldType == typeof(GameObject))?.SetValue(scatter, gameObject);

                // Call the modules
                Components.ForEach(c => c.Apply(this));
                Components.ForEach(c => c.PostApply(this));
            }
コード例 #6
0
ファイル: ModularScatter.cs プロジェクト: ysdavy/Kopernicus
        private void Start()
        {
            // Apply the modules
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].Apply(this);
            }

            // Register us as the parental object for the scatter
            landControl             = transform.parent.GetComponent <PQSLandControl>();
            transform.parent        = landControl.sphere.transform;
            transform.localPosition = Vector3.zero;
            transform.localRotation = Quaternion.identity;
            transform.localScale    = Vector3.one;
            scatter = landControl.scatters.First(s => s.scatterName == scatter.scatterName); // I hate Unity
            typeof(PQSLandControl.LandClassScatter).GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
            .FirstOrDefault(f => f.FieldType == typeof(GameObject))?.SetValue(scatter, gameObject);
            scatterObjects = new List <GameObject>();
            body           = Part.GetComponentUpwards <CelestialBody>(landControl.gameObject);
            GameEvents.onGameSceneLoadRequested.Add(OnGameSceneLoadRequested);
            if (!baseMesh && meshes.Count > 0)
            {
                baseMesh = meshes[0];
            }

            // Generate a dummy mesh that is used to replace the mesh KSP want's to render itself.
            if (!_cubeMesh)
            {
                Vector3[] vertices =
                {
                    new Vector3(0, 0, 0),
                    new Vector3(1, 0, 0),
                    new Vector3(1, 1, 0),
                    new Vector3(0, 1, 0),
                    new Vector3(0, 1, 1),
                    new Vector3(1, 1, 1),
                    new Vector3(1, 0, 1),
                    new Vector3(0, 0, 1),
                };

                Int32[] triangles =
                {
                    0, 2, 1, //face front
                    0, 3, 2,
                    2, 3, 4, //face top
                    2, 4, 5,
                    1, 2, 5, //face right
                    1, 5, 6,
                    0, 7, 4, //face left
                    0, 4, 3,
                    5, 4, 7, //face back
                    5, 7, 6,
                    0, 6, 7, //face bottom
                    0, 1, 6
                };

                _cubeMesh = new Mesh {
                    vertices = vertices, triangles = triangles, name = "Kopernicus-CubeDummy"
                };
            }

            scatter.baseMesh = _cubeMesh;

            // PostApply for the Modules
            for (int i = 0; i < Components.Count; i++)
            {
                Components[i].PostApply(this);
            }
        }
コード例 #7
0
ファイル: LandControl.cs プロジェクト: KillAshley/Kopernicus
 public LandClassScatterLoader(PQSLandControl.LandClassScatter scatter)
 {
     this.scatter = scatter;
 }
コード例 #8
0
ファイル: LandControl.cs プロジェクト: KillAshley/Kopernicus
                    public LandClassScatterLoader()
                    {
                        scatter = new PQSLandControl.LandClassScatter();

                        // Initialize default parameters
                        scatter.maxCache = 512;
                        scatter.maxCacheDelta = 32;
                        scatter.maxSpeed = 1000;
                    }