Exemplo n.º 1
0
        public void OnTouchStay(int fingerId, Vector2 touchPosWorld, Vector2 deltaPixel)
        {
            Vector2 v = Camera.main.ScreenToWorldPoint((Vector3)deltaPixel + new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), -Camera.main.transform.position.z)) - Camera.main.transform.position;

            this.roundStrength = Mathf.Clamp01(this.roundStrength + v.magnitude * this.smoothIncrease - this.smoothDecay * Time.deltaTime);
            if (Build.HoldingPart.isNull(this.holdingParts[fingerId]))
            {
                this.MoveCamera(v);
                this.pickGrid.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(0f, (float)Screen.height, this.pickMenuDistance)) + (Vector3)this.pickMenuPosition;
                return;
            }
            Vector2 vector      = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset);
            Vector2 autoCorrect = this.GetAutoCorrect(vector, fingerId);

            if (this.holdingParts[fingerId].part.partIcon != null)
            {
                PlacedPart          tgtPart = this.holdingParts[fingerId].part;
                Vector3             tgtPos  = Vector3.Lerp(vector, autoCorrect, 1f - this.roundStrength);
                MyPartStartDragHook hook    = new MyPartStartDragHook(tgtPart, tgtPos);
                if (hook.isCanceled())
                {
                    return;
                }
                this.holdingParts[fingerId].part.partIcon.position = hook.pos;
            }
        }
Exemplo n.º 2
0
        private void UpdateInactive()
        {
            List <PlacedPart> list = new List <PlacedPart>();

            for (int i = 0; i < this.inactiveParts.Count; i++)
            {
                if (Ref.hasPartsExpansion || !this.inactiveParts[i].partData.inFull)
                {
                    bool flag = false;
                    for (int j = 0; j < this.parts.Count; j++)
                    {
                        if (PlacedPart.IsOverplaing(this.inactiveParts[i], this.parts[j]))
                        {
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        UnityEngine.Object.Destroy(this.inactiveParts[i].partIcon.gameObject);
                        this.inactiveParts[i].partIcon = PartGrid.LoadIcon(this.iconPrefab, this.inactiveParts[i].partData.prefab, this.inactiveParts[i].position, this.inactiveParts[i].partData.prefab.localScale, base.transform, 0, this.inactiveParts[i].orientation, Color.white, true);
                        list.Add(this.inactiveParts[i]);
                        MonoBehaviour.print(this.inactiveParts[i].partData.name);
                        this.parts.Add(this.inactiveParts[i]);
                        this.inactiveParts.RemoveAt(i);
                        i--;
                    }
                }
            }
            for (int k = 0; k < list.Count; k++)
            {
                list[k].UpdateConnected(this.parts);
            }
        }
Exemplo n.º 3
0
        public void UpdateSuraface(PartData.AttachmentSurface surfaceA, List <PlacedPart> parts)
        {
            float num = 0f;

            foreach (PlacedPart current in parts)
            {
                if (current.partData != null)
                {
                    PartData.AttachmentSurface[] attachmentSurfaces = current.partData.attachmentSurfaces;
                    for (int i = 0; i < attachmentSurfaces.Length; i++)
                    {
                        PartData.AttachmentSurface surfaceB = attachmentSurfaces[i];
                        if (current != this)
                        {
                            num += Mathf.Max(0f, PlacedPart.SurfacesConnect(this, surfaceA, current, surfaceB));
                        }
                    }
                }
            }
            bool flag = num > 0f;

            PartData.AttachmentSprite[] attachmentSprites = this.partData.attachmentSprites;
            for (int j = 0; j < attachmentSprites.Length; j++)
            {
                PartData.AttachmentSprite attachmentSprite = attachmentSprites[j];
                if (this.partData.attachmentSurfaces[attachmentSprite.surfaceId] == surfaceA)
                {
                    Utility.GetByPath(this.partIcon, attachmentSprite.path).gameObject.SetActive(flag != attachmentSprite.inverse);
                }
            }
        }
Exemplo n.º 4
0
        public void UpdateSuraface(PartData.AttachmentSurface surfaceA, List <PlacedPart> parts)
        {
            float num = 0f;

            foreach (PlacedPart placedPart in parts)
            {
                if (placedPart.partData != null)
                {
                    foreach (PartData.AttachmentSurface surfaceB in placedPart.partData.attachmentSurfaces)
                    {
                        if (placedPart != this)
                        {
                            num += Mathf.Max(0f, PlacedPart.SurfacesConnect(this, surfaceA, placedPart, surfaceB));
                        }
                    }
                }
            }
            bool flag = num > 0f;

            foreach (PartData.AttachmentSprite attachmentSprite in this.partData.attachmentSprites)
            {
                if (attachmentSprite.surfaceId != -1)
                {
                    if (this.partData.attachmentSurfaces[attachmentSprite.surfaceId] == surfaceA)
                    {
                        Utility.GetByPath(this.partIcon, attachmentSprite.path).gameObject.SetActive(flag != attachmentSprite.inverse);
                    }
                }
                else
                {
                    Utility.GetByPath(this.partIcon, attachmentSprite.path).gameObject.SetActive(attachmentSprite.inverse);
                }
            }
        }
Exemplo n.º 5
0
        public void OnTouchStay(int fingerId, Vector2 touchPosWorld, Vector2 deltaPixel)
        {
            Vector2 v = default(Vector2);

            v = Camera.main.ScreenToWorldPoint((Vector3)deltaPixel + new Vector3((float)(Screen.width / 2), (float)(Screen.height / 2), -Camera.main.transform.position.z)) - Camera.main.transform.position;
            this.roundStrength = Mathf.Clamp01(this.roundStrength + v.magnitude * this.smoothIncrease - this.smoothDecay * Time.deltaTime);
            if (Build.HoldingPart.isNull(this.holdingParts[fingerId]))
            {
                this.MoveCamera(v);
                this.pickGrid.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(0f, (float)Screen.height, this.pickMenuDistance)) + (Vector3)this.pickMenuPosition;
                return;
            }
            Vector2 vector = touchPosWorld + this.holdingParts[fingerId].holdingOffset;

            if (this.pickGrid.IsInsideDropArea(Utility.ToDepth(vector + this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation, this.pickMenuDistance)))
            {
                this.roundStrength = 1f;
            }
            Vector2 autoCorrect = this.GetAutoCorrect(vector, fingerId);

            if (this.holdingParts[fingerId].part.partIcon != null)
            {
                PlacedPart     part           = this.holdingParts[fingerId].part;
                Vector3        newPos         = Vector3.Lerp(vector, autoCorrect, 1f - this.roundStrength);
                MyPartDragHook myPartDragHook = new MyPartDragHook(part, newPos);
                bool           flag3          = myPartDragHook.isCanceled();
                if (!flag3)
                {
                    this.holdingParts[fingerId].part.partIcon.position = myPartDragHook.pos;
                }
            }
        }
