Exemple #1
0
        public void CollisionDetectedWithCorrection(ICutlassCollidable collisionTarget, Vector2 normal, float distance)
        {
            //Check for jumping through top-only collisions, or level-transition zones.
            if ((collisionTarget.Side == CollisionSide.Top && normal.Y == -1 && _IsJumpingDown) ||
                collisionTarget is LevelTransition)
            {
                return;
            }

            //get the separation and penetration separately, this is to stop penetration
            //from causing the obejcts to ping apart
            float separation  = Math.Max(distance, 0.0f);
            float penetration = Math.Min(distance, 0.0f);

            //get relative normal velocity so object will stop exactly on surface.
            float relativeNormalVelocity = 0.0f;

            relativeNormalVelocity = VectorUtilities.DotProduct(Velocity, normal);

            if (relativeNormalVelocity < 0)
            {
                //remove normal velocity
                Velocity -= normal * relativeNormalVelocity;
            }

            //is this ground?
            if (normal.Y < 0.0f)
            {
                _WasOnGround = true;
                //StandingOn.Add(contact.B);
            }
        }
 protected override void OnDrag(MouseDevice mouseDevice, double zoom)
 {
     if (this.IsActive)
     {
         PathGeometryEditor pathGeometryEditor = this.BeginEditing();
         PathFigureEditor   pathFigureEditor   = new PathFigureEditor(this.PathEditContext.GetPathFigure(this.Path));
         int figureIndex       = this.PathEditContext.FigureIndex;
         int partIndex         = this.PathEditContext.PartIndex;
         int ofUpstreamSegment = pathFigureEditor.GetFirstIndexOfUpstreamSegment(partIndex);
         if (!this.hasDragged)
         {
             Point point1 = pathFigureEditor.GetPoint(ofUpstreamSegment);
             Point point2 = pathFigureEditor.GetPoint(partIndex);
             if (VectorUtilities.ArePathPointsVeryClose(point2, pathFigureEditor.GetPoint(ofUpstreamSegment + 2)) && VectorUtilities.ArePathPointsVeryClose(point1, pathFigureEditor.GetPoint(ofUpstreamSegment + 1)))
             {
                 pathGeometryEditor.SetPoint(figureIndex, ofUpstreamSegment + 1, VectorUtilities.WeightedAverage(point1, point2, 1.0 / 3.0));
                 pathGeometryEditor.SetPoint(figureIndex, ofUpstreamSegment + 2, VectorUtilities.WeightedAverage(point1, point2, 2.0 / 3.0));
                 this.initialFirstCubicHandle  = pathFigureEditor.GetPoint(ofUpstreamSegment + 1);
                 this.initialSecondCubicHandle = pathFigureEditor.GetPoint(ofUpstreamSegment + 2);
             }
             this.hasDragged = true;
         }
         Vector correspondingVector = ElementUtilities.GetCorrespondingVector((this.GetPointInViewRootCoordinates(mouseDevice, false) - this.initialPointerPosition) * this.damping, this.geometryToDocument, this.IsShiftDown ? this.AxisConstraint : (AxisConstraint)null);
         Vector vector1             = correspondingVector * this.firstHandleCoef;
         Vector vector2             = correspondingVector * this.secondHandleCoef;
         pathGeometryEditor.SetPoint(figureIndex, ofUpstreamSegment + 1, this.initialFirstCubicHandle + vector1);
         pathGeometryEditor.SetPoint(figureIndex, ofUpstreamSegment + 2, this.initialSecondCubicHandle + vector2);
     }
     base.OnDrag(mouseDevice, zoom);
 }
