Beispiel #1
0
    public GameObject CreatePrefab()
    {
        GameObject gameObject = EntityTemplates.CreatePlacedEntity("Geyser", STRINGS.CREATURES.SPECIES.GEYSER.NAME, STRINGS.CREATURES.SPECIES.GEYSER.DESC, 2000f, Assets.GetAnim("geyser_side_steam_kanim"), "inactive", Grid.SceneLayer.BuildingBack, 4, 2, TUNING.BUILDINGS.DECOR.BONUS.TIER1, NOISE_POLLUTION.NOISY.TIER6, SimHashes.Creature, null, 293f);

        gameObject.GetComponent <KPrefabID>().AddTag(GameTags.DeprecatedContent, false);
        PrimaryElement component = gameObject.GetComponent <PrimaryElement>();

        component.SetElement(SimHashes.IgneousRock);
        component.Temperature = 372.15f;
        Geyser geyser = gameObject.AddOrGet <Geyser>();

        geyser.outputOffset = new Vector2I(0, 1);
        GeyserConfigurator geyserConfigurator = gameObject.AddOrGet <GeyserConfigurator>();

        geyserConfigurator.presetType = "steam";
        geyserConfigurator.presetMin  = 0.5f;
        geyserConfigurator.presetMax  = 0.75f;
        Studyable studyable = gameObject.AddOrGet <Studyable>();

        studyable.meterTrackerSymbol = "geotracker_target";
        studyable.meterAnim          = "tracker";
        gameObject.AddOrGet <LoopingSounds>();
        SoundEventVolumeCache.instance.AddVolume("geyser_side_steam_kanim", "Geyser_shake_LP", NOISE_POLLUTION.NOISY.TIER5);
        SoundEventVolumeCache.instance.AddVolume("geyser_side_steam_kanim", "Geyser_erupt_LP", NOISE_POLLUTION.NOISY.TIER6);
        return(gameObject);
    }
    public GameObject CreateGeyser(string id, string anim, int width, int height, string name, string desc, HashedString presetType)
    {
        float      mass       = 2000f;
        GameObject gameObject = EntityTemplates.CreatePlacedEntity(id, name, desc, mass, Assets.GetAnim(anim), "inactive", Grid.SceneLayer.BuildingBack, width, height, BUILDINGS.DECOR.BONUS.TIER1, NOISE_POLLUTION.NOISY.TIER6, SimHashes.Creature, null, 293f);

        gameObject.AddOrGet <OccupyArea>().objectLayers = new ObjectLayer[1]
        {
            ObjectLayer.Building
        };
        PrimaryElement component = gameObject.GetComponent <PrimaryElement>();

        component.SetElement(SimHashes.Katairite);
        component.Temperature = 372.15f;
        gameObject.AddOrGet <Prioritizable>();
        gameObject.AddOrGet <Uncoverable>();
        Geyser geyser = gameObject.AddOrGet <Geyser>();

        geyser.outputOffset = new Vector2I(0, 1);
        GeyserConfigurator geyserConfigurator = gameObject.AddOrGet <GeyserConfigurator>();

        geyserConfigurator.presetType = presetType;
        Studyable studyable = gameObject.AddOrGet <Studyable>();

        studyable.meterTrackerSymbol = "geotracker_target";
        studyable.meterAnim          = "tracker";
        gameObject.AddOrGet <LoopingSounds>();
        SoundEventVolumeCache.instance.AddVolume("geyser_side_steam_kanim", "Geyser_shake_LP", NOISE_POLLUTION.NOISY.TIER5);
        SoundEventVolumeCache.instance.AddVolume("geyser_side_steam_kanim", "Geyser_erupt_LP", NOISE_POLLUTION.NOISY.TIER6);
        return(gameObject);
    }
