// Populates required values internal static void Populate() { // Gets unity stuff for (int i = 0; i < 32; i++) { string name = LayerMask.LayerToName(i); if (!name.Equals(string.Empty) && !layers.ContainsKey(name)) { layers.Add(name, i); } } // Obtains objects loaded into the game that might be useful foreach (Mesh mesh in Resources.FindObjectsOfTypeAll <Mesh>()) { if (!mesh.name.Equals(string.Empty) && !originMesh.ContainsKey(mesh.name.Replace("(Instance)", ""))) { originMesh.Add(mesh.name.Replace("(Instance)", ""), mesh); } } foreach (Material mat in Resources.FindObjectsOfTypeAll <Material>()) { if (!mat.name.Equals(string.Empty) && !originMaterial.ContainsKey(mat.name.Replace("(Instance)", "")) && !mat.name.StartsWith("Hidden/") && !materialBlacklist.Contains(mat.name.Replace("(Instance)", ""))) { originMaterial.Add(mat.name.Replace("(Instance)", ""), mat); } } foreach (PhysicMaterial mat in Resources.FindObjectsOfTypeAll <PhysicMaterial>()) { if (!mat.name.Equals(string.Empty) && !originPhysMaterial.ContainsKey(mat.name.Replace("(Instance)", ""))) { originPhysMaterial.Add(mat.name.Replace("(Instance)", ""), mat); } } foreach (Texture tex in Resources.FindObjectsOfTypeAll <Texture>()) { if (!tex.name.Equals(string.Empty) && !originTexture.ContainsKey(tex.name.Replace("(Instance)", ""))) { originTexture.Add(tex.name.Replace("(Instance)", ""), tex); } } foreach (Sprite sprite in Resources.FindObjectsOfTypeAll <Sprite>()) { if (!sprite.name.Equals(string.Empty) && !originSprite.ContainsKey(sprite.name.Replace("(Instance)", ""))) { originSprite.Add(sprite.name.Replace("(Instance)", ""), sprite); } } foreach (AudioClip clip in Resources.FindObjectsOfTypeAll <AudioClip>()) { if (!clip.name.Equals(string.Empty) && !originClips.ContainsKey(clip.name.Replace("(Instance)", ""))) { originClips.Add(clip.name.Replace("(Instance)", ""), clip); } } foreach (SECTR_AudioCue cue in Resources.FindObjectsOfTypeAll <SECTR_AudioCue>()) { if (!cue.name.Equals(string.Empty) && !originCues.ContainsKey(cue.name.Replace("(Instance)", ""))) { originCues.Add(cue.name.Replace("(Instance)", ""), cue); } } foreach (SlimeSounds sound in Resources.FindObjectsOfTypeAll <SlimeSounds>()) { if (!sound.name.Equals(string.Empty) && !originSounds.ContainsKey(sound.name.Replace("(Instance)", ""))) { originSounds.Add(sound.name.Replace("(Instance)", ""), sound); } } foreach (RuntimeAnimatorController animator in Resources.FindObjectsOfTypeAll <RuntimeAnimatorController>()) { if (!animator.name.Equals(string.Empty) && !originAnimators.ContainsKey(animator.name.Replace("(Instance)", ""))) { originAnimators.Add(animator.name.Replace("(Instance)", ""), animator); } } foreach (Avatar avatar in Resources.FindObjectsOfTypeAll <Avatar>()) { if (!avatar.name.Equals(string.Empty) && !originAvatars.ContainsKey(avatar.name.Replace("(Instance)", ""))) { originAvatars.Add(avatar.name.Replace("(Instance)", ""), avatar); } } foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>()) { if (!(obj.name.StartsWith("FX ") || obj.name.StartsWith("fx"))) { continue; } if (!obj.name.Equals(string.Empty) && !originFXs.ContainsKey(obj.name.Replace("(Instance)", ""))) { originFXs.Add(obj.name.Replace("(Instance)", ""), obj); } } // Load Bones originSkinnedMesh.Add("HenSkinned", Director.GetPrefab(Identifiable.Id.HEN).GetChildCopy("Hen Hen/mesh_body1")); originBones.Add("HenBones", Director.GetPrefab(Identifiable.Id.HEN).GetChildCopy("Hen Hen/root")); originBones.Add("SlimeBones", Director.GetPrefab(Identifiable.Id.PINK_SLIME).GetChildCopy("Appearance")); originBones.Add("GordoBones", Director.GetGordo(Identifiable.Id.PINK_GORDO).GetChildCopy("Vibrating")); // Gets the cube for the markers cubeMesh = originMesh["Cube"]; debugSystem = new GameObject("DebugSystem", typeof(DebugSystem)); Object.DontDestroyOnLoad(debugSystem); // Adds markers to objects foreach (GameObject obj in Director.plotPrefabs) { obj.GetReadyForMarker(MarkerType.Plot, 8f); } foreach (GameObject obj in Director.resourceSpawnerPrefabs) { foreach (GameObject child in obj.FindChildrenWithPartialName("SpawnJoint")) { child.GetReadyForMarker(MarkerType.SpawnPoint); } foreach (GameObject child in obj.FindChildrenWithPartialName("NodeLoc")) { child.GetReadyForMarker(MarkerType.DroneNode, 3f); } } // Single Objects splatQuad = Director.GetPrefab(Identifiable.Id.PINK_SLIME).GetComponent <SplatOnImpact>().splatPrefab; // Register Global Template Actions TemplateActions.RegisterAction("buildSlime", AssembleModules); TemplateActions.RegisterAction("populateSlime", PopulateSlimeInfo); // Populates all other object classes GardenObjects.Populate(); TheWildsObjects.Populate(); RanchObjects.Populate(); EffectObjects.Populate(); // Adds Late Populate method SceneManager.sceneLoaded += LatePopulate; }
internal static void LatePopulate(Scene sceneLoaded, LoadSceneMode mode) { if (populated) { return; } if (sceneLoaded.name.Equals("worldGenerated")) { // Obtains objects loaded into the game that might be useful foreach (Mesh mesh in Resources.FindObjectsOfTypeAll <Mesh>()) { if (!mesh.name.Equals(string.Empty) && !originMesh.ContainsKey(mesh.name.Replace("(Instance)", "")) && !(!mesh.name.EndsWith("(Instance)") && Regex.IsMatch(mesh.name, @".*\(.*\)"))) { originMesh.Add(mesh.name.Replace("(Instance)", ""), mesh); } } foreach (Material mat in Resources.FindObjectsOfTypeAll <Material>()) { if (!mat.name.Equals(string.Empty) && !originMaterial.ContainsKey(mat.name.Replace("(Instance)", "")) && !mat.name.StartsWith("Hidden/") && !materialBlacklist.Contains(mat.name) && !(!mat.name.EndsWith("(Instance)") && Regex.IsMatch(mat.name, @".*\(.*\)"))) { originMaterial.Add(mat.name.Replace("(Instance)", ""), mat); } } foreach (PhysicMaterial mat in Resources.FindObjectsOfTypeAll <PhysicMaterial>()) { if (!mat.name.Equals(string.Empty) && !originPhysMaterial.ContainsKey(mat.name.Replace("(Instance)", "")) && !(!mat.name.EndsWith("(Instance)") && Regex.IsMatch(mat.name, @".*\(.*\)"))) { originPhysMaterial.Add(mat.name.Replace("(Instance)", ""), mat); } } foreach (Texture tex in Resources.FindObjectsOfTypeAll <Texture>()) { if (!tex.name.Equals(string.Empty) && !originTexture.ContainsKey(tex.name.Replace("(Instance)", "")) && !(!tex.name.EndsWith("(Instance)") && Regex.IsMatch(tex.name, @".*\(.*\)"))) { originTexture.Add(tex.name.Replace("(Instance)", ""), tex); } } foreach (Sprite sprite in Resources.FindObjectsOfTypeAll <Sprite>()) { if (!sprite.name.Equals(string.Empty) && !originSprite.ContainsKey(sprite.name.Replace("(Instance)", "")) && !(!sprite.name.EndsWith("(Instance)") && Regex.IsMatch(sprite.name, @".*\(.*\)"))) { originSprite.Add(sprite.name.Replace("(Instance)", ""), sprite); } } foreach (AudioClip clip in Resources.FindObjectsOfTypeAll <AudioClip>()) { if (!clip.name.Equals(string.Empty) && !originClips.ContainsKey(clip.name.Replace("(Instance)", "")) && !(!clip.name.EndsWith("(Instance)") && Regex.IsMatch(clip.name, @".*\(.*\)"))) { originClips.Add(clip.name.Replace("(Instance)", ""), clip); } } foreach (SECTR_AudioCue cue in Resources.FindObjectsOfTypeAll <SECTR_AudioCue>()) { if (!cue.name.Equals(string.Empty) && !originCues.ContainsKey(cue.name.Replace("(Instance)", "")) && !(!cue.name.EndsWith("(Instance)") && Regex.IsMatch(cue.name, @".*\(.*\)"))) { originCues.Add(cue.name.Replace("(Instance)", ""), cue); } } foreach (SlimeSounds sound in Resources.FindObjectsOfTypeAll <SlimeSounds>()) { if (!sound.name.Equals(string.Empty) && !originSounds.ContainsKey(sound.name.Replace("(Instance)", "")) && !(!sound.name.EndsWith("(Instance)") && Regex.IsMatch(sound.name, @".*\(.*\)"))) { originSounds.Add(sound.name.Replace("(Instance)", ""), sound); } } foreach (RuntimeAnimatorController animator in Resources.FindObjectsOfTypeAll <RuntimeAnimatorController>()) { if (!animator.name.Equals(string.Empty) && !originAnimators.ContainsKey(animator.name.Replace("(Instance)", "")) && !(!animator.name.EndsWith("(Instance)") && Regex.IsMatch(animator.name, @".*\(.*\)"))) { originAnimators.Add(animator.name.Replace("(Instance)", ""), animator); } } foreach (Avatar avatar in Resources.FindObjectsOfTypeAll <Avatar>()) { if (!avatar.name.Equals(string.Empty) && !originAvatars.ContainsKey(avatar.name.Replace("(Instance)", "")) && !(!avatar.name.EndsWith("(Instance)") && Regex.IsMatch(avatar.name, @".*\(.*\)"))) { originAvatars.Add(avatar.name.Replace("(Instance)", ""), avatar); } } foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>()) { if (!(obj.name.StartsWith("FX ") || obj.name.StartsWith("fx"))) { continue; } if (!obj.name.Equals(string.Empty) && !originFXs.ContainsKey(obj.name.Replace("(Instance)", "")) && !(!obj.name.EndsWith("(Instance)") && Regex.IsMatch(obj.name, @".*\(.*\)"))) { originFXs.Add(obj.name.Replace("(Instance)", ""), obj); } } // Adds markers for world objects foreach (GadgetSiteModel obj in GameModel.AllGadgetSites().Values) { obj.transform.gameObject.GetReadyForMarker(MarkerType.GadgetLocation, 4f); } foreach (KookadobaPatchNode node in Resources.FindObjectsOfTypeAll <KookadobaPatchNode>()) { foreach (GameObject child in node.gameObject.FindChildrenWithPartialName("SpawnJoint")) { child.GetReadyForMarker(MarkerType.SpawnPoint); } } GardenObjects.LatePopulate(); TheWildsObjects.LatePopulate(); RanchObjects.LatePopulate(); EffectObjects.LatePopulate(); populated = true; } }