Exemple #3
0
    public void FractureBullet(Vector3 impactPoint, Vector3 impactNormal, bool isActiveHardware = true)
    {
        int   numberOfProjectiles = isActiveHardware ? ActiveNumberOfProjectiles : PassiveNumberOfProjectiles;
        float arcOfFire           = isActiveHardware ? ActiveArcOfFire : PassiveArcOfFire;
        float projectileDamage    = isActiveHardware ? ActiveProjectileDamage : PassiveProjectileDamage;
        float projectileSpeed     = isActiveHardware ? ActiveProjectileSpeed : PassiveProjectileSpeed;

        int projectilesSpawned = 0;

        while (projectilesSpawned < numberOfProjectiles)
        {
            GameObject newBullet = Instantiate(GameManager.BulletPrefab, impactPoint, Quaternion.identity, GameManager.BulletsParent.transform);

            float   angleAdjustment  = Random.Range(-arcOfFire, arcOfFire);
            Vector3 updatedDirection = VectorUtilities.RotatePointAroundPivot(impactNormal + impactPoint, impactPoint, angleAdjustment);

            BulletController bulletController = newBullet.GetComponent <BulletController>();
            bulletController.InitializeValues(projectileDamage, updatedDirection, transform, null, projectileSpeed);
            bulletController.SetFriendly();

            if (isActiveHardware)
            {
                gear.ApplyPassiveHardware(typeof(FractureHardware), newBullet);
            }

            projectilesSpawned++;
        }
    }
Exemple #4
0
    void ApplyArcNoiseAndLaunch(BulletController bullet, Vector3 fireDirection)
    {
        float   arcNoise     = Random.Range(-arcRange, arcRange);
        Vector3 newDirection = VectorUtilities.RotatePointAroundPivot(fireDirection, Vector3.zero, arcNoise);

        bullet.Launch(newDirection);
    }
        private void MoveToPosition(Vector3 position)
        {
            var targetDirection = VectorUtilities.Direction(transform.position, position);

            var angleDirection = AngleUtilities.AngleDirection(transform.forward, targetDirection, transform.up);

            var isBehind = AngleUtilities.AngleIsBehind(transform.forward, targetDirection);

            if (isBehind && angleDirection == 0)
            {
                _moveComponent.MoveBack(Time.fixedDeltaTime);
                return;
            }

            _moveComponent.MoveForward(Time.fixedDeltaTime);

            switch (angleDirection)
            {
            case -1:
                _moveComponent.TurnLeft(Time.fixedDeltaTime);
                break;

            case 1:
                _moveComponent.TurnRight(Time.fixedDeltaTime);
                break;

            case 0:
                break;
            }
        }
    public void tileGUIClicked(Ray mousePositionRay)
    {
        Vector2 worldClickPosition = mousePositionRay.origin;        //this assumes that we keep the scene window camera to orthigraphic/2D
        //Debug.Log("left click at world coords: " + worldClickPosition.ToString());

        Vector2 tileSpawnCoords = VectorUtilities.FloorVectorDataToInts(worldClickPosition + new Vector2(0.5f, 0.5f));        // we add 0.5 to account for the fact that the tile object's coords line up with the center of the sprite

        //Debug.Log("TileSpawnCoords: " + tileSpawnCoords);

        if (tiles.ContainsKey(tileSpawnCoords))           //regardless if we are trying to remove a tile or we are setting it to something else if a tile exists at the coords in question it needs to be destroyed
        {
            GameObject tile = tiles[tileSpawnCoords];
            tiles.Remove(tileSpawnCoords);
            GameObject.DestroyImmediate(tile);
        }

        switch (placingMode)          //creates a new gameobject at the correct location using the apropriate prefab and either adds it to the dictionary with the key being its location or overwrites the gameobject already at said location
        {
        case TilePlacingMode.Floor:
            tiles.Add(tileSpawnCoords, (GameObject)Instantiate(floorTilePrefab, tileSpawnCoords, Quaternion.identity, this.transform));
            break;

        case TilePlacingMode.Wall:
            tiles.Add(tileSpawnCoords, (GameObject)Instantiate(wallTilePrefab, tileSpawnCoords, Quaternion.identity, this.transform));
            break;
        }
    }
