Пример #1
0
        /// <summary>
        /// Removes the wreck model from an KSC Object.
        /// </summary>
        internal static void MangleSquadStatic(GameObject gameObject)
        {
            gameObject.transform.parent = null;

            foreach (var component in gameObject.GetComponentsInChildren <MonoBehaviour>(true))
            {
                if (behavioursToRemove.Contains(component.GetType()))
                {
                    //     Log.Normal("Removed: " + bla.GetType().ToString());
                    UnityEngine.Object.Destroy(component);
                }
            }


            var transforms = gameObject.transform.GetComponentsInChildren <Transform>(true);

            foreach (var transform in transforms)
            {
                if (transform.name.Equals("wreck", StringComparison.InvariantCultureIgnoreCase))
                {
                    transform.parent = null;
                    GameObject.Destroy(transform.gameObject);
                }

                //if (transform.name.Equals("commnetnode", StringComparison.InvariantCultureIgnoreCase))
                //{
                //    transform.parent = null;
                //    GameObject.Destroy(transform.gameObject);
                //}
            }

            TimeOfDayAnimation dotAnim = gameObject.AddComponent <TimeOfDayAnimation>();

            dotAnim.emissives = new List <TimeOfDayAnimation.MaterialProperty>();
            foreach (var renderer in gameObject.GetComponentsInChildren <Renderer>(true))
            {
                foreach (Material mat in renderer.materials)
                {
                    // Log.Normal("found Material: " + gameObject.name +" " +  mat.name);
                    foreach (string matname in materialPropertyNames)
                    {
                        if (mat.name.Contains(matname) && mat.HasProperty(dotPoperty))
                        {
                            //Log.Normal("added Materialproperty to: " + gameObject.name + " "+ mat.name);

                            TimeOfDayAnimation.MaterialProperty mp = new TimeOfDayAnimation.MaterialProperty();
                            mp.material     = mat;
                            mp.propertyName = dotPoperty;
                            mp.isDirty      = true;
                            dotAnim.emissives.Add(mp);
                            break;
                        }
                    }
                }
            }
            dotAnim.emissiveTgtColor      = dotColor;
            dotAnim.emissiveColorProperty = dotPoperty;
            dotAnim.emissivesCurve        = dotAnimationCurve;
            dotAnim.enabled = true;
        }
Пример #2
0
        /// <summary>
        /// Removes some unneeded behaviours from squad models and sets up the Destructibles
        /// </summary>
        internal static void MangleSquadStatic(StaticInstance instance)
        {
            GameObject gameObject = instance.mesh;

            //Log.Normal("Called for:" + instance.gameObject.name);

            foreach (var component in gameObject.GetComponentsInChildren <MonoBehaviour>(true))
            {
                if (behavioursToRemove.Contains(component.GetType()))
                {
                    //Log.Normal("Removed: " + component.GetType().ToString());
                    UnityEngine.Object.DestroyImmediate(component);
                }
            }

            //instance.gameObject.tag = String.Empty;

            //foreach (Transform transform in gameObject.transform.GetComponentsInChildren<Transform>(true))
            //{
            //    //transform.gameObject.tag = String.Empty;
            //    if (transform.name.Equals("wreck", StringComparison.InvariantCultureIgnoreCase))
            //    {
            //        transform.parent = null;
            //        GameObject.Destroy(transform.gameObject);
            //    }

            //    //if (transform.name.Equals("commnetnode", StringComparison.InvariantCultureIgnoreCase))
            //    //{
            //    //    transform.parent = null;
            //    //    GameObject.Destroy(transform.gameObject);
            //    //}
            //}
            int counter = 0;

            foreach (var component in gameObject.GetComponentsInChildren <DestructibleBuilding>(true))
            {
                component.id            = instance.UUID + "_" + counter;
                component.preCompiledId = true;
                instance.destructible   = component;
                //Log.Normal("registering destructible: " + component.id);
                counter++;
            }


            TimeOfDayAnimation dotAnim = gameObject.AddComponent <TimeOfDayAnimation>();

            dotAnim.emissives = new List <TimeOfDayAnimation.MaterialProperty>();
            foreach (var renderer in gameObject.GetComponentsInChildren <Renderer>(true))
            {
                foreach (Material mat in renderer.materials)
                {
                    // Log.Normal("found Material: " + gameObject.name +" " +  mat.name);
                    foreach (string matname in materialPropertyNames)
                    {
                        if (mat.name.Contains(matname))
                        //if (mat.name.Contains(matname) && mat.HasProperty(dotPoperty))
                        {
                            //Log.Normal("added Materialproperty to: " + gameObject.name + " "+ mat.name);

                            TimeOfDayAnimation.MaterialProperty mp = new TimeOfDayAnimation.MaterialProperty();
                            mp.material     = mat;
                            mp.propertyName = dotPoperty;
                            mp.isDirty      = true;
                            dotAnim.emissives.Add(mp);
                            break;
                        }
                    }
                }
            }
            dotAnim.emissiveTgtColor      = dotColor;
            dotAnim.emissiveColorProperty = dotPoperty;
            dotAnim.emissivesCurve        = dotAnimationCurve;
            dotAnim.enabled = true;

            // Lv3 Tracking Dish Animation
            if (instance.model.name == "SQUAD_LV3_Tracking_Dish")
            {
                DishController controller = gameObject.AddComponent <DishController>();

                controller.fakeTimeWarp = 1f;
                controller.maxSpeed     = 2 / instance.ModelScale;
                controller.maxElevation = 90f;
                controller.minElevation = 5f;

                DishController.Dish dish = new DishController.Dish();
                dish.rotationTransform  = gameObject.transform.FindRecursive("Lower Assembly");
                dish.elevationTransform = gameObject.transform.FindRecursive("Satellite Dish");
                controller.dishes       = new DishController.Dish[] { dish };
                controller.enabled      = true;
            }

            if (instance.model.name == "KSC_FuelTank")
            {
                //Log.Normal("Fixing KSC Fuel Tank");
                GameObject oldGameObject = instance.mesh;
                GameObject newBaseObject = new GameObject(instance.model.name);
                oldGameObject.transform.parent           = newBaseObject.transform;
                oldGameObject.transform.localEulerAngles = new Vector3(270, 0, 0);
                instance.mesh = newBaseObject;
            }
        }
