Пример #1
0
 public override void ComputeLastPos(RegexpBuilder bld)
 {
     Left.ComputeLastPos(bld);
     Right.ComputeLastPos(bld);
     LastPos = (BitArray)Left.FirstPos.Clone();
     LastPos.Or(Right.LastPos);
 }
Пример #2
0
 public override void ComputeLastPos(RegexpBuilder bld)
 {
     Left.ComputeLastPos(bld);
     Right.ComputeLastPos(bld);
     LastPos = (BitArray)Right.LastPos.Clone();
     if (Right.Nullable)
     {
         LastPos.Or(Left.LastPos);
     }
 }
Пример #3
0
        //Removed minimum collision distance
        private bool CheckForCollisionBetween()
        {
            var lastPosIV3 = LastPos.ToIntVec3();
            var newPosIV3  = ExactPosition.ToIntVec3();

            List <Thing> list = base.Map.listerThings.ThingsInGroup(ThingRequestGroup.ProjectileInterceptor);

            for (int i = 0; i < list.Count; i++)
            {
                if (CheckIntercept(list[i], list[i].TryGetComp <CompProjectileInterceptor>()))
                {
                    this.Destroy(DestroyMode.Vanish);
                    return(true);
                }
            }

            #region Sanity checks
            if (ticksToImpact == 0 || def.projectile.flyOverhead)
            {
                return(false);
            }

            if (!lastPosIV3.InBounds(Map) || !newPosIV3.InBounds(Map))
            {
                return(false);
            }

            if (Controller.settings.DebugDrawInterceptChecks)
            {
                Map.debugDrawer.FlashLine(lastPosIV3, newPosIV3);
            }
            #endregion

            // Iterate through all cells between the last and the new position
            // INCLUDING[!!!] THE LAST AND NEW POSITIONS!
            var cells = GenSight.PointsOnLineOfSight(lastPosIV3, newPosIV3).Union(new[] { lastPosIV3, newPosIV3 }).Distinct().OrderBy(x => (x.ToVector3Shifted() - LastPos).MagnitudeHorizontalSquared());

            //Order cells by distance from the last position
            foreach (var cell in cells)
            {
                if (CheckCellForCollision(cell))
                {
                    return(true);
                }

                if (Controller.settings.DebugDrawInterceptChecks)
                {
                    Map.debugDrawer.FlashCell(cell, 1, "o");
                }
            }

            return(false);
        }
Пример #4
0
        public override void Tick()
        {
            base.Tick();
            if (landed)
            {
                return;
            }
            LastPos = ExactPosition;
            ticksToImpact--;
            if (!ExactPosition.InBounds(Map))
            {
                Position = LastPos.ToIntVec3();
                Destroy();
                return;
            }
            if (CheckForCollisionBetween())
            {
                return;
            }
            Position = ExactPosition.ToIntVec3();
            if (ticksToImpact == 60 && Find.TickManager.CurTimeSpeed == TimeSpeed.Normal &&
                def.projectile.soundImpactAnticipate != null)
            {
                def.projectile.soundImpactAnticipate.PlayOneShot(this);
            }
            //TODO : It appears that the final steps in the arc (past ticksToImpact == 0) don't CheckForCollisionBetween.
            if (ticksToImpact <= 0)
            {
                ImpactSomething();
                return;
            }
            if (ambientSustainer != null)
            {
                ambientSustainer.Maintain();
            }

            if (def.HasModExtension <TrailerProjectileExtension>())
            {
                var trailer = def.GetModExtension <TrailerProjectileExtension>();
                if (trailer != null)
                {
                    if (ticksToImpact % trailer.trailerMoteInterval == 0)
                    {
                        for (int i = 0; i < trailer.motesThrown; i++)
                        {
                            TrailThrower.ThrowSmoke(DrawPos, trailer.trailMoteSize, Map, trailer.trailMoteDef);
                        }
                    }
                }
            }
        }
Пример #5
0
            public override void ComputeFollowPos(RegexpBuilder bld)
            {
                node.ComputeFollowPos(bld);
                FollowPos = node.FollowPos;
                for (int i = 0; i != LastPos.Length; ++i)
                {
                    if (!LastPos.Get(i))
                    {
                        continue;
                    }

                    ByteNode ii = (ByteNode)bld.positions[i];
                    ii.FollowPos.Or(FirstPos);
                }
            }