Exemple #7
0
        private bool ShouldEnforceSmoothness(PathTangentAdorner pathTangentAdorner)
        {
            int              partIndex        = pathTangentAdorner.PartIndex;
            PathEditContext  pathEditContext  = new PathEditContext(pathTangentAdorner.FigureIndex, partIndex);
            PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditContext.GetPathFigure(this.pathEditorTarget.PathGeometry));
            Point            point1           = pathFigureEditor.GetPoint(pathEditContext.PartIndex);
            bool             flag             = false;

            if (pathFigureEditor.IsFirstCubicBezierHandle(partIndex))
            {
                if (pathFigureEditor.GetPointKind(partIndex - 1) == PathPointKind.Cubic)
                {
                    Point point2 = pathFigureEditor.GetPoint(partIndex - 1);
                    Point point3 = pathFigureEditor.GetPoint(partIndex - 2);
                    flag = VectorUtilities.HaveOppositeDirections(point1 - point2, point3 - point2);
                }
            }
            else if (pathFigureEditor.IsIndexValid(partIndex + 4) && pathFigureEditor.GetPointKind(partIndex + 4) == PathPointKind.Cubic)
            {
                Point point2 = pathFigureEditor.GetPoint(partIndex + 1);
                Point point3 = pathFigureEditor.GetPoint(partIndex + 2);
                flag = VectorUtilities.HaveOppositeDirections(point1 - point2, point3 - point2);
            }
            return(flag);
        }
    public static Vector3 GetOrthogonalVector(Vector3 vCenter, Vector3 vPoint)
    {
        Vector3 vector   = vCenter - vPoint;
        double  distance = VectorUtilities.GetDistance(vCenter, vPoint);

        return(vector / (float)distance);
    }
        /// <summary>
        /// Calculates the output derivative with respect to the <see cref="ICostFunction"/> of the optimizer.
        /// </summary>
        /// <param name="predictions">The predictions.</param>
        /// <param name="oneHots">The one hot values.</param>
        /// <returns>The derivatives.</returns>
        public virtual double[][] CalculateOutputDerivative(double[][] predictions, int[] oneHots)
        {
            int count  = predictions.Length;
            int length = predictions[0].Length;

            double[][] gradient = VectorUtilities.CreateMatrix(count, length);

            for (var i = 0; i < count; i++)
            {
                gradient[i] = CostFunction.Derivative(predictions[i], oneHots[i].OneHot(length));

                if (PipelineSettings.Instance.UseGradientClipping)
                {
                    const double threshold = 2.5;

                    double l2Norm = MathUtilities.L2Norm(gradient[i]);

                    if (l2Norm > threshold)
                    {
                        for (var j = 0; j < length; j++)
                        {
                            gradient[i][j] = gradient[i][j] * threshold / l2Norm;
                        }
                    }
                }
            }

            return(gradient);
        }
    public void updateModelScale(float width, float height)
    {
        float boundsSize;

        if (rootObject.GetComponent <MeshFilter>() != null) //If it has a mesh filter
        {
            boundsSize = VectorUtilities.VectorMax(rootObject.GetComponent <MeshFilter>().mesh.bounds.size) * 100;
        }
        else
        {
            boundsSize = VectorUtilities.VectorMax(rootObject.GetComponentInChildren <SkinnedMeshRenderer>().sharedMesh.bounds.size) * 80;
        }

        float frameSize = Mathf.Min(height, width);
        float scale     = frameSize / boundsSize;

        rootObject.transform.localScale = Vector3.one * (scale * 40);

        //Add exceptions for the grass
        if (this.id == 100)
        {
            //Scale it on the Y axis by a factor of 10
            Vector3 scaleAmount = new Vector3(rootObject.transform.localScale.x, rootObject.transform.localScale.y * 10, rootObject.transform.localScale.z);
            rootObject.transform.localScale = scaleAmount;
        }
    }
        protected override void OnBegin(PathEditContext pathEditContext, MouseDevice mouseDevice)
        {
            this.View.ViewModel.PathPartSelectionSet.SetSelection((PathPart) new PathPoint((SceneElement)this.PathEditorTarget.EditingElement, this.PathEditorTarget.PathEditMode, pathEditContext.FigureIndex, pathEditContext.PartIndex));
            this.geometryToDocument = this.EditingElementTransformToRoot;
            int figureIndex = pathEditContext.FigureIndex;
            int num         = pathEditContext.PartIndex;
            PathFigureEditor pathFigureEditor = new PathFigureEditor(pathEditContext.GetPathFigure(this.Path));
            Point            point            = pathFigureEditor.GetPoint(num);
            int downstreamSegment             = pathFigureEditor.GetLastIndexOfDownstreamSegment(num);

            if (pathFigureEditor.GetPointKind(num) != PathPointKind.Cubic && pathFigureEditor.GetPointKind(num) != PathPointKind.Start || pathFigureEditor.GetPointKind(downstreamSegment) != PathPointKind.Cubic)
            {
                PathGeometryEditor pathGeometryEditor = this.BeginEditing();
                num = this.PromoteAdjacentSegments(pathEditContext);
                pathFigureEditor     = new PathFigureEditor(pathGeometryEditor.PathGeometry.Figures[figureIndex]);
                this.PathEditContext = new PathEditContext(figureIndex, num);
                this.View.ViewModel.PathPartSelectionSet.SetSelection((PathPart) new PathPoint((SceneElement)this.PathEditorTarget.EditingElement, this.PathEditorTarget.PathEditMode, this.PathEditContext.FigureIndex, this.PathEditContext.PartIndex));
            }
            if (this.zeroTangents)
            {
                if ((num > 0 || PathFigureUtilities.IsClosed(pathFigureEditor.PathFigure)) && !VectorUtilities.ArePathPointsVeryClose(pathFigureEditor.GetPoint(num), pathFigureEditor.GetPoint(num - 1)))
                {
                    this.BeginEditing().SetPoint(figureIndex, num - 1, point);
                }
                if (pathFigureEditor.GetLastIndexOfDownstreamSegment(num) != num && !VectorUtilities.ArePathPointsVeryClose(pathFigureEditor.GetPoint(num), pathFigureEditor.GetPoint(num + 1)))
                {
                    this.BeginEditing().SetPoint(figureIndex, num + 1, point);
                }
                if (num == PathFigureUtilities.PointCount(pathFigureEditor.PathFigure) - 1 && PathFigureUtilities.IsOpen(pathFigureEditor.PathFigure))
                {
                    this.LastTangent = new Vector(0.0, 0.0);
                }
            }
            base.OnBegin(pathEditContext, mouseDevice);
        }
        public static Vector3Int[] Random(this Vector3Int[] v1, int number)
        {
            if (v1.Length == number)
            {
                return((Vector3Int[])v1.Clone()); //(Vector3Int[])v1.Clone() since passing arrays using the same Object pointer into methods but with new this link is broken
            }
            if (v1.IsValidIndex(number - 1))
            {
                Vector3Int[] randomArray = new Vector3Int[number];
                for (int i = 0; i < number; i++)
                {
                    if (i == 0)
                    {
                        randomArray[i] = v1[v1.RandomIndex()];
                    }
                    else
                    {
                        randomArray[i] = VectorUtilities.GetDifferent(v1, randomArray, i);
                    }
                }

                return(randomArray);
            }

            return(null);
        }
    public static void Initialize()
    {
        HotkeyComponent.ActionDict.Add("_VFToggle", delegate
        {
            MiscOptions.VehicleFly = !MiscOptions.VehicleFly;
        });
        HotkeyComponent.ActionDict.Add("_ToggleAimbot", delegate
        {
            AimbotOptions.Enabled = !AimbotOptions.Enabled;
        });
        HotkeyComponent.ActionDict.Add("_AimbotOnKey", delegate
        {
            AimbotOptions.OnKey = !AimbotOptions.OnKey;
        });
        HotkeyComponent.ActionDict.Add("_ToggleFreecam", delegate
        {
            MiscOptions.Freecam = !MiscOptions.Freecam;
        });
        HotkeyComponent.ActionDict.Add("_PanicButton", delegate
        {
            MiscOptions.PanicMode = !MiscOptions.PanicMode;
            bool panicMode        = MiscOptions.PanicMode;
            if (panicMode)
            {
                PlayerCoroutines.DisableAllVisuals();
            }
            else
            {
                PlayerCoroutines.EnableAllVisuals();
            }
        });
        HotkeyComponent.ActionDict.Add("_SelectPlayer", delegate
        {
            Vector3 position           = OptimizationVariables.MainPlayer.look.aim.position;
            Vector3 forward            = OptimizationVariables.MainPlayer.look.aim.forward;
            bool enablePlayerSelection = RaycastOptions.EnablePlayerSelection;
            if (enablePlayerSelection)
            {
                foreach (GameObject gameObject in RaycastUtilities.Objects)
                {
                    Player component = gameObject.GetComponent <Player>();
                    bool flag        = component != null;
                    if (flag)
                    {
                        bool flag2 = VectorUtilities.GetAngleDelta(position, forward, gameObject.transform.position) < RaycastOptions.SelectedFOV;
                        if (flag2)
                        {
                            RaycastUtilities.TargetedPlayer = component;
                            break;
                        }
                    }
                }
            }
        });

        HotkeyComponent.ActionDict.Add("_InstantDisconnect", delegate
        {
            Provider.disconnect();
        });
    }
    public static IEnumerator CheckVerification(Vector3 LastPos)
    {
        bool flag = Time.realtimeSinceStartup - MiscComponent.LastMovementCheck < 0.8f;

        if (flag)
        {
            yield break;
        }
        MiscComponent.LastMovementCheck = Time.realtimeSinceStartup;
        OptimizationVariables.MainPlayer.transform.position = new Vector3(0f, -1337f, 0f);
        yield return(new WaitForSeconds(3f));

        bool flag2 = VectorUtilities.GetDistance(OptimizationVariables.MainPlayer.transform.position, LastPos) < 10.0;

        if (flag2)
        {
            MiscOptions.NoMovementVerification = false;
        }
        else
        {
            MiscOptions.NoMovementVerification = true;
            OptimizationVariables.MainPlayer.transform.position = LastPos + new Vector3(0f, 5f, 0f);
        }
        yield break;
    }