Beispiel #3
0
        public static string GetRandomGeyserType(Transform transform)
        {
            System.Random RNG = transform != null?GetRNG(transform) : new System.Random();

            int random = RNG.Next(sum);              // 0 <= random < sum
            int pick   = 0;

            for (int j = 0; j <= random;)
            {
                j += weights[pick++];
            }
            return(GeyserConfigurator.FindType(geysers[pick - 1]).id);
        }
Beispiel #4
0
        public static void PrefabInitForGeysers(GameObject go)
        {
            System.Random RNG;
            if (CustomizeGeyserState.StateManager.State.RandomizerUsesMapSeed)
            {
                RNG = new System.Random(SaveLoader.Instance.worldDetailSave.globalWorldSeed + (int)go.transform.GetPosition().x + (int)go.transform.GetPosition().y);
            }
            else
            {
                RNG = new System.Random();
            }

#if DEBUG_1
            Debug.Log("[CustomizeGeyser] Printout of RandomizerTable");
            Debug.Log("\tsum is: " + RandomizerTable.sum);
            for (int DEBUG1 = 0; DEBUG1 < RandomizerTable.geysers.Length; DEBUG1++)
            {
                Debug.Log("\t[" + DEBUG1 + "] " + RandomizerTable.geysers[DEBUG1] + " weight: " + RandomizerTable.weights[DEBUG1]);
            }
#endif

            if (RandomizerTable.sum > 0)
            {
                int random = RNG.Next(RandomizerTable.sum);                      // 0 <= random < sum
                int pick   = 0;
                for (int j = 0; j <= random;)
                {
                    j += RandomizerTable.weights[pick++];
                }
                string geyserTag = GeyserConfigurator.FindType(RandomizerTable.geysers[pick - 1]).id;

                if (CustomizeGeyserState.StateManager.State.RandomizerPopupGeyserDiscoveryInfo)
                {
                    KMod.Manager.Dialog(null, "Geysers discovered", "You just discovered a geyser: " + geyserTag);
                }

                GameUtil.KInstantiate(Assets.GetPrefab(
                                          (Tag)("GeyserGeneric_" + geyserTag)    //change Tag to whatever you want to spawn; Tag is "GeyserGeneric_" + geyserType.id
                                          ), go.transform.GetPosition(), Grid.SceneLayer.BuildingBack, (string)null, 0).SetActive(true);
                go.DeleteObject();
            }
            else
            {
                // empty geyser?
                Debug.Log("[CustomizeGeyser] RandomizerTable was empty...");
            }
        }
Beispiel #5
0
        public void TriggerTextDialog()
        {
            FileNameDialog textDialog = CreateTextDialog("");

            //textDialog.name = StringBoxTitle;
            textDialog.onConfirm = (System.Action <string>)(name =>
            {
                if (name != null)
                {
                    name = name.Substring(0, Math.Max(0, name.Length - 4));

                    GeyserConfigurator.GeyserType type = GeyserConfigurator.FindType((HashedString)name);

                    ChangeGeyserElement(this.gameObject, type?.id);
                }
            });

            SpeedControlScreen.Instance.Pause(false);
            textDialog.Activate();
        }
Beispiel #6
0
        public static void Postfix(GeyserConfigurator __instance, ref GeyserConfigurator.GeyserInstanceConfiguration __result)
        {
            if (CustomizeGeyserState.StateManager.State.RandomizerRerollsCycleRate)
            {
                System.Random RNG;
                if (CustomizeGeyserState.StateManager.State.RandomizerUsesMapSeed)
                {
                    RNG = new System.Random(SaveLoader.Instance.worldDetailSave.globalWorldSeed + (int)__instance.transform.GetPosition().x + (int)__instance.transform.GetPosition().y);
                }
                else
                {
                    RNG = new System.Random();
                }

                __result.rateRoll             = (float)RNG.NextDouble();
                __result.iterationLengthRoll  = (float)RNG.NextDouble();
                __result.iterationPercentRoll = (float)RNG.NextDouble();
                __result.yearLengthRoll       = (float)RNG.NextDouble();
                __result.yearPercentRoll      = (float)RNG.NextDouble();
            }
        }