protected override Vector3 GetOffset(ThingStatus status)
        {
            var destination = GetDestinationForThing(status.Thing);

            var progress = (float)status.Counter / BeltSpeed;

            // Are we going under or getting out ?
            if (ThingOrigin == (parent.Position - parent.Rotation.FacingCell))
            {
                if (progress < 0.5)
                {
                    var myDir = parent.Position - ThingOrigin;
                    return(myDir.ToVector3() * (progress - 0.5f));
                }
                else
                {
                    return(parent.Position.ToVector3());
                }
            }
            else
            {
                if (progress < 0.5)
                {
                    return(parent.Position.ToVector3());
                }
                else
                {
                    var myDir = destination - parent.Position;
                    return(myDir.ToVector3() * (progress - 0.5f));
                }
            }
        }
Esempio n. 2
0
        protected override Vector3 GetOffset(ThingStatus status)
        {
            var     destination = GetDestinationForThing(status.Thing);
            IntVec3 direction;
            IntVec3 midDirection;

            if (ThingOrigin != IntVec3.Invalid && !this.IsReceiver())
            {
                direction    = destination - ThingOrigin;
                midDirection = parent.Position + parent.Rotation.FacingCell - ThingOrigin;
            }
            else
            {
                if (!this.IsReceiver())
                {
                    direction    = new IntVec3(3 * parent.Rotation.FacingCell.x, parent.Rotation.FacingCell.y, 3 * parent.Rotation.FacingCell.z);
                    midDirection = parent.Rotation.FacingCell;
                }
                else
                {
                    direction    = parent.Rotation.FacingCell;
                    midDirection = parent.Rotation.FacingCell;                     // Should never be used in principle ...
                }
            }
            var progress = (float)status.Counter / BeltSpeed;

            // In case we use the teleporter
            if (this.IsReceiver())
            {
                var myDir = direction.ToVector3();
                return(myDir * progress * 0.5f);
            }
            if (progress < 0.5)
            {
                // Slew item to teleportation pad
                var midDir         = midDirection.ToVector3();
                var midDirOff      = new Vector3(0.5f * midDir.normalized.x, 0.0f, 0.5f * midDir.normalized.z);
                var midDirCorr     = midDir.normalized + midDirOff;
                var midScaleFactor = progress / 0.5f;
                return((midDirCorr * midScaleFactor) - midDirOff);
            }

            // Start the teleportation
            var randomNumber = Random.Range(0.0f, 1.0f);

            if (randomNumber > 2 * (progress - 0.5f))
            {
                var finDira = midDirection.ToVector3();
                finDira.Normalize();
                return(finDira);
            }
            var finDir     = direction.ToVector3();
            var finDirNorm = direction.ToVector3();

            finDirNorm.Normalize();             // Can't normalize, or it doesn't go anywhere ... !
            return(finDir - finDirNorm);
        }
Esempio n. 3
0
        protected static void DrawGUIOverlay([NotNull] ThingStatus status, Vector3 drawPos)
        {
            if (Find.CameraMap.CurrentZoom != CameraZoomRange.Closest)
            {
                return;
            }
            drawPos.z -= 0.4f;

            var screenPos = Find.CameraMap.camera.WorldToScreenPoint(drawPos);

            screenPos.y = Screen.height - screenPos.y;

            GenWorldUI.DrawThingLabel(new Vector2(screenPos.x, screenPos.y), GenString.ToStringCached(status.Thing.stackCount),
                                      new Color(1f, 1f, 1f, 0.75f));
        }