Exemple #15
0
    // Start is called before the first frame update
    void Start()
    {
        rb2D = GetComponent <Rigidbody2D>();

        rb2D.velocity = VectorUtilities.AngleToVector2(135) * initialVelocity;
        Physics2D.IgnoreLayerCollision(0, 9);
    }
Exemple #16
0
 public static bool operator ==(Matrix4x4 left, in Matrix4x4 right)
 {
     return(VectorUtilities.CompareEqualAll(left._x, right._x) &&
            VectorUtilities.CompareEqualAll(left._y, right._y) &&
            VectorUtilities.CompareEqualAll(left._z, right._z) &&
            VectorUtilities.CompareEqualAll(left._w, right._w));
 }
Exemple #17
0
 protected override bool OnDrag(Point dragStartPosition, Point dragCurrentPosition, bool scrollNow)
 {
     if (!this.IsProjectedInsertionPoint)
     {
         if (VectorUtilities.Distance(this.pointList[this.pointList.Count - 1], dragCurrentPosition) > 1.2 / this.ActiveView.Zoom)
         {
             this.pointList.Add(dragCurrentPosition);
             if (DebugVariables.Instance.EnableRealTimeFitting)
             {
                 this.vpFitter.Add(dragCurrentPosition, 0L);
             }
         }
         DrawingContext dc = this.OpenFeedback();
         if (DebugVariables.Instance.EnableRealTimeFitting)
         {
             this.DrawCurve(dc);
         }
         else
         {
             this.DrawLines(dc);
         }
         this.CloseFeedback();
     }
     return(true);
 }
    public override Vector3 posClamp(RaycastHit hit)
    {
        int yRot = (int)((mainCamera.transform.parent.eulerAngles.y + 225) / 90);

        int[]   flowerGridLoc            = WorldManager.instance.worldPointToFlowerGrid(hit.point);//find what grid the point is in
        float   chunkOverFlower          = (float)WorldManager.instance.chunkWidth / WorldManager.instance.FlowerWidthPerChunk;
        Vector3 flowerCellCenterPosition = VectorUtilities.VectorAdd((VectorUtilities.VectorFloor(hit.point * chunkOverFlower) / chunkOverFlower), (chunkOverFlower * .5f));
        Vector3 distanceFromCenter       = hit.point - flowerCellCenterPosition;

        if (yRot % 2 == 0)
        {
            if (distanceFromCenter.x > 0)
            {
                flowerCellCenterPosition += Vector3.right * 0.5f;
            }
            else
            {
                flowerCellCenterPosition -= Vector3.right * 0.5f;
            }
        }
        else
        {
            if (distanceFromCenter.z > 0)
            {
                flowerCellCenterPosition += Vector3.forward * 0.5f;
            }
            else
            {
                flowerCellCenterPosition -= Vector3.forward * 0.5f;
            }
        }
        flowerCellCenterPosition.y = 0;
        return(flowerCellCenterPosition);
    }
