public static void AttachGroupAround(ILinkData newObj) { LinkGroupUtility.CheckAround(newObj, (i, current) => { int invert = LinkGroupUtility.Invert(i); if (current.CanLinkFromOther(i) && newObj.CanLinkFromOther(invert)) { current.GroupParent.Concat(newObj.GroupParent); newObj.Notify_Linked(current, i); current.Notify_Linked(newObj, invert); } }); }
public static bool ShouldSingle(IntVec3 pos, Map map) { int num = LinkGroupUtility.AlignQualityAgainst(pos + IntVec3.East, map); num += LinkGroupUtility.AlignQualityAgainst(pos + IntVec3.West, map); if (num == 2) { return(true); } num = LinkGroupUtility.AlignQualityAgainst(pos + IntVec3.North, map); num += LinkGroupUtility.AlignQualityAgainst(pos + IntVec3.South, map); if (num == 2) { return(true); } return(false); }
public override void Draw() { if (this.linkable.IsSingle) { base.Draw(); return; } if (LinkGroupUtility.ShouldSingle(base.Position, base.Map)) { LinkGroupUtility.DetachGroupAround(this.linkable); base.Draw(); return; } base.Rotation = this.linkable.LineDirection; float num = Mathf.Clamp01((float)this.ticksSinceOpen / (float)base.TicksToOpenNow); float[] move = { 0, 0 }; int index; switch (this.linkable.PosTag) { case PositionTag.LeftSide: this.linkable.CommonField = 1f * num; move[0] = this.GetMoveOffset(PositionTag.LeftSide); index = 0; break; case PositionTag.RightSide: this.linkable.CommonField = 1f * num; move[0] = this.GetMoveOffset(PositionTag.RightSide); index = 1; break; case PositionTag.LeftBorder | PositionTag.LeftSide: this.linkable.CommonField = (1f - ProtrudedDoorOffset) * num; move[0] = this.GetMoveOffset(PositionTag.LeftSide); move[1] = move[0]; index = 2; break; case PositionTag.RightBorder | PositionTag.RightSide: this.linkable.CommonField = (1f - ProtrudedDoorOffset) * num; move[0] = this.GetMoveOffset(PositionTag.RightSide); move[1] = move[0]; index = 3; break; case PositionTag.Center: this.linkable.CommonField = (0.5f - ProtrudedDoorOffset) * num; move[0] = this.GetMoveOffset(PositionTag.LeftSide); move[1] = this.GetMoveOffset(PositionTag.RightSide); index = 4; break; default: Log.Error("[LinkableDoors] default"); index = 0; break; } Vector3[] coefficients = LD_MeshPool.doorMeshPosSet[index].coefficients; Vector3[] offsets = LD_MeshPool.doorMeshPosSet[index].offsets; Mesh[] meshes = LD_MeshPool.doorMeshPosSet[index].meshes; Rot4 rotation = base.Rotation; rotation.Rotate(RotationDirection.Clockwise); Quaternion quat = rotation.AsQuat; for (int i = 0; i < 2; i++) { if (meshes[i] != null) { Vector3 vector = this.DrawPos; vector.y = Altitudes.AltitudeFor(AltitudeLayer.DoorMoveable) + offsets[i].y; Vector3 vector2 = quat * coefficients[i]; Vector3 vector3 = quat * offsets[i]; vector += vector3 + vector2 * move[i]; Graphics.DrawMesh(meshes[i], vector, base.Rotation.AsQuat, this.Graphic.MatAt(base.Rotation, null), 0); } } base.Comps_PostDraw(); }
public static void Notify_LinkableDeSpawned(ILinkData delObj) { LinkGroupUtility.DetachGroupAround(delObj); }
public static void Notify_LinkableSpawned(ILinkData newObj) { ILinkGroup result = new LinkGroup(newObj); LinkGroupUtility.AttachGroupAround(newObj); }
public override void PostDeSpawn(Map map) { base.PostDeSpawn(map); LinkGroupUtility.Notify_LinkableDeSpawned(this); }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); this.LineDirection = default(Rot4); LinkGroupUtility.Notify_LinkableSpawned(this); }
public virtual bool CanLinkFromOther(int direction) { return(this.linkableDirections(direction) && this.GroupParent.Children.Count() < this.compDef.linkableLimit && !LinkGroupUtility.ShouldSingle(this.Pos, this.Map)); }