Ejemplo n.º 1
0
        private bool NearCookingStation(PieceEntry checkPiece)
        {
            if (cookingPositionCache == null)
            {
                cookingPositionCache = new List <Vector3>();

                foreach (PieceEntry piece in blueprint.Pieces)
                {
                    switch (piece.prefabName)
                    {
                    case "piece_cookingstation":
                    case "piece_cookingstation_iron":
                    case "piece_cauldron":
                    case "cauldron_ext1_spice":
                    case "cauldron_ext3_butchertable":
                    case "cauldron_ext4_pots":
                        cookingPositionCache.Add(piece.position);
                        break;
                    }
                }
            }

            foreach (Vector3 v in cookingPositionCache)
            {
                var diff = v - checkPiece.position;
                diff.y = 0;

                if (Mathf.Abs(v.y - checkPiece.position.y) < 2 && diff.sqrMagnitude < 9 * 9)
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
 private string GetPickableTreasure(PieceEntry piece)
 {
     if (NearCookingStation(piece))
     {
         return("Pickable_RandomFood");
     }
     else if (biome == Heightmap.Biome.Meadows || biome == Heightmap.Biome.BlackForest)
     {
         return("Pickable_DolmenTreasure");
     }
     return("Pickable_ForestCryptRandom");
 }
Ejemplo n.º 3
0
        private bool IsBlackListedPiece(PieceEntry piece)
        {
            GameObject prefab = piece.prefab();

            if (prefab == null)
            {
                Jotunn.Logger.LogWarning($"Prefab not found: {piece.prefabName}");
                return(true);
            }

            // Named blacklist
            if (blacklistedPieces.Contains(piece.prefabName))
            {
                return(true);
            }

            // Blacklist some piece types to prevent interaction and advancement for the player
            if (prefab.GetComponent("CraftingStation") ||
                prefab.GetComponent("Bed") ||
                prefab.GetComponent("TeleportWorld") ||
                prefab.GetComponent("PrivateArea") ||
                prefab.GetComponent("Beehive") ||
                prefab.GetComponent("Smelter") ||
                prefab.GetComponent("Vagon") || // Carts are bugged because it RandomSpawns the Container
                prefab.GetComponent("Ship"))
            {
                return(true);
            }

            // Blacklist pieces built with certain items to prevent the player from obtaining them early
            Piece pieceData = prefab.GetComponent <Piece>();

            if (pieceData)
            {
                foreach (var requirement in pieceData.m_resources)
                {
                    if (!materialSpawnChance.ContainsKey(requirement.m_resItem.name))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        private string GetReplacementPrefabName(PieceEntry piece)
        {
            switch (piece.prefabName)
            {
            case "piece_groundtorch_green":
                return("CastleKit_groundtorch_green");

            case "piece_groundtorch":
                return("CastleKit_groundtorch");

            case "sign":
                return("sign_notext");

            case "bed":
                return("goblin_bed");

            // This doesn't work out well because gates can be surrounded by iron bars and then just be awkwardly free standing.
            //case "iron_grate":
            //  return "dungeon_sunkencrypt_irongate";
            case "itemstandh":
                return(GetPickableTreasure(piece));

            case "loot_chest_wood":
            case "piece_chest_wood":
            case "piece_chest":
            case "piece_chest_blackmetal":
            case "piece_chest_private":
                return(GetWoodTreasureChest());

            case "stonechest":
            case "loot_chest_stone":
                return(GetStoneTreasureChest());

            case "CargoCrate":
                return("CastleKit_braided_box01");

            default:
                return(piece.prefabName);
            }
        }
Ejemplo n.º 5
0
        private static Blueprint FromArray(string id, string[] lines, Format format)
        {
            Blueprint result = new Blueprint();

            bool ignore = false;

            foreach (var line in lines)
            {
                if (line == HeaderSnapPoints)
                {
                    ignore = true;
                    continue;
                }
                if (line == HeaderPieces)
                {
                    ignore = false;
                    continue;
                }

                if (ignore || line.StartsWith("#") || string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }

                PieceEntry piece = null;
                if (format == Format.VBuild)
                {
                    piece = PieceEntry.FromVBuild(line);
                }
                else if (format == Format.Blueprint)
                {
                    piece = PieceEntry.FromBlueprint(line);
                }

                result.Pieces.Add(piece);
            }
            result.Name = id;
            return(result);
        }