Exemple #19
0
        private Matrix GetTransformMatrix(IViewObject targetVisual, bool includeParentTransforms)
        {
            Matrix matrix = Matrix.Identity;

            if (!this.AdornsMultipleElements)
            {
                IViewObject viewTargetElement = this.PrimaryElement.ViewTargetElement;
                if (viewTargetElement != null && this.ViewModel.DefaultView.IsInArtboard(this.PrimaryElement))
                {
                    matrix = VectorUtilities.GetMatrixFromTransform(this.ViewModel.DefaultView.ComputeTransformToVisual(viewTargetElement, targetVisual));
                }
            }
            else
            {
                if (this.cachedTransform == null)
                {
                    CanonicalDecomposition transformToRootVisual = this.SharedTransformToRootVisual;
                    this.EnsureBounds();
                    Matrix identity = Matrix.Identity;
                    identity.Translate(this.cachedBounds.X, this.cachedBounds.Y);
                    this.cachedTransform = (Transform) new MatrixTransform(identity * transformToRootVisual.Value);
                }
                Matrix    computedTransformToRoot = this.ViewModel.DefaultView.GetComputedTransformToRoot(targetVisual);
                Transform transform = (Transform)this.ViewModel.DefaultView.Artboard.CalculateTransformFromContentToArtboard().Inverse;
                computedTransformToRoot.Append(transform.Value);
                matrix = this.cachedTransform.Value * computedTransformToRoot;
            }
            return(matrix);
        }
