public bool IsValidFoundationSpot(Vector3 searchPos) { if (this._structureComponents.Count == 0) { return(true); } foreach (StructureComponent component in this._structureComponents) { if (component.type == StructureComponent.StructureComponentType.Foundation) { Vector3 vector2; Vector3 vector3; Vector3 vector = component.transform.InverseTransformPoint(searchPos); bool flag = ((this.Approx(Mathf.Abs(vector.x), 5f) && this.Approx(vector.z, 0f)) || (this.Approx(Mathf.Abs(vector.z), 5f) && this.Approx(vector.x, 0f))) && this.Approx(vector.y, 0f); bool flag2 = false; if (TransformHelpers.GetGroundInfoTerrainOnly(searchPos + new Vector3(0f, 3.5f, 0f), 3.5f, out vector2, out vector3)) { flag2 = true; } if (flag && !flag2) { flag = false; } bool flag3 = false; if (flag || flag3) { return(true); } } } return(false); }
public GameObject SpawnGeneric(Spawns.SpawnerGeneric.SpawnInstance instance) { Vector3 startPos = this.Position + UnityEngine.Random.insideUnitSphere * this.SpawnRadius; startPos.y = this.Position.y; Quaternion quaternion = Quaternion.Euler(new Vector3(0f, (float)UnityEngine.Random.Range(0, 360), 0f)); Vector3 vector; if (instance.UseNavmeshSample && TransformHelpers.GetGroundInfoNavMesh(startPos, out vector, 15f, -1)) { startPos = vector; } Vector3 up; GameObject result; if (TransformHelpers.GetGroundInfoTerrainOnly(startPos, 300f, out vector, out up)) { vector.y += 0.05f; if (instance.PrefabName == "BoxLoot") { vector.y += 0.35f; } quaternion = TransformHelpers.LookRotationForcedUp(quaternion * Vector3.forward, up); GameObject gameObject; if (!instance.StaticInstantiate && !instance.PrefabName.StartsWith(";")) { gameObject = NetCull.InstantiateDynamic(instance.PrefabName, vector, quaternion); } else { gameObject = NetCull.InstantiateStatic(instance.PrefabName, vector, quaternion); } if (gameObject != null) { instance.Spawned.Add(gameObject); } result = gameObject; } else { result = null; } return(result); }