miepzerino
2025-04-01 ff3f9c75fccb3fbb7b882ec29e754e6135b53e60
#25 oreTiles now connect to forestTiles
3 files modified
6 files added
461 ■■■■■ changed files
Assets/Scenes/GameplayScene.unity 4 ●●●● patch | view | raw | blame | history
Assets/Scripts/CustomRuleTile.cs 34 ●●●●● patch | view | raw | blame | history
Assets/Scripts/CustomRuleTile.cs.meta 11 ●●●●● patch | view | raw | blame | history
Assets/Scripts/GenerateTileMap.cs 4 ●●●● patch | view | raw | blame | history
Assets/TileSets/Palettes/ForestRuleTileCustom.asset 341 ●●●●● patch | view | raw | blame | history
Assets/TileSets/Palettes/ForestRuleTileCustom.asset.meta 8 ●●●●● patch | view | raw | blame | history
Assets/TileSets/Palettes/IronOreRuleCustom.asset 41 ●●●●● patch | view | raw | blame | history
Assets/TileSets/Palettes/IronOreRuleCustom.asset.meta 8 ●●●●● patch | view | raw | blame | history
Assets/TileSets/Palettes/IronOreRuleTile.asset 10 ●●●● patch | view | raw | blame | history
Assets/Scenes/GameplayScene.unity
@@ -4869,13 +4869,13 @@
  m_Script: {fileID: 11500000, guid: 000b2ca4a3c14d04e8c8a5c1084c700f, type: 3}
  m_Name: 
  m_EditorClassIdentifier: 
  forestRuleTile: {fileID: 11400000, guid: e77c00aec3ec74f4a9ec15ef63c3f9a7, type: 2}
  forestRuleTile: {fileID: 11400000, guid: 3999614e192b37546a6b710bf5ceb30c, type: 2}
  borderTile: {fileID: 11400000, guid: dcef846474e534b45ab3b175559c19a2, type: 2}
  ores:
  - name: Iron
    weight: 7
    clusterWeight: 40
    tile: {fileID: 11400000, guid: 4d8deb60103293942a07fd9361be5e8f, type: 2}
    tile: {fileID: 11400000, guid: bbc5a3964d8331546a4dbc880f8ae9fc, type: 2}
    maxSpawnHeight: 250
    minSpawnHeight: 150
--- !u!1 &1955008394
Assets/Scripts/CustomRuleTile.cs
New file
@@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Tilemaps;
using static UnityEngine.RuleTile.TilingRuleOutput;
[CreateAssetMenu(fileName = "CustomRuleTile", menuName = "2D/Tiles/Custom Rule Tile")]
public class CustomRuleTile : RuleTile<CustomRuleTile.Neighbor>
{
    public List<TileBase> siblings = new List<TileBase>();
    public class Neighbor : RuleTile.TilingRule.Neighbor
    {
        public const int Sibling = 3;
    }
    public override bool RuleMatch(int neighbor, TileBase tile)
    {
        // Handle null tiles
        if (tile == null)
            return neighbor == RuleTile.TilingRule.Neighbor.NotThis;
        // Always allow connections to siblings or self, regardless of surrounding tiles
        if (tile == this || siblings.Contains(tile))
            return neighbor == RuleTile.TilingRule.Neighbor.This;
        // For Sibling type explicitly
        if (neighbor == Neighbor.Sibling)
            return siblings.Contains(tile);
        // For any other case, use base behavior
        return base.RuleMatch(neighbor, tile);
    }
}
Assets/Scripts/CustomRuleTile.cs.meta
New file
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4f32125565481304cbcd5f6e6cefa637
MonoImporter:
  externalObjects: {}
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/Scripts/GenerateTileMap.cs
@@ -24,7 +24,7 @@
    [Tooltip("The lower the number the more dense the ore will spawn (big clusters. Higher number means little clusters (more spread).")]
    [Range(10, 100000)]
    public int clusterWeight;
    public RuleTile tile;
    public CustomRuleTile tile;
    public int maxSpawnHeight;
    public int minSpawnHeight;
}
@@ -39,7 +39,7 @@
    private float offsetX;
    private float offsetY;
    Tilemap tilemap;
    public RuleTile forestRuleTile;
    public CustomRuleTile forestRuleTile;
    public TileBase borderTile;
    public List<Ore> ores;
    //public List<TileBase> tiles;