Exemple #20
0
        public static RaycastInfo OV_raycast(Ray ray, float range, int mask)
        {
            switch (OV_DamageTool.OVType)
            {
            case OverrideType.Extended:
                return(RaycastUtilities.GenerateOriginalRaycast(ray, MiscOptions.MeleeRangeExtension, mask));

            case OverrideType.PlayerHit:
                for (int i = 0; i < Provider.clients.Count; i++)
                {
                    bool flag  = VectorUtilities.GetDistance(Player.player.transform.position, Provider.clients[i].player.transform.position) > 15.5;
                    bool flag2 = !flag;
                    if (flag2)
                    {
                        RaycastInfo result;
                        RaycastUtilities.GenerateRaycast(out result);
                        return(result);
                    }
                }
                break;

            case OverrideType.SilentAim:
            {
                RaycastInfo raycastInfo;
                return(RaycastUtilities.GenerateRaycast(out raycastInfo) ? raycastInfo : RaycastUtilities.GenerateOriginalRaycast(ray, range, mask));
            }

            case OverrideType.SilentAimMelee:
            {
                RaycastInfo raycastInfo2;
                return(RaycastUtilities.GenerateRaycast(out raycastInfo2) ? raycastInfo2 : RaycastUtilities.GenerateOriginalRaycast(ray, MiscOptions.MeleeRangeExtension, mask));
            }
            }
            return(RaycastUtilities.GenerateOriginalRaycast(ray, range, mask));
        }
Exemple #21
0
    void FireProjectile(Transform currentTarget)
    {
        if (currentTarget != target)
        {
            target          = currentTarget;
            targetRigidbody = target.GetComponent <Rigidbody>();
        }

        if (currentTarget.name != "Manticore")
        {
            Debug.Log(currentTarget.name);
        }

        if (currentTarget.position != GameManager.GetPlayerPosition())
        {
            Debug.Log(currentTarget.position);
        }
        Vector3 targetPosition = currentTarget.GetComponent <Collider>().bounds.center;

        // Lead bullet logic
        float   timeToImpact          = targetPosition.sqrMagnitude / (BulletSpeed * BulletSpeed);
        Vector3 currentTargetVelocity = targetRigidbody.velocity;

        cachedTargetVelocities[currentVelocityCacheIndex] = currentTargetVelocity;
        currentVelocityCacheIndex++;
        if (currentVelocityCacheIndex >= maximumVelocitiesToCache)
        {
            currentVelocityCacheIndex = 0;
        }

        Vector3 cumulativeVelocity = Vector3.zero;

        for (int i = 0; i < maximumVelocitiesToCache; i++)
        {
            cumulativeVelocity += cachedTargetVelocities[i];
        }

        Vector3 averageVelocity = cumulativeVelocity / maximumVelocitiesToCache;

        averageVelocity *= timeToImpact;
        targetPosition  += averageVelocity;

        float baseNoiseAdjustment = Random.Range(-AimNoiseInDegrees, AimNoiseInDegrees);

        targetPosition = VectorUtilities.RotatePointAroundPivot(targetPosition, transform.position, baseNoiseAdjustment);

        float currentTime = Time.time;

        if (currentTime < timeWarmedUp)
        {
            targetPosition = ApplyWarmUpNoiseToPoint(targetPosition, currentTime);
        }

        Quaternion       rotation         = Quaternion.LookRotation(Vector3.up);
        Transform        createdBullet    = Instantiate(Projectile, SpawnPoint.position, rotation, GameManager.BulletsParent.transform);
        BulletController bulletController = createdBullet.GetComponent <BulletController>();

        bulletController.InitializeValues(ProjectileStrength, targetPosition, transform, currentTarget, BulletSpeed);
    }
