public void Tick() { long num = (long)10000000; double dayLengthInMinutes = 1440 / (double)SynchronizedClock.DayLengthInMinutes; double num1 = (double)num * dayLengthInMinutes; for (int i = 0; i < this.events.Count; i++) { SynchronizedClock.TimedEvent item = this.events[i]; long num2 = item.ticks; long ticks = SynchronizedClock.Ticks; long num3 = (long)((double)item.delta * num1); long num4 = num2 / num3 * num3; uint num5 = (uint)(num4 % (ulong)-1); SeedRandom.Wanghash(ref num5); long num6 = (long)((double)SeedRandom.Range(ref num5, -item.variance, item.variance) * num1); long num7 = num4 + num3 + num6; if (num2 < num7 && ticks >= num7) { item.action(num5); item.ticks = ticks; } else if (ticks > num2 || ticks < num4) { item.ticks = ticks; } this.events[i] = item; } }
protected void Start() { uint num1 = SeedEx.Seed(((Component)this).get_transform().get_position(), World.Seed + this.Seed); if ((double)SeedRandom.Value(ref num1) > (double)this.Probability) { for (int index = 0; index < this.Candidates.Length; ++index) { GameManager.Destroy(this.Candidates[index], 0.0f); } GameManager.Destroy((Component)this, 0.0f); } else { int num2 = SeedRandom.Range(num1, 0, ((Component)this).get_transform().get_childCount()); for (int index = 0; index < this.Candidates.Length; ++index) { GameObject candidate = this.Candidates[index]; if (index == num2) { candidate.SetActive(true); } else { GameManager.Destroy(candidate, 0.0f); } } GameManager.Destroy((Component)this, 0.0f); } }
public void Tick() { double num1 = 10000000.0 * (1440.0 / (double)SynchronizedClock.DayLengthInMinutes); for (int index = 0; index < this.events.Count; ++index) { SynchronizedClock.TimedEvent timedEvent = this.events[index]; long ticks1 = timedEvent.ticks; long ticks2 = SynchronizedClock.Ticks; long num2 = (long)((double)timedEvent.delta * num1); long num3 = ticks1 / num2 * num2; uint num4 = (uint)((ulong)num3 % (ulong)uint.MaxValue); int num5 = (int)SeedRandom.Wanghash(ref num4); long num6 = (long)((double)SeedRandom.Range(ref num4, -timedEvent.variance, timedEvent.variance) * num1); long num7 = num3 + num2 + num6; if (ticks1 < num7 && ticks2 >= num7) { timedEvent.action(num4); timedEvent.ticks = ticks2; } else if (ticks2 > ticks1 || ticks2 < num3) { timedEvent.ticks = ticks2; } this.events[index] = timedEvent; } }
public static Prefab <T> LoadRandom <T>( string folder, ref uint seed, GameManager manager = null, PrefabAttribute.Library attribute = null, bool useProbabilities = true) where T : Component { if (string.IsNullOrEmpty(folder)) { return((Prefab <T>)null); } if (manager == null) { manager = Prefab.DefaultManager; } if (attribute == null) { attribute = Prefab.DefaultAttribute; } string[] prefabNames = Prefab.FindPrefabNames(folder, useProbabilities); if (prefabNames.Length == 0) { return((Prefab <T>)null); } string str = prefabNames[SeedRandom.Range(ref seed, 0, prefabNames.Length)]; GameObject prefab = manager.FindPrefab(str); T component = prefab.GetComponent <T>(); return(new Prefab <T>(str, prefab, component, manager, attribute)); }
protected void Start() { uint num = base.transform.position.Seed(World.Seed + this.Seed); if (SeedRandom.Value(ref num) > this.Probability) { for (int i = 0; i < (int)this.Candidates.Length; i++) { GameManager.Destroy(this.Candidates[i], 0f); } GameManager.Destroy(this, 0f); return; } int num1 = SeedRandom.Range(num, 0, base.transform.childCount); for (int j = 0; j < (int)this.Candidates.Length; j++) { GameObject candidates = this.Candidates[j]; if (j != num1) { GameManager.Destroy(candidates, 0f); } else { candidates.SetActive(true); } } GameManager.Destroy(this, 0f); }
private WeatherPreset GetWeatherPreset(uint seed) { float max = Weather.ClearChance + Weather.DustChance + Weather.FogChance + Weather.OvercastChance + Weather.StormChance + Weather.RainChance; float num = SeedRandom.Range(ref seed, 0f, max); if (num < Weather.RainChance) { return(GetWeatherPreset(seed, WeatherPresetType.Rain)); } if (num < Weather.RainChance + Weather.StormChance) { return(GetWeatherPreset(seed, WeatherPresetType.Storm)); } if (num < Weather.RainChance + Weather.StormChance + Weather.OvercastChance) { return(GetWeatherPreset(seed, WeatherPresetType.Overcast)); } if (num < Weather.RainChance + Weather.StormChance + Weather.OvercastChance + Weather.FogChance) { return(GetWeatherPreset(seed, WeatherPresetType.Fog)); } if (num < Weather.RainChance + Weather.StormChance + Weather.OvercastChance + Weather.FogChance + Weather.DustChance) { return(GetWeatherPreset(seed, WeatherPresetType.Dust)); } return(GetWeatherPreset(seed, WeatherPresetType.Clear)); }
public virtual void LoadoutPlayer(BasePlayer player) { PlayerInventoryProperties playerInventoryProperties; if (IsTeamGame()) { if (player.gamemodeteam == -1) { Debug.LogWarning("Player loading out without team assigned, auto assigning!"); AutoAssignTeam(player); } playerInventoryProperties = teams[player.gamemodeteam].teamloadouts[SeedRandom.Range((uint)player.userID, 0, teams[player.gamemodeteam].teamloadouts.Length)]; } else { playerInventoryProperties = loadouts[SeedRandom.Range((uint)player.userID, 0, loadouts.Length)]; } if ((bool)playerInventoryProperties) { playerInventoryProperties.GiveToPlayer(player); } else { player.inventory.GiveItem(ItemManager.CreateByName("hazmatsuit", 1, 0uL), player.inventory.containerWear); } }
public override void Process(uint seed) { TerrainHeightMap heightMap = TerrainMeta.HeightMap; Vector3 position1 = TerrainMeta.Position; Vector3 size = TerrainMeta.Size; float x1 = (float)position1.x; float z1 = (float)position1.z; float num1 = (float)(position1.x + size.x); float num2 = (float)(position1.z + size.z); PlaceMonument.SpawnInfo spawnInfo1 = new PlaceMonument.SpawnInfo(); int num3 = int.MinValue; Prefab <MonumentInfo> prefab1 = Prefab.Load <MonumentInfo>(this.Monument.resourceID, (GameManager)null, (PrefabAttribute.Library)null); for (int index = 0; index < 10000; ++index) { float x2 = SeedRandom.Range(ref seed, x1, num1); float z2 = SeedRandom.Range(ref seed, z1, num2); float normX = TerrainMeta.NormalizeX(x2); float normZ = TerrainMeta.NormalizeZ(z2); float num4 = SeedRandom.Value(ref seed); double factor = (double)this.Filter.GetFactor(normX, normZ); if (factor * factor >= (double)num4) { float height = heightMap.GetHeight(normX, normZ); Vector3 pos; ((Vector3) ref pos).\u002Ector(x2, height, z2); Quaternion localRotation = prefab1.Object.get_transform().get_localRotation(); Vector3 localScale = prefab1.Object.get_transform().get_localScale(); prefab1.ApplyDecorComponents(ref pos, ref localRotation, ref localScale); if ((!Object.op_Implicit((Object)prefab1.Component) || prefab1.Component.CheckPlacement(pos, localRotation, localScale)) && (prefab1.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && prefab1.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter)) && (prefab1.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && prefab1.ApplyWaterChecks(pos, localRotation, localScale) && !prefab1.CheckEnvironmentVolumes(pos, localRotation, localScale, EnvironmentType.Underground))) { PlaceMonument.SpawnInfo spawnInfo2 = new PlaceMonument.SpawnInfo(); spawnInfo2.prefab = (Prefab)prefab1; spawnInfo2.position = pos; spawnInfo2.rotation = localRotation; spawnInfo2.scale = localScale; int num5 = -Mathf.RoundToInt(Vector3Ex.Magnitude2D(pos)); if (num5 > num3) { num3 = num5; spawnInfo1 = spawnInfo2; } } } } if (num3 == int.MinValue) { return; } Prefab prefab2 = spawnInfo1.prefab; Vector3 position2 = spawnInfo1.position; Quaternion rotation = spawnInfo1.rotation; Vector3 scale = spawnInfo1.scale; prefab2.ApplyTerrainPlacements(position2, rotation, scale); prefab2.ApplyTerrainModifiers(position2, rotation, scale); World.AddPrefab("Monument", prefab2.ID, position2, rotation, scale); }
public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale) { uint seed = pos.Seed(World.Seed) + 1; pos.x += scale.x * SeedRandom.Range(ref seed, MinOffset.x, MaxOffset.x); pos.y += scale.y * SeedRandom.Range(ref seed, MinOffset.y, MaxOffset.y); pos.z += scale.z * SeedRandom.Range(ref seed, MinOffset.z, MaxOffset.z); }
public static T GetRandom <T>(this T[] array, ref uint seed) { if (array == null || array.Length == 0) { return(default(T)); } return(array[SeedRandom.Range(ref seed, 0, array.Length)]); }
public static T GetRandom <T>(this List <T> list, ref uint seed) { if (list == null || list.Count == 0) { return(default(T)); } return(list[SeedRandom.Range(ref seed, 0, list.Count)]); }
public override void Process(uint seed) { TerrainHeightMap heightMap = TerrainMeta.HeightMap; Vector3 position = TerrainMeta.Position; Vector3 size = TerrainMeta.Size; float single = position.x; float single1 = position.z; float single2 = position.x + size.x; float single3 = position.z + size.z; PlaceMonument.SpawnInfo spawnInfo = new PlaceMonument.SpawnInfo(); int num = -2147483648; Prefab <MonumentInfo> prefab = Prefab.Load <MonumentInfo>(this.Monument.resourceID, null, null); for (int i = 0; i < 10000; i++) { float single4 = SeedRandom.Range(ref seed, single, single2); float single5 = SeedRandom.Range(ref seed, single1, single3); float single6 = TerrainMeta.NormalizeX(single4); float single7 = TerrainMeta.NormalizeZ(single5); float single8 = SeedRandom.Value(ref seed); float factor = this.Filter.GetFactor(single6, single7); if (factor * factor >= single8) { float height = heightMap.GetHeight(single6, single7); Vector3 vector3 = new Vector3(single4, height, single5); Quaternion obj = prefab.Object.transform.localRotation; Vector3 obj1 = prefab.Object.transform.localScale; prefab.ApplyDecorComponents(ref vector3, ref obj, ref obj1); if ((!prefab.Component || prefab.Component.CheckPlacement(vector3, obj, obj1)) && prefab.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && prefab.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && prefab.ApplyTerrainFilters(vector3, obj, obj1, null) && prefab.ApplyWaterChecks(vector3, obj, obj1) && !prefab.CheckEnvironmentVolumes(vector3, obj, obj1, EnvironmentType.Underground)) { PlaceMonument.SpawnInfo spawnInfo1 = new PlaceMonument.SpawnInfo() { prefab = prefab, position = vector3, rotation = obj, scale = obj1 }; int num1 = -Mathf.RoundToInt(vector3.Magnitude2D()); if (num1 > num) { num = num1; spawnInfo = spawnInfo1; } } } } if (num != -2147483648) { Prefab prefab1 = spawnInfo.prefab; Vector3 vector31 = spawnInfo.position; Quaternion quaternion = spawnInfo.rotation; Vector3 vector32 = spawnInfo.scale; prefab1.ApplyTerrainPlacements(vector31, quaternion, vector32); prefab1.ApplyTerrainModifiers(vector31, quaternion, vector32); World.AddPrefab("Monument", prefab1.ID, vector31, quaternion, vector32); } }
public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale) { uint num = pos.Seed(World.Seed) + 2; float single = SeedRandom.Range(ref num, this.MinRotation.x, this.MaxRotation.x); float single1 = SeedRandom.Range(ref num, this.MinRotation.y, this.MaxRotation.y); float single2 = SeedRandom.Range(ref num, this.MinRotation.z, this.MaxRotation.z); rot = Quaternion.Euler(single, single1, single2) * rot; }
public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale) { uint seed = pos.Seed(World.Seed) + 2; float x = SeedRandom.Range(ref seed, MinRotation.x, MaxRotation.x); float y = SeedRandom.Range(ref seed, MinRotation.y, MaxRotation.y); float z = SeedRandom.Range(ref seed, MinRotation.z, MaxRotation.z); rot = Quaternion.Euler(x, y, z) * rot; }
public override void Apply(ref Vector3 pos, ref Quaternion rot, ref Vector3 scale) { uint num1 = SeedEx.Seed(pos, World.Seed) + 2U; float num2 = SeedRandom.Range(ref num1, (float)this.MinRotation.x, (float)this.MaxRotation.x); float num3 = SeedRandom.Range(ref num1, (float)this.MinRotation.y, (float)this.MaxRotation.y); float num4 = SeedRandom.Range(ref num1, (float)this.MinRotation.z, (float)this.MaxRotation.z); rot = Quaternion.op_Multiply(Quaternion.Euler(num2, num3, num4), rot); }
public static void Shuffle <T>(this T[] array, ref uint seed) { for (int i = 0; i < (int)array.Length; i++) { int num = SeedRandom.Range(ref seed, 0, (int)array.Length); int num1 = SeedRandom.Range(ref seed, 0, (int)array.Length); T t = array[num]; array[num] = array[num1]; array[num1] = t; } }
public static void Shuffle <T>(this List <T> list, ref uint seed) { for (int i = 0; i < list.Count; i++) { int item = SeedRandom.Range(ref seed, 0, list.Count); int num = SeedRandom.Range(ref seed, 0, list.Count); T t = list[item]; list[item] = list[num]; list[num] = t; } }
public static void Shuffle <T>(this T[] array, ref uint seed) { for (int index1 = 0; index1 < array.Length; ++index1) { int index2 = SeedRandom.Range(ref seed, 0, array.Length); int index3 = SeedRandom.Range(ref seed, 0, array.Length); T obj = array[index2]; array[index2] = array[index3]; array[index3] = obj; } }
public static void Shuffle <T>(this T[] array, ref uint seed) { for (int i = 0; i < array.Length; i++) { int num = SeedRandom.Range(ref seed, 0, array.Length); int num2 = SeedRandom.Range(ref seed, 0, array.Length); T val = array[num]; array[num] = array[num2]; array[num2] = val; } }
public override void Process(uint seed) { TerrainHeightMap heightMap = TerrainMeta.HeightMap; Prefab[] array = Prefab.Load("assets/bundled/prefabs/autospawn/" + this.ResourceFolder, (GameManager)null, (PrefabAttribute.Library)null, true); if (array == null || array.Length == 0) { return; } Vector3 position = TerrainMeta.Position; Vector3 size = TerrainMeta.Size; int num1 = Mathf.RoundToInt((float)((double)this.ObjectDensity * size.x * size.z * 9.99999997475243E-07)); float x1 = (float)position.x; float z1 = (float)position.z; float num2 = (float)(position.x + size.x); float num3 = (float)(position.z + size.z); float num4 = SeedRandom.Range(ref seed, -1000000f, 1000000f); float num5 = SeedRandom.Range(ref seed, -1000000f, 1000000f); int octaves = this.Cluster.Octaves; float offset = this.Cluster.Offset; float frequency = this.Cluster.Frequency * 0.01f; float amplitude = this.Cluster.Amplitude; for (int index = 0; index < num1; ++index) { float x2 = SeedRandom.Range(ref seed, x1, num2); float z2 = SeedRandom.Range(ref seed, z1, num3); float normX = TerrainMeta.NormalizeX(x2); float normZ = TerrainMeta.NormalizeZ(z2); float num6 = SeedRandom.Value(ref seed); float factor = this.Filter.GetFactor(normX, normZ); Prefab random = array.GetRandom <Prefab>(ref seed); if ((double)factor > 0.0 && ((double)offset + (double)Noise.Turbulence(num4 + x2, num5 + z2, octaves, frequency, amplitude, 2f, 0.5f)) * (double)factor * (double)factor >= (double)num6) { float height = heightMap.GetHeight(normX, normZ); Vector3 pos; ((Vector3) ref pos).\u002Ector(x2, height, z2); Quaternion localRotation = random.Object.get_transform().get_localRotation(); Vector3 localScale = random.Object.get_transform().get_localScale(); random.ApplyDecorComponents(ref pos, ref localRotation, ref localScale); if (random.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && random.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter) && (random.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && random.ApplyWaterChecks(pos, localRotation, localScale))) { random.ApplyTerrainModifiers(pos, localRotation, localScale); World.AddPrefab("Decor", random.ID, pos, localRotation, localScale); } } } }
public override void Process(uint seed) { TerrainHeightMap heightMap = TerrainMeta.HeightMap; Prefab[] prefabArray = Prefab.Load(string.Concat("assets/bundled/prefabs/autospawn/", this.ResourceFolder), null, null, true); if (prefabArray == null || prefabArray.Length == 0) { return; } Vector3 position = TerrainMeta.Position; Vector3 size = TerrainMeta.Size; int num = Mathf.RoundToInt(this.ObjectDensity * size.x * size.z * 1E-06f); float single = position.x; float single1 = position.z; float single2 = position.x + size.x; float single3 = position.z + size.z; float single4 = SeedRandom.Range(ref seed, -1000000f, 1000000f); float single5 = SeedRandom.Range(ref seed, -1000000f, 1000000f); int octaves = this.Cluster.Octaves; float offset = this.Cluster.Offset; float frequency = this.Cluster.Frequency * 0.01f; float amplitude = this.Cluster.Amplitude; for (int i = 0; i < num; i++) { float single6 = SeedRandom.Range(ref seed, single, single2); float single7 = SeedRandom.Range(ref seed, single1, single3); float single8 = TerrainMeta.NormalizeX(single6); float single9 = TerrainMeta.NormalizeZ(single7); float single10 = SeedRandom.Value(ref seed); float factor = this.Filter.GetFactor(single8, single9); Prefab random = prefabArray.GetRandom <Prefab>(ref seed); if (factor > 0f && (offset + Noise.Turbulence(single4 + single6, single5 + single7, octaves, frequency, amplitude, 2f, 0.5f)) * factor * factor >= single10) { float height = heightMap.GetHeight(single8, single9); Vector3 vector3 = new Vector3(single6, height, single7); Quaternion obj = random.Object.transform.localRotation; Vector3 obj1 = random.Object.transform.localScale; random.ApplyDecorComponents(ref vector3, ref obj, ref obj1); if (random.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && random.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && random.ApplyTerrainFilters(vector3, obj, obj1, null) && random.ApplyWaterChecks(vector3, obj, obj1)) { random.ApplyTerrainModifiers(vector3, obj, obj1); World.AddPrefab("Decor", random.ID, vector3, obj, obj1); } } } }
public void Init(UnityEngine.Terrain terrainOverride = null, TerrainConfig configOverride = null) { if (terrainOverride != null) { this.terrain = terrainOverride; } if (configOverride != null) { this.config = configOverride; } TerrainMeta.Terrain = this.terrain; TerrainMeta.Config = this.config; TerrainMeta.Transform = this.terrain.transform; TerrainMeta.Data = this.terrain.terrainData; TerrainMeta.Size = this.terrain.terrainData.size; TerrainMeta.OneOverSize = TerrainMeta.Size.Inverse(); TerrainMeta.Position = this.terrain.GetPosition(); TerrainMeta.Collider = this.terrain.GetComponent <TerrainCollider>(); TerrainMeta.Collision = this.terrain.GetComponent <TerrainCollision>(); TerrainMeta.Physics = this.terrain.GetComponent <TerrainPhysics>(); TerrainMeta.Colors = this.terrain.GetComponent <TerrainColors>(); TerrainMeta.Quality = this.terrain.GetComponent <TerrainQuality>(); TerrainMeta.Path = this.terrain.GetComponent <TerrainPath>(); TerrainMeta.BiomeMap = this.terrain.GetComponent <TerrainBiomeMap>(); TerrainMeta.AlphaMap = this.terrain.GetComponent <TerrainAlphaMap>(); TerrainMeta.BlendMap = this.terrain.GetComponent <TerrainBlendMap>(); TerrainMeta.HeightMap = this.terrain.GetComponent <TerrainHeightMap>(); TerrainMeta.SplatMap = this.terrain.GetComponent <TerrainSplatMap>(); TerrainMeta.TopologyMap = this.terrain.GetComponent <TerrainTopologyMap>(); TerrainMeta.WaterMap = this.terrain.GetComponent <TerrainWaterMap>(); TerrainMeta.DistanceMap = this.terrain.GetComponent <TerrainDistanceMap>(); TerrainMeta.Texturing = this.terrain.GetComponent <TerrainTexturing>(); TerrainMeta.HighestPoint = new Vector3(TerrainMeta.Position.x, TerrainMeta.Position.y + TerrainMeta.Size.y, TerrainMeta.Position.z); TerrainMeta.LowestPoint = new Vector3(TerrainMeta.Position.x, TerrainMeta.Position.y, TerrainMeta.Position.z); TerrainExtension[] components = base.GetComponents <TerrainExtension>(); for (int i = 0; i < (int)components.Length; i++) { components[i].Init(this.terrain, this.config); } uint seed = World.Seed; int num = SeedRandom.Range(ref seed, 0, 4) * 90; int num1 = SeedRandom.Range(ref seed, -45, 46); int num2 = SeedRandom.Sign(ref seed); TerrainMeta.LootAxisAngle = (float)num; TerrainMeta.BiomeAxisAngle = (float)(num + num1 + num2 * 90); }
public void Init(Terrain terrainOverride = null, TerrainConfig configOverride = null) { if (Object.op_Inequality((Object)terrainOverride, (Object)null)) { this.terrain = terrainOverride; } if (Object.op_Inequality((Object)configOverride, (Object)null)) { this.config = configOverride; } TerrainMeta.Terrain = this.terrain; TerrainMeta.Config = this.config; TerrainMeta.Transform = ((Component)this.terrain).get_transform(); TerrainMeta.Data = this.terrain.get_terrainData(); TerrainMeta.Size = this.terrain.get_terrainData().get_size(); TerrainMeta.OneOverSize = Vector3Ex.Inverse(TerrainMeta.Size); TerrainMeta.Position = this.terrain.GetPosition(); TerrainMeta.Collider = (TerrainCollider)((Component)this.terrain).GetComponent <TerrainCollider>(); TerrainMeta.Collision = (TerrainCollision)((Component)this.terrain).GetComponent <TerrainCollision>(); TerrainMeta.Physics = (TerrainPhysics)((Component)this.terrain).GetComponent <TerrainPhysics>(); TerrainMeta.Colors = (TerrainColors)((Component)this.terrain).GetComponent <TerrainColors>(); TerrainMeta.Quality = (TerrainQuality)((Component)this.terrain).GetComponent <TerrainQuality>(); TerrainMeta.Path = (TerrainPath)((Component)this.terrain).GetComponent <TerrainPath>(); TerrainMeta.BiomeMap = (TerrainBiomeMap)((Component)this.terrain).GetComponent <TerrainBiomeMap>(); TerrainMeta.AlphaMap = (TerrainAlphaMap)((Component)this.terrain).GetComponent <TerrainAlphaMap>(); TerrainMeta.BlendMap = (TerrainBlendMap)((Component)this.terrain).GetComponent <TerrainBlendMap>(); TerrainMeta.HeightMap = (TerrainHeightMap)((Component)this.terrain).GetComponent <TerrainHeightMap>(); TerrainMeta.SplatMap = (TerrainSplatMap)((Component)this.terrain).GetComponent <TerrainSplatMap>(); TerrainMeta.TopologyMap = (TerrainTopologyMap)((Component)this.terrain).GetComponent <TerrainTopologyMap>(); TerrainMeta.WaterMap = (TerrainWaterMap)((Component)this.terrain).GetComponent <TerrainWaterMap>(); TerrainMeta.DistanceMap = (TerrainDistanceMap)((Component)this.terrain).GetComponent <TerrainDistanceMap>(); TerrainMeta.Texturing = (TerrainTexturing)((Component)this.terrain).GetComponent <TerrainTexturing>(); TerrainMeta.HighestPoint = new Vector3((float)TerrainMeta.Position.x, (float)(TerrainMeta.Position.y + TerrainMeta.Size.y), (float)TerrainMeta.Position.z); TerrainMeta.LowestPoint = new Vector3((float)TerrainMeta.Position.x, (float)TerrainMeta.Position.y, (float)TerrainMeta.Position.z); foreach (TerrainExtension component in (TerrainExtension[])((Component)this).GetComponents <TerrainExtension>()) { component.Init(this.terrain, this.config); } uint seed = World.Seed; int num1 = SeedRandom.Range(ref seed, 0, 4) * 90; int num2 = SeedRandom.Range(ref seed, -45, 46); int num3 = SeedRandom.Sign(ref seed); TerrainMeta.LootAxisAngle = (float)num1; TerrainMeta.BiomeAxisAngle = (float)(num1 + num2 + num3 * 90); }
public override void Process(uint seed) { TerrainHeightMap heightMap = TerrainMeta.HeightMap; Prefab[] array = Prefab.Load("assets/bundled/prefabs/autospawn/" + this.ResourceFolder, (GameManager)null, (PrefabAttribute.Library)null, true); if (array == null || array.Length == 0) { return; } Vector3 position = TerrainMeta.Position; Vector3 size = TerrainMeta.Size; float x1 = (float)position.x; float z1 = (float)position.z; float num1 = (float)(position.x + size.x); float num2 = (float)(position.z + size.z); for (float num3 = z1; (double)num3 < (double)num2; num3 += this.ObjectDistance) { for (float num4 = x1; (double)num4 < (double)num1; num4 += this.ObjectDistance) { float x2 = num4 + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering); float z2 = num3 + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering); float normX = TerrainMeta.NormalizeX(x2); float normZ = TerrainMeta.NormalizeZ(z2); float num5 = SeedRandom.Value(ref seed); double factor = (double)this.Filter.GetFactor(normX, normZ); Prefab random = array.GetRandom <Prefab>(ref seed); if (factor * factor >= (double)num5) { float height = heightMap.GetHeight(normX, normZ); Vector3 pos; ((Vector3) ref pos).\u002Ector(x2, height, z2); Quaternion localRotation = random.Object.get_transform().get_localRotation(); Vector3 localScale = random.Object.get_transform().get_localScale(); random.ApplyDecorComponents(ref pos, ref localRotation, ref localScale); if (random.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && random.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter) && (random.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && random.ApplyWaterChecks(pos, localRotation, localScale))) { random.ApplyTerrainModifiers(pos, localRotation, localScale); World.AddPrefab("Decor", random.ID, pos, localRotation, localScale); } } } } }
public override void Process(uint seed) { TerrainHeightMap heightMap = TerrainMeta.HeightMap; Prefab[] prefabArray = Prefab.Load(string.Concat("assets/bundled/prefabs/autospawn/", this.ResourceFolder), null, null, true); if (prefabArray == null || prefabArray.Length == 0) { return; } Vector3 position = TerrainMeta.Position; Vector3 size = TerrainMeta.Size; float single = position.x; float single1 = position.z; float single2 = position.x + size.x; float single3 = position.z + size.z; for (float i = single1; i < single3; i += this.ObjectDistance) { for (float j = single; j < single2; j += this.ObjectDistance) { float single4 = j + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering); float single5 = i + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering); float single6 = TerrainMeta.NormalizeX(single4); float single7 = TerrainMeta.NormalizeZ(single5); float single8 = SeedRandom.Value(ref seed); float factor = this.Filter.GetFactor(single6, single7); Prefab random = prefabArray.GetRandom <Prefab>(ref seed); if (factor * factor >= single8) { float height = heightMap.GetHeight(single6, single7); Vector3 vector3 = new Vector3(single4, height, single5); Quaternion obj = random.Object.transform.localRotation; Vector3 obj1 = random.Object.transform.localScale; random.ApplyDecorComponents(ref vector3, ref obj, ref obj1); if (random.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && random.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && random.ApplyTerrainFilters(vector3, obj, obj1, null) && random.ApplyWaterChecks(vector3, obj, obj1)) { random.ApplyTerrainModifiers(vector3, obj, obj1); World.AddPrefab("Decor", random.ID, vector3, obj, obj1); } } } } }
public static Prefab LoadRandom(string folder, ref uint seed, GameManager manager = null, PrefabAttribute.Library attribute = null, bool useProbabilities = true) { if (string.IsNullOrEmpty(folder)) { return(null); } if (manager == null) { manager = Prefab.DefaultManager; } if (attribute == null) { attribute = Prefab.DefaultAttribute; } string[] strArrays = Prefab.FindPrefabNames(folder, useProbabilities); if (strArrays.Length == 0) { return(null); } string str = strArrays[SeedRandom.Range(ref seed, 0, (int)strArrays.Length)]; return(new Prefab(str, manager.FindPrefab(str), manager, attribute)); }
public static int Range(uint seed, int min, int max) { return(SeedRandom.Range(ref seed, min, max)); }
public float Range(float min, float max) { return(SeedRandom.Range(ref this.Seed, min, max)); }
public int Range(int min, int max) { return(SeedRandom.Range(ref this.Seed, min, max)); }
public static float Range(uint seed, float min, float max) { return(SeedRandom.Range(ref seed, min, max)); }