Exemplo n.º 6
0
        public void OnTouchEnd(int fingerId, Vector2 touchPosWorld)
        {
            if (Build.HoldingPart.isNull(this.holdingParts[fingerId]))
            {
                return;
            }
            Vector2 vector      = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset);
            Vector2 autoCorrect = this.GetAutoCorrect(vector, fingerId);
            Vector2 a           = Vector3.Lerp(vector, autoCorrect, 1f - this.roundStrength);
            Vector2 v           = a + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : (this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation));
            bool    flag        = Utility.IsInsideRange(v.x - this.buildGrid.transform.position.x, -0.5f, this.buildGrid.width + 0.5f, true) && Utility.IsInsideRange(v.y - this.buildGrid.transform.position.y, -0.5f, this.buildGrid.height + 0.5f, true);
            bool    flag2       = this.pickGrid.IsInsideDropArea(Utility.ToDepth(v, this.pickMenuDistance));

            if (flag && !flag2)
            {
                PlacedPart        newPart = new PlacedPart(null, (Vector3)autoCorrect - this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData);
                MyPartCreatedHook hook    = new MyPartCreatedHook(newPart);
                hook = MyHookSystem.executeHook <MyPartCreatedHook>(hook);
                if (hook.isCanceled())
                {
                    return;
                }
                this.dragAndDropInstruction.InvokeEvenets();
                this.buildGrid.PlacePart(hook.target);
            }
            if (this.holdingParts[fingerId].part.partIcon != null)
            {
                UnityEngine.Object.Destroy(this.holdingParts[fingerId].part.partIcon.gameObject);
            }
            this.holdingParts[fingerId] = null;
        }
