- Notifications
You must be signed in to change notification settings - Fork 343
Home
ChuanXin-Unity edited this page Jul 8, 2021 · 2 revisions
Welcome to the 2d-extras wiki!
- Inheritable RuleTile
- Customizable attributes
- Can expand or rewrite neighbor rules and GUI display
- Can be used by RuleOverrideTile
- Template script (Menu: Assets/Create/Custom Rule Tile Script)
- Neighbor rules tooltip
- Backward compatible
- Custom Attributes:
public class MyTile : RuleTile { public string tileId; public bool isWater; }
- Custom Rules:
public class MyTile : RuleTile<MyTile.Neighbor> { public class Neighbor { public const int MyRule1 = 0; public const int MyRule2 = 1; } public override bool RuleMatch(int neighbor, TileBase tile) { switch (neighbor) { case Neighbor.MyRule1: return false; case Neighbor.MyRule2: return true; } return true; } }
- Expansion Rules
public class MyTile : RuleTile<MyTile.Neighbor> { public class Neighbor : RuleTile.TilingRule.Neighbor { // 0, 1, 2 is using in RuleTile.TilingRule.Neighbor public const int MyRule1 = 3; public const int MyRule2 = 4; } public override bool RuleMatch(int neighbor, TileBase tile) { switch (neighbor) { case Neighbor.MyRule1: return false; case Neighbor.MyRule2: return true; } return base.RuleMatch(neighbor, tile); } }
- Siblings Tile 1
public class MyTile : RuleTile<MyTile.Neighbor> { public List<TileBase> sibings = new List<TileBase>(); public class Neighbor : RuleTile.TilingRule.Neighbor { public const int Sibing = 3; } public override bool RuleMatch(int neighbor, TileBase tile) { switch (neighbor) { case Neighbor.Sibing: return sibings.Contains(tile); } return base.RuleMatch(neighbor, tile); } }
- Siblings Tile 2
public class MyTile : RuleTile<MyTile.Neighbor> { public int siblingGroup; public class Neighbor : RuleTile.TilingRule.Neighbor { public const int Sibing = 3; } public override bool RuleMatch(int neighbor, TileBase tile) { MyTile myTile = tile as MyTile; switch (neighbor) { case Neighbor.Sibing: return myTile && myTile.siblingGroup == siblingGroup; } return base.RuleMatch(neighbor, tile); } }