//util funcs static float GetSpeedyPathModifier(Player player) { if (!player.IsSwiming() && !player.InInterior()) { GroundType groundtype = GetGroundType(player); if (_speedModifiers.ContainsKey(groundtype)) { _activeStatusText = _groundTypeStrings[groundtype].Value; return(_speedModifiers[groundtype].Value); } //fallback to biome speed Heightmap.Biome playerBiome = player.GetCurrentBiome(); //Handle new biomes "gracefully" if (!_untamedSpeedModifiers.ContainsKey(playerBiome)) { Logger.LogWarning($"New biome {playerBiome.ToString()}. Unsure how to Handle. Falling back to None."); playerBiome = Heightmap.Biome.None; } _activeStatusText = "$biome_" + playerBiome.ToString().ToLower(); if (_biomeTypeStrings.ContainsKey(playerBiome) && _biomeTypeStrings[playerBiome].Value != "default") { _activeStatusText = _biomeTypeStrings[playerBiome].Value; } return(_untamedSpeedModifiers[playerBiome].Value); } return(1.0f); }
public void Setup(Player player, Heightmap.Biome biome, int treasureMapInterval) { Reinitialize(biome, treasureMapInterval, false, player.GetPlayerID()); var container = GetComponent <Container>(); var zdo = container?.m_nview.GetZDO(); if (container != null && zdo != null && zdo.IsValid()) { container.GetInventory().RemoveAll(); zdo.Set("TreasureMapChest.Interval", Interval); zdo.Set("TreasureMapChest.Biome", Biome.ToString()); zdo.Set("creator", player.GetPlayerID()); var items = LootRoller.RollLootTable(LootTableName, 1, LootTableName, transform.position); items.ForEach(item => container.m_inventory.AddItem(item)); var biomeConfig = AdventureDataManager.Config.TreasureMap.BiomeInfo.Find(x => x.Biome == biome); if (biomeConfig?.ForestTokens > 0) { container.m_inventory.AddItem("ForestToken", biomeConfig.ForestTokens, 1, 0, 0, ""); } container.Save(); } else { EpicLoot.LogError($"Trying to set up TreasureMapChest ({biome} {treasureMapInterval}) but there was no Container component!"); } }
private void Update() { var player = Player.m_localPlayer; if (configModEnabled.Value && player != null) { Heightmap.Biome currentBiome = player.GetCurrentBiome(); if (currentBiome != saved_biome) { saved_biome = currentBiome; if (saved_biome != Heightmap.Biome.None) { string text = Localization.instance.Localize("$biome_" + currentBiome.ToString().ToLower()); MessageHud.instance.ShowBiomeFoundMsg(text, configSoundEnabled.Value); } } } }
static float GetSpeedyPathStaminaModifier(Player player) { if (!player.IsSwiming() && !player.InInterior()) { if (_staminaModifiers.ContainsKey(m_cachedGroundType)) { return(_staminaModifiers[m_cachedGroundType].Value); } //fallback to biome stamina Heightmap.Biome playerBiome = player.GetCurrentBiome(); //Handle new biomes "gracefully" if (!_untamedStaminaModifiers.ContainsKey(playerBiome)) { Logger.LogWarning($"New biome {playerBiome.ToString()}. Unsure how to Handle. Falling back to None."); playerBiome = Heightmap.Biome.None; } return(_untamedStaminaModifiers[playerBiome].Value); } return(1.0f); }
public string ToJson() { StringBuilder builder = new StringBuilder(); builder.Append('{'); builder.AppendTypeAndValue(nameof(IsWet), IsWet); builder.Append(','); builder.AppendTypeAndValue(nameof(IsCold), IsCold); builder.Append(','); builder.AppendTypeAndValue(nameof(IsDaylight), IsDaylight); builder.Append(','); builder.AppendTypeAndValue(nameof(WindAngle), WindAngle); builder.Append(','); builder.AppendTypeAndValue(nameof(Biome), Biome.ToString()); builder.Append(','); builder.AppendTypeAndValue(nameof(SunFog), SunFog); builder.Append('}'); return(builder.ToString()); }
public void Reinitialize(Heightmap.Biome biome, int treasureMapInterval, bool hasBeenFound, long ownerPlayerId) { Biome = biome; Interval = treasureMapInterval; gameObject.layer = 12; var container = GetComponent <Container>(); if (container != null) { var label = Localization.instance.Localize("$mod_epicloot_treasurechest_name", $"$biome_{Biome.ToString().ToLower()}", (treasureMapInterval + 1).ToString()); container.m_name = Localization.instance.Localize(label); container.m_privacy = hasBeenFound ? Container.PrivacySetting.Public : Container.PrivacySetting.Private; } var piece = GetComponent <Piece>(); if (piece != null) { piece.m_creator = ownerPlayerId; } if (!hasBeenFound) { var beacon = gameObject.AddComponent <Beacon>(); beacon.m_range = EpicLoot.GetAndvaranautRange(); } // TODO Figure out why this damn thing won't float /*var rigidbody = gameObject.AddComponent<Rigidbody>(); * rigidbody.constraints = * RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation; | rigidbody.collisionDetectionMode = CollisionDetectionMode.Discrete; | | var floating = gameObject.AddComponent<Floating>(); | floating.m_waterLevelOffset = 0.3f; | floating.TerrainCheck();*/ Destroy(gameObject.GetComponent <WearNTear>()); }