/// <summary> /// Registers the given room as a possibility if it isn't already registered. /// </summary> /// <param name="transform"></param> /// <param name="part"></param> private RoomMeta RegisterKey(MatrixI transform, PartFromPrefab part) { var key = new RoomKey(transform, part); RoomMeta room; if (!m_openRooms.TryGetValue(key, out room)) { var ent = new ProceduralRoom(); ent.Init(transform, part); m_openRooms[key] = room = new RoomMeta(ent); } else if (room.Nonce == m_nonce) { return(room); } room.Nonce = m_nonce; room.InFactor = 0; foreach (var mount in room.Room.MountPoints) { var other = mount.AttachedToIn(m_construction); if (other == null) { continue; } room.InFactor++; m_possibleRooms.Add(other, room); } return(room); }
public bool Intersects(PartFromPrefab other, MatrixI otherTransform, MatrixI otherITransform, bool testOptional, bool testQuick = false, ProceduralRoom ignore = null) { var bb = Utilities.TransformBoundingBox(other.BoundingBoxBoth, otherTransform); var result = false; m_roomTree.Query((x) => { var test = m_roomTree.GetUserData <ProceduralRoom>(x); var res = test != ignore && test.Intersects(other, otherTransform, otherITransform, testOptional, testQuick); result = res; return(!res); }, ref bb); return(result); }
public void Init(MatrixI transform, PartFromPrefab prefab) { m_part = prefab; Transform = transform; m_mountPoints = new Dictionary <string, Dictionary <string, ProceduralMountPoint> >(); using (m_part.LockSharedUsing()) foreach (var mount in prefab.MountPoints) { var point = new ProceduralMountPoint(); point.Init(mount, this); Dictionary <string, ProceduralMountPoint> byName; if (!m_mountPoints.TryGetValue(point.MountPoint.MountType, out byName)) { m_mountPoints[point.MountPoint.MountType] = byName = new Dictionary <string, ProceduralMountPoint>(); } byName[point.MountPoint.MountName] = point; } }
public RoomKey(MatrixI transform, PartFromPrefab part) { Transformation = transform; Part = part; }
public bool Intersects(PartFromPrefab other, MatrixI otherTransform, MatrixI otherITransform, bool testOptional, bool testQuick = false) { return(PartMetadata.Intersects(ref m_part, ref m_transform, ref m_invTransform, ref other, ref otherTransform, ref otherITransform, testOptional, testQuick)); }