Пример #3
0
        /// <summary>
        /// Removes the wreck model from an KSC Object.
        /// </summary>
        internal static void MangleSquadStatic(StaticInstance instance)
        {
            GameObject gameObject = instance.gameObject;

            gameObject.transform.parent = null;
            foreach (var component in gameObject.GetComponentsInChildren <MonoBehaviour>(true))
            {
                if (behavioursToRemove.Contains(component.GetType()))
                {
                    //     Log.Normal("Removed: " + bla.GetType().ToString());
                    UnityEngine.Object.Destroy(component);
                }
            }


            var transforms = gameObject.transform.GetComponentsInChildren <Transform>(true);

            foreach (var transform in transforms)
            {
                if (transform.name.Equals("wreck", StringComparison.InvariantCultureIgnoreCase))
                {
                    transform.parent = null;
                    GameObject.Destroy(transform.gameObject);
                }

                //if (transform.name.Equals("commnetnode", StringComparison.InvariantCultureIgnoreCase))
                //{
                //    transform.parent = null;
                //    GameObject.Destroy(transform.gameObject);
                //}
            }

            TimeOfDayAnimation dotAnim = gameObject.AddComponent <TimeOfDayAnimation>();

            dotAnim.emissives = new List <TimeOfDayAnimation.MaterialProperty>();
            foreach (var renderer in gameObject.GetComponentsInChildren <Renderer>(true))
            {
                foreach (Material mat in renderer.materials)
                {
                    // Log.Normal("found Material: " + gameObject.name +" " +  mat.name);
                    foreach (string matname in materialPropertyNames)
                    {
                        if (mat.name.Contains(matname) && mat.HasProperty(dotPoperty))
                        {
                            //Log.Normal("added Materialproperty to: " + gameObject.name + " "+ mat.name);

                            TimeOfDayAnimation.MaterialProperty mp = new TimeOfDayAnimation.MaterialProperty();
                            mp.material     = mat;
                            mp.propertyName = dotPoperty;
                            mp.isDirty      = true;
                            dotAnim.emissives.Add(mp);
                            break;
                        }
                    }
                }
            }
            dotAnim.emissiveTgtColor      = dotColor;
            dotAnim.emissiveColorProperty = dotPoperty;
            dotAnim.emissivesCurve        = dotAnimationCurve;
            dotAnim.enabled = true;

            // Lv3 Tracking Dish Animation
            if (instance.model.name == "SQUAD_LV3_Tracking_Dish")
            {
                DishController controller = gameObject.AddComponent <DishController>();

                controller.fakeTimeWarp = 1f;
                controller.maxSpeed     = 2 / instance.ModelScale;
                controller.maxElevation = 90f;
                controller.minElevation = 5f;

                DishController.Dish dish = new DishController.Dish();
                dish.rotationTransform  = gameObject.transform.FindRecursive("Lower Assembly");
                dish.elevationTransform = gameObject.transform.FindRecursive("Satellite Dish");
                controller.dishes       = new DishController.Dish[] { dish };
                controller.enabled      = true;
            }


            //if (instance.model.name == "KSC_Runway_level_2")
            //{
            //    SquadStatics.PimpLv2Runway(instance.gameObject);
            //}
        }