Exemplo n.º 7
0
        public void ClampToLimits(PlacedPart part)
        {
            Vector2 zero  = Vector2.zero;
            Vector2 zero2 = Vector2.zero;

            foreach (PartData.Area area in part.partData.areas)
            {
                Vector2 vector  = part.position + area.start * part.orientation;
                Vector2 vector2 = part.position + (area.start + area.size) * part.orientation;
                zero = new Vector2(Mathf.Max(new float[]
                {
                    zero.x,
                    vector.x,
                    vector2.x
                }), Mathf.Max(new float[]
                {
                    zero.y,
                    vector.y,
                    vector2.y
                }));
                zero2 = new Vector2(Mathf.Min(new float[]
                {
                    zero2.x,
                    vector.x,
                    vector2.x
                }), Mathf.Min(new float[]
                {
                    zero2.y,
                    vector.y,
                    vector2.y
                }));
            }
            part.position -= new Vector2(Mathf.Min(0f, zero2.x), Mathf.Min(0f, zero2.y)) + new Vector2(Mathf.Max(0f, zero.x - this.width), Mathf.Max(0f, zero.y - this.height));
        }
Exemplo n.º 8
0
 public void RemovePart(PlacedPart partToRemove)
 {
     if (partToRemove.partIcon != null)
     {
         UnityEngine.Object.Destroy(partToRemove.partIcon.gameObject);
     }
     this.parts.Remove(partToRemove);
     this.UpdateAllConnections();
 }