Exemple #22
0
    public void updateModelScale(float width, float height)
    {
        float boundsSize = VectorUtilities.VectorMax(rootObject.GetComponent <MeshFilter>().mesh.bounds.size) * 100;
        float frameSize  = Mathf.Min(height, width);
        float scale      = frameSize / boundsSize;

        rootObject.transform.localScale = Vector3.one * (scale * 40);
    }
 internal static object MakeZoomPositive(DependencyObject d, object baseValue)
 {
     if (baseValue != null)
     {
         return((object)VectorUtilities.RemoveMirror((Vector)baseValue));
     }
     return(baseValue);
 }
Exemple #24
0
        private Vector CreateRandomVector()
        {
            var x = CreateRandomDouble();
            var y = CreateRandomDouble();
            var z = CreateRandomDouble();

            return(VectorUtilities.NewVector(x, y, z));
        }
Exemple #25
0
        public LineSegment(Vector3 start, Vector3 end)
        {
            this.start = start;
            this.end   = end;

            // No normal supplied, pick arbitrary normal vector:
            this.normal = VectorUtilities.InventNormal(end - start);
        }
Exemple #26
0
 public static Matrix GetComputedTransform(Visual targetVisual, Visual visual)
 {
     if (targetVisual == null || visual == null || (Visual)visual.FindCommonVisualAncestor((DependencyObject)targetVisual) == null)
     {
         return(Matrix.Identity);
     }
     return(VectorUtilities.GetMatrixFromTransform(visual.TransformToVisual(targetVisual)));
 }
Exemple #27
0
        public void StartSim()
        {
            gravityGameObjects = GameObject.FindGameObjectsWithTag("GravityObject");
            vectorUtilities    = new VectorUtilities();

            GenerateGravityObjects();
            started = true;
        }
Exemple #28
0
        public LineSegment(dvec3 start, dvec3 end)
        {
            _start = start;
            _end   = end;

            // No normal supplied, pick arbitrary normal vector:
            _normal = VectorUtilities.InventNormal(end - start);
        }
    public static bool GetTargetObject(GameObject[] Objects, out GameObject Object, out Vector3 Point, double Range)
    {
        double num  = Range + 1f;
        double num2 = 180f;

        Object = null;
        Point  = Vector3.zero;
        Vector3 position = OptimizationVariables.MainPlayer.look.aim.position;
        Vector3 forward  = OptimizationVariables.MainPlayer.look.aim.forward;

        foreach (GameObject gameObject in Objects)
        {
            if (!(gameObject == null))
            {
                Vector3 position2 = gameObject.transform.position;
                Player  component = gameObject.GetComponent <Player>();
                if (!component || (!component.life.isDead && !FriendUtilities.IsFriendly(component) && (!RaycastOptions.NoShootthroughthewalls || RaycastUtilities.NoShootthroughthewalls(gameObject.transform))))
                {
                    Zombie component2 = gameObject.GetComponent <Zombie>();
                    if (!component2 || !component2.isDead)
                    {
                        if (gameObject.GetComponent <RaycastComponent>() == null)
                        {
                            gameObject.AddComponent <RaycastComponent>();
                        }
                        else
                        {
                            double distance = VectorUtilities.GetDistance(position, position2);
                            if (distance <= Range)
                            {
                                if (RaycastOptions.SilentAimUseFOV)
                                {
                                    double angleDelta = VectorUtilities.GetAngleDelta(position, forward, position2);
                                    if (angleDelta > RaycastOptions.SilentAimFOV || angleDelta > num2)
                                    {
                                        goto IL_12A;
                                    }
                                    num2 = angleDelta;
                                }
                                else if (distance > num)
                                {
                                    goto IL_12A;
                                }
                                if (SphereUtilities.GetRaycast(gameObject, position, out Vector3 vector))
                                {
                                    Object = gameObject;
                                    num    = distance;
                                    Point  = vector;
                                }
                            }
                        }
                    }
                }
            }
            IL_12A :;
        }
        return(Object != null);
    }
Exemple #30
0
        /// <summary>
        /// Sets the voxel data for a volume in the world
        /// </summary>
        /// <param name="voxelDataVolume">The new voxel data volume</param>
        /// <param name="originPosition">The world position of the origin where the voxel data should be set</param>
        public void SetVoxelDataCustom(VoxelDataVolume voxelDataVolume, int3 originPosition)
        {
            Bounds worldSpaceQuery = new Bounds();

            worldSpaceQuery.SetMinMax(originPosition.ToVectorInt(), (originPosition + voxelDataVolume.Size - new int3(1, 1, 1)).ToVectorInt());

            int chunkSize = VoxelWorld.WorldSettings.ChunkSize;

            int3 minChunkCoordinate = VectorUtilities.WorldPositionToCoordinate(worldSpaceQuery.min - Vector3Int.one, chunkSize);
            int3 maxChunkCoordinate = VectorUtilities.WorldPositionToCoordinate(worldSpaceQuery.max + Vector3Int.one, chunkSize);

            for (int chunkCoordinateX = minChunkCoordinate.x; chunkCoordinateX <= maxChunkCoordinate.x; chunkCoordinateX++)
            {
                for (int chunkCoordinateY = minChunkCoordinate.y; chunkCoordinateY <= maxChunkCoordinate.y; chunkCoordinateY++)
                {
                    for (int chunkCoordinateZ = minChunkCoordinate.z; chunkCoordinateZ <= maxChunkCoordinate.z; chunkCoordinateZ++)
                    {
                        int3 chunkCoordinate = new int3(chunkCoordinateX, chunkCoordinateY, chunkCoordinateZ);
                        if (!TryGetVoxelDataChunk(chunkCoordinate, out VoxelDataVolume voxelDataChunk))
                        {
                            continue;
                        }

                        Vector3 chunkBoundsSize       = new Vector3(voxelDataChunk.Width - 1, voxelDataChunk.Height - 1, voxelDataChunk.Depth - 1);
                        int3    chunkWorldSpaceOrigin = chunkCoordinate * chunkSize;

                        Bounds chunkWorldSpaceBounds = new Bounds();
                        chunkWorldSpaceBounds.SetMinMax(chunkWorldSpaceOrigin.ToVectorInt(), chunkWorldSpaceOrigin.ToVectorInt() + chunkBoundsSize);

                        Bounds intersectionVolume    = IntersectionUtilities.GetIntersectionVolume(worldSpaceQuery, chunkWorldSpaceBounds);
                        int3   intersectionVolumeMin = intersectionVolume.min.ToInt3();
                        int3   intersectionVolumeMax = intersectionVolume.max.ToInt3();

                        for (int voxelDataWorldPositionX = intersectionVolumeMin.x; voxelDataWorldPositionX <= intersectionVolumeMax.x; voxelDataWorldPositionX++)
                        {
                            for (int voxelDataWorldPositionY = intersectionVolumeMin.y; voxelDataWorldPositionY <= intersectionVolumeMax.y; voxelDataWorldPositionY++)
                            {
                                for (int voxelDataWorldPositionZ = intersectionVolumeMin.z; voxelDataWorldPositionZ <= intersectionVolumeMax.z; voxelDataWorldPositionZ++)
                                {
                                    int3 voxelDataWorldPosition = new int3(voxelDataWorldPositionX, voxelDataWorldPositionY, voxelDataWorldPositionZ);

                                    if (voxelDataChunk.TryGetVoxelData(voxelDataWorldPosition - worldSpaceQuery.min.ToInt3(), out float voxelData))
                                    {
                                        voxelDataChunk.SetVoxelData(voxelData, voxelDataWorldPosition - chunkWorldSpaceOrigin);
                                    }
                                }
                            }
                        }

                        if (VoxelWorld.ChunkStore.TryGetChunkAtCoordinate(chunkCoordinate, out Chunk chunk))
                        {
                            chunk.HasChanges = true;
                        }
                    }
                }
            }
        }