Assets/TileSets/Palettes/ForestRuleTileCustom.asset
New file
@@ -0,0 +1,341 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 4f32125565481304cbcd5f6e6cefa637, type: 3}
  m_Name: ForestRuleTileCustom
  m_EditorClassIdentifier:
  m_DefaultSprite: {fileID: 0}
  m_DefaultGameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
  m_DefaultColliderType: 1
  m_TilingRules:
  - m_Id: 0
    m_Sprites:
    - {fileID: -1200237691, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 020000000200000001000000
    m_NeighborPositions:
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    m_RuleTransform: 0
  - m_Id: 1
    m_Sprites:
    - {fileID: -1554015212, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 020000000100000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    m_RuleTransform: 0
  - m_Id: 2
    m_Sprites:
    - {fileID: 952801214, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 020000000200000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    m_RuleTransform: 0
  - m_Id: 3
    m_Sprites:
    - {fileID: -1701200628, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 02000000010000000100000001000000
    m_NeighborPositions:
    - {x: -1, y: 0, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 0, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 4
    m_Sprites:
    - {fileID: 1210147125, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 01000000020000000200000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 1, y: 0, z: 0}
    m_RuleTransform: 0
  - m_Id: 5
    m_Sprites:
    - {fileID: -603009601, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 010000000200000001000000010000000100000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    m_RuleTransform: 0
  - m_Id: 6
    m_Sprites:
    - {fileID: -1438444955, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 01000000010000000200000002000000
    m_NeighborPositions:
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 7
    m_Sprites:
    - {fileID: -1608621674, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 02000000010000000100000001000000
    m_NeighborPositions:
    - {x: 1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: -1, y: 0, z: 0}
    m_RuleTransform: 0
  - m_Id: 8
    m_Sprites:
    - {fileID: 68800321, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    - {fileID: 1862643484, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.703
    m_Output: 1
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000100000001000000010000000100000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: 1, y: -1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: -1, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 9
    m_Sprites:
    - {fileID: 1984530201, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000002000000010000000100000001000000010000000100000001000000
    m_NeighborPositions:
    - {x: 1, y: 0, z: 0}
    - {x: 1, y: -1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: -1, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 10
    m_Sprites:
    - {fileID: -58827736, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000100000002000000010000000100000001000000
    m_NeighborPositions:
    - {x: 1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 1, y: -1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: 1, z: 0}
    m_RuleTransform: 0
  - m_Id: 11
    m_Sprites:
    - {fileID: 1943074245, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 02000000020000000200000002000000
    m_NeighborPositions:
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 13
    m_Sprites:
    - {fileID: 956194596, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000100000001000000010000000200000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 1, y: -1, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    m_RuleTransform: 0
  - m_Id: 16
    m_Sprites:
    - {fileID: -855959738, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000100000001000000010000000200000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 1, y: -1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: 1, z: 0}
    m_RuleTransform: 0
  - m_Id: 14
    m_Sprites:
    - {fileID: 1598334396, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000200000001000000020000000100000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: 1, y: -1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: -1, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 15
    m_Sprites:
    - {fileID: 1451081626, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000100000002000000020000000100000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: 1, y: -1, z: 0}
    m_RuleTransform: 0
  - m_Id: 17
    m_Sprites:
    - {fileID: 1451081626, guid: 42962cf14c23fee4baaaea0cd52d52e0, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: c82bc431abdeded4ab41cfdd19459501, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0100000001000000010000000100000002000000020000000100000001000000
    m_NeighborPositions:
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: -1, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: 1, y: -1, z: 0}
    m_RuleTransform: 0
  siblings:
  - {fileID: 11400000, guid: bbc5a3964d8331546a4dbc880f8ae9fc, type: 2}
Assets/TileSets/Palettes/ForestRuleTileCustom.asset.meta
New file
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3999614e192b37546a6b710bf5ceb30c
NativeFormatImporter:
  externalObjects: {}
  mainObjectFileID: 11400000
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/TileSets/Palettes/IronOreRuleCustom.asset
New file
@@ -0,0 +1,41 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 4f32125565481304cbcd5f6e6cefa637, type: 3}
  m_Name: IronOreRuleCustom
  m_EditorClassIdentifier:
  m_DefaultSprite: {fileID: 21300000, guid: 83ee72e0f385a7641b729c9f5c288e74, type: 3}
  m_DefaultGameObject: {fileID: 3549545049718014148, guid: 858e9987645c29748a5b0990923da82f, type: 3}
  m_DefaultColliderType: 1
  m_TilingRules:
  - m_Id: 0
    m_Sprites:
    - {fileID: 21300000, guid: 83ee72e0f385a7641b729c9f5c288e74, type: 3}
    m_GameObject: {fileID: 3549545049718014148, guid: 858e9987645c29748a5b0990923da82f, type: 3}
    m_MinAnimationSpeed: 1
    m_MaxAnimationSpeed: 1
    m_PerlinScale: 0.5
    m_Output: 0
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 0200000002000000020000000200000002000000020000000200000002000000
    m_NeighborPositions:
    - {x: -1, y: 1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: 1, y: -1, z: 0}
    m_RuleTransform: 0
  siblings:
  - {fileID: 11400000, guid: 3999614e192b37546a6b710bf5ceb30c, type: 2}
Assets/TileSets/Palettes/IronOreRuleCustom.asset.meta
New file
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bbc5a3964d8331546a4dbc880f8ae9fc
NativeFormatImporter:
  externalObjects: {}
  mainObjectFileID: 11400000
  userData:
  assetBundleName:
  assetBundleVariant:
Assets/TileSets/Palettes/IronOreRuleTile.asset
@@ -27,13 +27,5 @@
    m_ColliderType: 1
    m_RandomTransform: 0
    m_Neighbors: 
    m_NeighborPositions:
    - {x: -1, y: 1, z: 0}
    - {x: 0, y: 1, z: 0}
    - {x: 1, y: 1, z: 0}
    - {x: -1, y: 0, z: 0}
    - {x: 1, y: 0, z: 0}
    - {x: -1, y: -1, z: 0}
    - {x: 0, y: -1, z: 0}
    - {x: 1, y: -1, z: 0}
    m_NeighborPositions: []
    m_RuleTransform: 0