Exemplo n.º 9
0
 public bool Overlap(PlacedPart part)
 {
     for (int i = this.parts.Count - 1; i >= 0; i--)
     {
         if (PlacedPart.IsOverplaing(part, this.parts[i]))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 10
0
 public static PlacedPart PointCastParts(Vector2 pointPositionLocal, List <PlacedPart> castParts)
 {
     for (int i = 0; i < castParts.Count; i++)
     {
         if (PlacedPart.IsInside(pointPositionLocal, castParts[i]))
         {
             return(castParts[i]);
         }
     }
     return(null);
 }
Exemplo n.º 11
0
 public static bool IsInside(Vector2 a, PlacedPart b, float edge)
 {
     foreach (PartData.Area area in b.partData.areas)
     {
         bool flag  = Utility.IsInsideRange(a.x, b.GetWorldPosition(area.start).x, b.GetWorldPosition(area.start + area.size).x, true, edge);
         bool flag2 = Utility.IsInsideRange(a.y, b.GetWorldPosition(area.start).y, b.GetWorldPosition(area.start + area.size).y, true, edge);
         if (flag && flag2)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 12
0
 public static bool IsInside(Vector2 a, PlacedPart b)
 {
     PartData.Area[] areas = b.partData.areas;
     for (int i = 0; i < areas.Length; i++)
     {
         PartData.Area area  = areas[i];
         bool          flag  = Utility.IsInsideRange(a.x, b.GetWorldPosition(area.start).x, b.GetWorldPosition(area.start + area.size).x, true);
         bool          flag2 = Utility.IsInsideRange(a.y, b.GetWorldPosition(area.start).y, b.GetWorldPosition(area.start + area.size).y, true);
         if (flag && flag2)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 13
0
        public Build.HoldingPart TryTakePart(Vector2 mousePos, bool remove)
        {
            Vector2    vector     = (Vector3)mousePos - base.transform.position;
            PlacedPart placedPart = PartGrid.PointCastParts(vector, this.parts);

            if (placedPart == null)
            {
                return(null);
            }
            if (remove)
            {
                this.RemovePart(placedPart);
            }
            Ref.inputController.PlayClickSound(0.2f);
            return(new Build.HoldingPart(placedPart.position - vector, new PlacedPart(null, placedPart.position, placedPart.orientation.DeepCopy(), placedPart.partData)));
        }
Exemplo n.º 14
0
 public void PlacePart(PlacedPart newPart)
 {
     this.ClampToLimits(newPart);
     for (int i = this.parts.Count - 1; i >= 0; i--)
     {
         if (PlacedPart.IsOverplaing(newPart, this.parts[i]))
         {
             this.RemovePart(this.parts[i]);
         }
     }
     if (newPart.partData.prefab != null)
     {
         newPart.partIcon = PartGrid.LoadIcon(this.iconPrefab, newPart.partData.prefab, newPart.position, newPart.partData.prefab.localScale, base.transform, 0, newPart.orientation);
     }
     this.parts.Add(newPart);
     this.UpdateAllConnections();
     Ref.inputController.PlayClickSound(0.6f);
 }
Exemplo n.º 15
0
        public void OnTouchEnd(int fingerId, Vector2 touchPosWorld)
        {
            if (Build.HoldingPart.isNull(this.holdingParts[fingerId]))
            {
                return;
            }
            Vector2 vector  = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset);
            Vector2 vector2 = this.GetAutoCorrect(vector, fingerId);
            Vector2 a       = Vector3.Lerp(vector, vector2, 1f - this.roundStrength);
            Vector2 v       = a + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : (this.holdingParts[fingerId].part.partData.centerOfRotation * this.holdingParts[fingerId].part.orientation));
            bool    flag    = Utility.IsInsideRange(v.x - this.buildGrid.transform.position.x, -0.5f, this.buildGrid.width + 0.5f, true) && Utility.IsInsideRange(v.y - this.buildGrid.transform.position.y, -0.5f, this.buildGrid.height + 0.5f, true);
            bool    flag2   = this.pickGrid.IsInsideDropArea(Utility.ToDepth(v, this.pickMenuDistance));

            if (flag && !flag2)
            {
                PlacedPart        targetPart        = new PlacedPart(null, vector2 - (Vector2)this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData);
                MyPartCreatedHook myPartCreatedHook = new MyPartCreatedHook(targetPart);
                myPartCreatedHook = MyHookSystem.executeHook <MyPartCreatedHook>(myPartCreatedHook);
                bool flag5 = myPartCreatedHook.isCanceled();
                if (flag5)
                {
                    return;
                }
                if (this.holdingParts[fingerId].part.partData.flip2stickX && this.ConnectedSurface(vector2, fingerId) == 0f)
                {
                    this.FlipX();
                    Vector2 vector3 = vector2;
                    vector  = touchPosWorld + (Build.HoldingPart.isNull(this.holdingParts[fingerId]) ? Vector2.zero : this.holdingParts[fingerId].holdingOffset);
                    vector2 = this.GetAutoCorrect(vector, fingerId);
                    if (this.ConnectedSurface(vector2, fingerId) == 0f)
                    {
                        this.FlipX();
                        vector2 = vector3;
                    }
                }
                bool placeActive = !this.holdingParts[fingerId].part.partData.inFull || Ref.hasPartsExpansion;
                this.buildGrid.PlacePart(new PlacedPart(null, vector2 - (Vector2)this.buildGrid.transform.position, this.holdingParts[fingerId].part.orientation.DeepCopy(), this.holdingParts[fingerId].part.partData), placeActive);
            }
            if (this.holdingParts[fingerId].part.partIcon != null)
            {
                UnityEngine.Object.Destroy(this.holdingParts[fingerId].part.partIcon.gameObject);
            }
            this.holdingParts[fingerId] = null;
        }
Exemplo n.º 16
0
 public static bool IsOverplaing(PlacedPart a, PlacedPart b)
 {
     foreach (PartData.Area area in a.partData.areas)
     {
         foreach (PartData.Area area2 in b.partData.areas)
         {
             if (!area.hitboxOnly && !area2.hitboxOnly)
             {
                 bool flag  = Utility.LineOverlaps(a.GetWorldPosition(area.start).x, a.GetWorldPosition(area.start + area.size).x, b.GetWorldPosition(area2.start).x, b.GetWorldPosition(area2.start + area2.size).x);
                 bool flag2 = Utility.LineOverlaps(a.GetWorldPosition(area.start).y, a.GetWorldPosition(area.start + area.size).y, b.GetWorldPosition(area2.start).y, b.GetWorldPosition(area2.start + area2.size).y);
                 if (flag && flag2)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 17
0
 public static bool IsOverplaing(PlacedPart a, PlacedPart b)
 {
     PartData.Area[] areas = a.partData.areas;
     for (int i = 0; i < areas.Length; i++)
     {
         PartData.Area   area   = areas[i];
         PartData.Area[] areas2 = b.partData.areas;
         for (int j = 0; j < areas2.Length; j++)
         {
             PartData.Area area2 = areas2[j];
             bool          flag  = Utility.LineOverlaps(a.GetWorldPosition(area.start).x, a.GetWorldPosition(area.start + area.size).x, b.GetWorldPosition(area2.start).x, b.GetWorldPosition(area2.start + area2.size).x);
             bool          flag2 = Utility.LineOverlaps(a.GetWorldPosition(area.start).y, a.GetWorldPosition(area.start + area.size).y, b.GetWorldPosition(area2.start).y, b.GetWorldPosition(area2.start + area2.size).y);
             if (flag && flag2)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 18
0
 public void PlacePart(PlacedPart newPart, bool placeActive)
 {
     this.ClampToLimits(newPart);
     this.CreateUndoSave();
     Ref.inputController.PlayClickSound(0.6f);
     if (placeActive)
     {
         for (int i = 0; i < this.parts.Count; i++)
         {
             if (PlacedPart.IsOverplaing(newPart, this.parts[i]))
             {
                 UnityEngine.Object.Destroy(this.parts[i].partIcon.gameObject);
                 this.parts[i].partIcon = PartGrid.LoadIcon(this.iconPrefab, this.parts[i].partData.prefab, this.parts[i].position, this.parts[i].partData.prefab.localScale, base.transform, -50, this.parts[i].orientation, Color.white, true);
                 this.inactiveParts.Add(this.parts[i]);
                 this.parts.RemoveAt(i);
                 i--;
             }
         }
         this.parts.Add(newPart);
         newPart.partIcon = PartGrid.LoadIcon(this.iconPrefab, newPart.partData.prefab, newPart.position, newPart.partData.prefab.localScale, base.transform, 0, newPart.orientation, Color.white, true);
         foreach (PartData.AttachmentSurface surfaceA in newPart.partData.attachmentSurfaces)
         {
             foreach (PlacedPart placedPart in this.parts)
             {
                 foreach (PartData.AttachmentSurface surfaceB in placedPart.partData.attachmentSurfaces)
                 {
                     if (PlacedPart.SurfacesConnect(newPart, surfaceA, placedPart, surfaceB) > 0f)
                     {
                         placedPart.UpdateConnected(this.parts);
                     }
                 }
             }
         }
     }
     else
     {
         this.inactiveParts.Add(newPart);
         newPart.partIcon = PartGrid.LoadIcon(this.iconPrefab, newPart.partData.prefab, newPart.position, newPart.partData.prefab.localScale, base.transform, -50, newPart.orientation, Color.white, true);
     }
     newPart.UpdateConnected(this.parts);
 }
Exemplo n.º 19
0
        public float ConnectedSurface(Vector2 position, int fingerId)
        {
            float      num        = 0f;
            PlacedPart placedPart = new PlacedPart(null, position, this.holdingParts[fingerId].part.orientation, this.holdingParts[fingerId].part.partData);

            foreach (PartData.AttachmentSurface surfaceA in placedPart.partData.attachmentSurfaces)
            {
                foreach (PlacedPart placedPart2 in this.buildGrid.parts)
                {
                    bool flag = placedPart2.partIcon.name != "Inactive";
                    if (flag)
                    {
                        foreach (PartData.AttachmentSurface surfaceB in placedPart2.partData.attachmentSurfaces)
                        {
                            num += Mathf.Max(0f, PlacedPart.SurfacesConnect(placedPart, surfaceA, placedPart2, surfaceB));
                        }
                    }
                }
            }
            return(num);
        }
Exemplo n.º 20
0
        public static float SurfacesConnect(PlacedPart partA, PartData.AttachmentSurface surfaceA, PlacedPart partB, PartData.AttachmentSurface surfaceB)
        {
            bool flag  = Mathf.Abs((surfaceA.size * partA.orientation).x) > 0.1f;
            bool flag2 = Mathf.Abs((surfaceB.size * partB.orientation).x) > 0.1f;

            if (flag != flag2)
            {
                return(0f);
            }
            Vector2 worldPosition  = partA.GetWorldPosition(surfaceA.start);
            Vector2 worldPosition2 = partB.GetWorldPosition(surfaceB.start);

            if ((!flag) ? (Mathf.Abs(worldPosition.x - worldPosition2.x) > 0.1f) : (Mathf.Abs(worldPosition.y - worldPosition2.y) > 0.1f))
            {
                return(0f);
            }
            Vector2 worldPosition3 = partA.GetWorldPosition(surfaceA.start + surfaceA.size);
            Vector2 worldPosition4 = partB.GetWorldPosition(surfaceB.start + surfaceB.size);

            return((!flag) ? Utility.Overlap(worldPosition.y, worldPosition3.y, worldPosition2.y, worldPosition4.y) : Utility.Overlap(worldPosition.x, worldPosition3.x, worldPosition2.x, worldPosition4.x));
        }
Exemplo n.º 21
0
        public void ClampToLimits(PlacedPart part)
        {
            Vector2 zero  = Vector2.zero;
            Vector2 zero2 = Vector2.zero;

            PartData.Area[] areas = part.partData.areas;
            for (int i = 0; i < areas.Length; i++)
            {
                PartData.Area area    = areas[i];
                Vector2       vector  = part.position + area.start * part.orientation;
                Vector2       vector2 = part.position + (area.start + area.size) * part.orientation;
                zero = new Vector2(Mathf.Max(new float[]
                {
                    zero.x,
                    vector.x,
                    vector2.x
                }), Mathf.Max(new float[]
                {
                    zero.y,
                    vector.y,
                    vector2.y
                }));
                zero2 = new Vector2(Mathf.Min(new float[]
                {
                    zero2.x,
                    vector.x,
                    vector2.x
                }), Mathf.Min(new float[]
                {
                    zero2.y,
                    vector.y,
                    vector2.y
                }));
            }
            part.position -= new Vector2(Mathf.Min(0f, zero2.x), Mathf.Min(0f, zero2.y)) + new Vector2(Mathf.Max(0f, zero.x - this.width), Mathf.Max(0f, zero.y - this.height));
        }
Exemplo n.º 22
0
 public void RemovePart(PlacedPart partToRemove)
 {
     if (partToRemove.partIcon != null)
     {
         UnityEngine.Object.Destroy(partToRemove.partIcon.gameObject);
     }
     this.parts.Remove(partToRemove);
     this.inactiveParts.Remove(partToRemove);
     this.UpdateInactive();
     foreach (PartData.AttachmentSurface surfaceA in partToRemove.partData.attachmentSurfaces)
     {
         foreach (PlacedPart placedPart in this.parts)
         {
             foreach (PartData.AttachmentSurface surfaceB in placedPart.partData.attachmentSurfaces)
             {
                 if (PlacedPart.SurfacesConnect(partToRemove, surfaceA, placedPart, surfaceB) > 0f)
                 {
                     placedPart.UpdateConnected(this.parts);
                     break;
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
        public static PlacedPart PointCastParts(Vector2 pointPositionLocal, List <PlacedPart> castParts)
        {
            PlacedPart placedPart = null;

            for (int i = 0; i < castParts.Count; i++)
            {
                if (PlacedPart.IsInside(pointPositionLocal, castParts[i], 0f) && (placedPart == null || castParts[i].partData.depth >= placedPart.partData.depth))
                {
                    placedPart = castParts[i];
                }
            }
            if (placedPart != null)
            {
                return(placedPart);
            }
            for (int j = 0; j < castParts.Count; j++)
            {
                if (PlacedPart.IsInside(pointPositionLocal, castParts[j], 0.2f) && (placedPart == null || castParts[j].partData.depth >= placedPart.partData.depth))
                {
                    placedPart = castParts[j];
                }
            }
            return(placedPart);
        }
Exemplo n.º 24
0
                public PlacedPartSave(PlacedPart part)
                {
                    this.partName    = part.partData.name;
                    this.position    = part.position;
                    this.orientation = part.orientation;
                    this.GUID        = part.partData.GUID.ToString();

                    //Tags formatting for save
                    StringBuilder stringBuilder = new StringBuilder();

                    foreach (string text in part.partData.tags.Keys)
                    {
                        stringBuilder.Append(string.Concat(new string[]
                        {
                            part.partData.tags[text].GetType().AssemblyQualifiedName,
                            "#",
                            text,
                            "#",
                            JsonUtility.ToJson(part.partData.tags[text]),
                            "|"
                        }));
                    }
                    this.tagsString = stringBuilder.ToString();
                }
Exemplo n.º 25
0
 public PlacedPartSave(PlacedPart part)
 {
     this.partName    = part.partData.name;
     this.position    = part.position;
     this.orientation = part.orientation;
 }
Exemplo n.º 26
0
 public HoldingPart(Vector2 holdingOffset, PlacedPart part)
 {
     this.holdingOffset = holdingOffset;
     this.part          = part;
 }