Пример #6
0
    //Public because there are some moments that need to be saved for different things (like when hitting the ground)
    public void AddCurrentPosition()
    {
        float vel = 0;
        float x   = transform.position.x;
        float y   = transform.position.y;

        //Check if this is your first save
        if (mActions.Count > 0)
        {
            //Don't want to save the same position as last ones
            if (s_Utils.ShortToFloat(s_Utils.FloatToShort(x)) != s_Utils.ShortToFloat(mActions[mActions.Count - 1].GetXPos()) ||
                s_Utils.ShortToFloat(s_Utils.FloatToShort(y)) != s_Utils.ShortToFloat(mActions[mActions.Count - 1].GetYPos()))
            {
                //Final check to make sure time stamp didn't get messed up
                if (mActions[mActions.Count - 1].GetTimeStamp() < s_TimeManager.sTimeStamp)
                {
                    //Get velocity depending on if you have physics
                    if (mPhysics != null)
                    {
                        vel = mPhysics.mMoveVector.y;
                    }

                    //Add the position
                    LastPos temp = new LastPos();
                    temp.Set(s_TimeManager.sTimeStamp, s_Utils.FloatToShort(x), s_Utils.FloatToShort(y), s_Utils.FloatToShort(vel));
                    mActions.Add(temp);
                }
            }
        }
        else
        {
            //Add the first position with no velocity
            LastPos temp = new LastPos();
            temp.Set(s_TimeManager.sTimeStamp, s_Utils.FloatToShort(x), s_Utils.FloatToShort(y), s_Utils.FloatToShort(vel));
            mActions.Add(temp);
        }

        mCurrentFrame = 0;         //Reset it in here, because other things can call this function
    }
Пример #7
0
 public override void Tick()
 {
     base.Tick();
     if (landed)
     {
         return;
     }
     LastPos = ExactPosition;
     ticksToImpact--;
     if (!ExactPosition.InBounds(base.Map))
     {
         Position = LastPos.ToIntVec3();
         Destroy(DestroyMode.Vanish);
         return;
     }
     if (ticksToImpact >= 0 &&
         !def.projectile.flyOverhead &&
         CheckForCollisionBetween())
     {
         return;
     }
     Position = ExactPosition.ToIntVec3();
     if (ticksToImpact == 60 && Find.TickManager.CurTimeSpeed == TimeSpeed.Normal &&
         def.projectile.soundImpactAnticipate != null)
     {
         def.projectile.soundImpactAnticipate.PlayOneShot(this);
     }
     //TODO : It appears that the final steps in the arc (past ticksToImpact == 0) don't CheckForCollisionBetween.
     if (ticksToImpact <= 0)
     {
         ImpactSomething();
         return;
     }
     if (ambientSustainer != null)
     {
         ambientSustainer.Maintain();
     }
 }
Пример #8
0
        //Removed minimum collision distance
        private bool CheckForCollisionBetween()
        {
            var lastPosIV3 = LastPos.ToIntVec3();
            var newPosIV3  = ExactPosition.ToIntVec3();

            #region Sanity checks
            if (!lastPosIV3.InBounds(base.Map) || !newPosIV3.InBounds(base.Map))
            {
                return(false);
            }

            if (DebugViewSettings.drawInterceptChecks)
            {
                Map.debugDrawer.FlashLine(lastPosIV3, newPosIV3);
            }
            #endregion

            // Iterate through all cells between the last and the new position
            // INCLUDING[!!!] THE LAST AND NEW POSITIONS!
            var cells = GenSight.PointsOnLineOfSight(lastPosIV3, newPosIV3).Union(new [] { lastPosIV3, newPosIV3 }).Distinct().OrderBy(x => (x.ToVector3Shifted() - LastPos).MagnitudeHorizontalSquared());

            //Order cells by distance from the last position
            foreach (IntVec3 cell in cells)
            {
                if (CheckCellForCollision(cell))
                {
                    return(true);
                }

                if (DebugViewSettings.drawInterceptChecks)
                {
                    Map.debugDrawer.FlashCell(cell, 1, "o");
                }
            }

            return(false);
        }
Пример #9
0
    bool mWasGrounded = true; //For checking if you were on the ground, but no longer are

    #endregion Fields

    #region Methods

    //Public because there are some moments that need to be saved for different things (like when hitting the ground)
    public void AddCurrentPosition()
    {
        float vel = 0;
        float x = transform.position.x;
        float y = transform.position.y;

        //Check if this is your first save
        if (mActions.Count > 0)
        {
            //Don't want to save the same position as last ones
            if(s_Utils.ShortToFloat(s_Utils.FloatToShort(x)) != s_Utils.ShortToFloat(mActions[mActions.Count-1].GetXPos())
            || s_Utils.ShortToFloat(s_Utils.FloatToShort(y)) != s_Utils.ShortToFloat(mActions[mActions.Count-1].GetYPos()))
            {
                //Final check to make sure time stamp didn't get messed up
                if (mActions[mActions.Count-1].GetTimeStamp() < s_TimeManager.sTimeStamp)
                {
                    //Get velocity depending on if you have physics
                    if (mPhysics != null)
                        vel = mPhysics.mMoveVector.y;

                    //Add the position
                    LastPos temp = new LastPos();
                    temp.Set(s_TimeManager.sTimeStamp, s_Utils.FloatToShort(x), s_Utils.FloatToShort(y), s_Utils.FloatToShort(vel));
                    mActions.Add(temp);
                }
            }
        }
        else
        {
            //Add the first position with no velocity
            LastPos temp = new LastPos();
            temp.Set(s_TimeManager.sTimeStamp, s_Utils.FloatToShort(x), s_Utils.FloatToShort(y), s_Utils.FloatToShort(vel));
            mActions.Add(temp);
        }

        mCurrentFrame = 0; //Reset it in here, because other things can call this function
    }
