public bool CanAttach(OverlapWorld world, MapSiteDef site, HierarchyTransform t) { if (Size < site.AttachmentSize) { return(false); } var localT = new HierarchyTransform(Pos, Rot, t); var attachmentrT = new HierarchyTransform(default, site.AttachmentRotation, localT);
public MapSiteInstance(MapSiteDef def, Vec2 pos, float rot, bool attachedToBottom) { Def = def; World = new OverlapWorld(def.SizeX, def.SizeY); Pos = pos; Rot = rot; AttachedToBottom = attachedToBottom; }
public BaseDef Export() { var siteDef = new MapSiteDef(); var subSites = GetComponentsInChildren <SubSiteObject>(); var connections = GetComponentsInChildren <ConnectionObject>(); var attachment = GetComponentInChildren <MapSiteAttachmentObject>(); foreach (var subSite in subSites) { siteDef.SubSites.Add(new SubSite() { Pos = new Vec2(subSite.transform.position.x, subSite.transform.position.z), Rot = subSite.transform.rotation.eulerAngles.y, SizeX = subSite.transform.lossyScale.x, SizeY = subSite.transform.lossyScale.z, Tags = subSite.Tags.Select((x) => { var r = new DefRef <MapSiteTagDef>(new MapSiteTagDef()); ((IDef)r.Def).Address = new DefIDFull($"/Tags/{x}"); return(r); }).ToList() }); } foreach (var connection in connections) { siteDef.Connections.Add(new SiteConnection() { Pos = new Vec2(connection.transform.position.x, connection.transform.position.z), Rot = 360 - connection.transform.rotation.eulerAngles.y, Size = connection.transform.lossyScale.x, Tags = connection.Tags.Select((x) => { var r = new DefRef <MapSiteTagDef>(new MapSiteTagDef()); ((IDef)r.Def).Address = new DefIDFull($"/Tags/{x}"); return(r); }).ToList() }); } siteDef.SizeX = Size.x * transform.localScale.x; siteDef.SizeY = Size.z * transform.localScale.z; siteDef.Tags = Tags.Select((x) => { var r = new DefRef <MapSiteTagDef>(new MapSiteTagDef()); ((IDef)r.Def).Address = new DefIDFull($"/Tags/{x}"); return(r); }).ToList(); siteDef.Type = new MapSiteTypeDef() { EntitiesToSpawnOn = EntitiesToSpawnOn.Select(x => { var r = new DefRef <IEntityObjectDef>(new RefStubEntityObjectDef()); ((IDef)r.Def).Address = new DefIDFull($"/{x.name}"); return(r); }).ToList() }; if (attachment != null) { siteDef.AttachmentPoint = new Vec2(attachment.transform.position.x, attachment.transform.position.z); siteDef.AttachmentRotation = attachment.transform.rotation.eulerAngles.y; siteDef.AttachmentSize = Mathf.Abs(attachment.transform.lossyScale.x); } var sceneDef = SceneDefGetter.ExportSceneFrom(gameObject.GetComponentsInChildren <ISceneExportable>()); siteDef.AttachedScene = sceneDef; return(siteDef); }
public void Setup(MapSiteDef rootSite, Vec2 pos, float rot) { _rootInstance = new MapSiteInstance(rootSite, pos, rot, false); }