Esempio n. 4
0
        protected virtual Vector3 GetOffset([NotNull] ThingStatus status)
        {
            var destination = GetDestinationForThing(status.Thing);

            IntVec3 direction;

            if (ThingOrigin != IntVec3.Invalid)
            {
                direction = destination - ThingOrigin;
            }
            else
            {
                direction = parent.Rotation.FacingCell;
            }

            var progress = (float)status.Counter / BeltSpeed;

            if (Math.Abs(direction.x) == 1 && Math.Abs(direction.z) == 1 && ThingOrigin != IntVec3.Invalid)
            {
                // Diagonal movement
                var incoming = (parent.Position - ThingOrigin).ToVector3();
                var outgoing = (destination - parent.Position).ToVector3();

                // Now adjust the vectors.
                // Both need to be half the length so they only reach the edge of out square

                // The incoming vector also needs to be negated as it points in the wrong direction

                incoming = (-incoming) / 2;
                outgoing = outgoing / 2;

                var angle = progress * Mathf.PI / 2;

                var cos = Mathf.Cos(angle);
                var sin = Mathf.Sin(angle);

                return(incoming * (1 - sin) + outgoing * (1 - cos));
            }

            var dir = direction.ToVector3();

            dir.Normalize();

            var scaleFactor = progress - .5f;

            return(dir * scaleFactor);
        }
        protected override Vector3 GetOffset( ThingStatus status )
        {
            IntVec3 midDirection;

            if( ThingOrigin != IntVec3.Invalid ){
                midDirection = parent.Position + parent.Rotation.FacingCell - ThingOrigin;
            } else{
                midDirection = parent.Rotation.FacingCell;
            }

            float progress = 0.5f;
            if( CurrentState == TeleportState.Default ){
                progress = ( float )status.Counter / BeltSpeed;
                // No further than the middle of the pad
                if( progress > 0.5f )
                    progress = 0.5f;
            }

            var mid = midDirection.ToVector3();

            return GetRotationOffset() + mid.normalized * ( progress - 0.5f );
        }
Esempio n. 6
0
        protected override Vector3 GetOffset(ThingStatus status)
        {
            var destination = GetDestinationForThing (status.Thing);

            var progress = (float)status.Counter / A2BData.BeltSpeed.TicksToMove;

            // Are we going under or getting out ?
            if (ThingOrigin == (parent.Position - parent.Rotation.FacingCell))
            {
                if (progress < 0.5)
                {
                    var myDir = parent.Position - ThingOrigin;
                    return myDir.ToVector3()*(progress-0.5f);
                }
                else
                {
                    return parent.Position.ToVector3();
                }
            }
            else
            {

                if (progress < 0.5)
                {
                    return parent.Position.ToVector3();
                }
                else
                {
                    var myDir = destination - parent.Position;
                    return myDir.ToVector3()*(progress-0.5f);
                }

            }
        }
        protected override Vector3 GetOffset(ThingStatus status)
        {
            var direction = parent.Rotation.FacingCell;
            var progress = (float) status.Counter / A2BData.BeltSpeed.TicksToMove;

            // Comes in at the middle of the pad
            if( progress < 0.5f )
                progress = 0.5f;

            return GetRotationOffset() + direction.ToVector3() * ( progress - 0.5f );
        }
Esempio n. 8
0
        protected override Vector3 GetOffset(ThingStatus status)
        {
            var destination = GetDestinationForThing(status.Thing);
            IntVec3 direction;
            IntVec3 midDirection;
            if (ThingOrigin != IntVec3.Invalid && !this.IsReceiver())
            {
                direction = destination - ThingOrigin;
                midDirection = parent.Position + parent.Rotation.FacingCell - ThingOrigin;
            }
            else
            {
                if (!this.IsReceiver())
                {
                    direction = new IntVec3(3 * parent.Rotation.FacingCell.x, parent.Rotation.FacingCell.y, 3 * parent.Rotation.FacingCell.z);
                    midDirection = parent.Rotation.FacingCell;
                }
                else
                {
                    direction = parent.Rotation.FacingCell;
                    midDirection = parent.Rotation.FacingCell; // Should never be used in principle ...
                }
            }
            var progress = (float) status.Counter / BeltSpeed;
            // In case we use the teleporter
            if (this.IsReceiver())
            {
                var myDir = direction.ToVector3();
                return myDir * progress * 0.5f;
            }
            if (progress < 0.5)
            {
                // Slew item to teleportation pad
                var midDir = midDirection.ToVector3();
                var midDirOff = new Vector3(0.5f * midDir.normalized.x, 0.0f, 0.5f * midDir.normalized.z);
                var midDirCorr = midDir.normalized + midDirOff;
                var midScaleFactor = progress / 0.5f;
                return (midDirCorr * midScaleFactor) - midDirOff;
            }

            // Start the teleportation
            var randomNumber = Random.Range(0.0f, 1.0f);
            if (randomNumber > 2 * (progress - 0.5f))
            {
                var finDira = midDirection.ToVector3();
                finDira.Normalize();
                return finDira;
            }
            var finDir = direction.ToVector3();
            var finDirNorm = direction.ToVector3();
            finDirNorm.Normalize(); // Can't normalize, or it doesn't go anywhere ... !
            return (finDir - finDirNorm);
        }