Пример #10
0
    private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject, LastPos lastPosition, ulong trackingid)
    {
        float minX = float.MaxValue;
        float maxX = float.MinValue;
        float minY = float.MaxValue;
        float maxY = float.MinValue;

        Vector3 spineBasePos = Vector3.zero;
        Vector3 spineMidPos  = Vector3.zero;

        Vector3 shoulderPosLeft  = Vector3.zero;
        Vector3 shoulderPosRight = Vector3.zero;

        float handDeltaLeft  = 0;
        float handDeltaRight = 0;

        for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++)
        {
            Kinect.Joint sourceJoint = body.Joints[jt];
            Kinect.Joint?targetJoint = null;

            if (_BoneMap.ContainsKey(jt))
            {
                targetJoint = body.Joints[_BoneMap[jt]];
            }

            Transform jointObj = bodyObject.transform.Find(jt.ToString());
            jointObj.localPosition = GetVector3FromJoint(sourceJoint);
            shoeOverlays[trackingid].localPosition = GetVector3FromJoint(sourceJoint);

            if (jointObj.localPosition.x > maxX)
            {
                maxX = jointObj.localPosition.x;
            }
            if (jointObj.localPosition.x < minX)
            {
                minX = jointObj.localPosition.x;
            }
            if (jointObj.localPosition.y > maxY)
            {
                maxY = jointObj.localPosition.y;
            }
            if (jointObj.localPosition.y < minY)
            {
                minY = jointObj.localPosition.y;
            }

            if (jt == Kinect.JointType.SpineBase)
            {
                spineBasePos = jointObj.localPosition;
            }
            else if (jt == Kinect.JointType.SpineMid)
            {
                spineMidPos = jointObj.localPosition;
            }
            else if (jt == Kinect.JointType.ShoulderLeft)
            {
                handDeltaLeft = Vector3.Distance(lastPosition.lastLeftHandPos, jointObj.localPosition);
                lastPosition.lastLeftHandPos = jointObj.localPosition;
                shoulderPosLeft = jointObj.localPosition;
            }
            else if (jt == Kinect.JointType.ShoulderRight)
            {
                handDeltaRight = Vector3.Distance(lastPosition.lastRightHandPos, jointObj.localPosition);
                lastPosition.lastRightHandPos = jointObj.localPosition;
                shoulderPosRight = jointObj.localPosition;
            }

            if (showBones)
            {
                LineRenderer lr = jointObj.GetComponent <LineRenderer>();
                if (targetJoint.HasValue)
                {
                    lr.SetPosition(0, jointObj.localPosition);
                    lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value));
                    lr.SetColors(GetColorForState(sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState));
                }
                else
                {
                    lr.enabled = false;
                }
            }
        }

        //print("HAND LEFT DELTA " + handDeltaLeft);
        //print("HAND RIGHT DELTA " + handDeltaRight);

        instancedShoeMats[trackingid].SetFloat("_OffsetMultiplierX", handDeltaLeft * morphMultiplier.x);
        instancedShoeMats[trackingid].SetFloat("_OffsetMultiplierY", handDeltaRight * morphMultiplier.y);

        lastPositions[trackingid] = lastPosition;

        //Calc rotation
        float rotationZ = Mathf.Atan2(shoulderPosRight.y - shoulderPosLeft.y, shoulderPosRight.x - shoulderPosLeft.x) * 180f / Mathf.PI;
        //print(rotationZ);
        var shoeOverlay = shoeOverlays[trackingid];
        var shoePos     = shoeOverlay.transform.localPosition;

        shoeOverlay.transform.localPosition = new Vector3((maxX + minX) / 2f + +offset.x, (maxY + minY) / 2f + offset.y, shoePos.z + offset.z);
        float shoeScaleX = baseScale.x + (maxX - minX) * overlayScaleMultiplier.x;
        float shoeScaleY = baseScale.y + (maxY - minY) * overlayScaleMultiplier.y;

        shoeOverlay.transform.localScale    = new Vector3(shoeScaleX, shoeScaleY, shoeOverlay.transform.localScale.z * overlayScaleMultiplier.z);
        shoeOverlay.transform.localRotation = Quaternion.Euler(0, 0, rotationZ * rotaionMultiplier);
    }