Created
January 30, 2025 02:52
-
-
Save TheCuttlefish/67644927089ab74266bc00e263a2d494 to your computer and use it in GitHub Desktop.
Seeds for tile world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Transform activeMap; | |
void SwapMap() | |
{ | |
if (activeMap) activeMap.gameObject.SetActive(false); | |
int chunkHash = Mathf.Abs((int)transform.position.x * 73856093 ^ (int)transform.position.y * 19349663); | |
activeMap = maps[seed.Next(chunkHash, maps.Count)]; // Directly store GameObject | |
activeMap.gameObject.SetActive(true); | |
transform.localEulerAngles = new Vector3(0, 0, 90 * seed.Next(chunkHash, 4)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Seed : MonoBehaviour | |
{ | |
int seed = 1; | |
public int Next(float _hashKey, int _range) | |
{ | |
System.Random rand = new System.Random((int)_hashKey + seed); // Using a fixed seed | |
return( rand.Next(_range) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment