public override void Update(GameTime gameTime) { Position += Speed; Angle += AngularSpeed; Opacity -= OpacityChange; CurrentLife += gameTime.ElapsedGameTime.Milliseconds; }

// Shifts the camera position by a value public void Move(Vector2 amount) { position += amount; ClampPosition(); UpdateCamArea(); center = new Vector2(camArea.X + camArea.Width / 2.0f, camArea.Y + camArea.Height / 2.0f); }

internal static void BeginScrollView(Rect position, Vector2 scrollPosition, Rect viewRect, GUIStyle horizontalScrollbar, GUIStyle verticalScrollbar) { s_ScrollPos = scrollPosition; s_ViewRect = viewRect; s_Position = position; GUIClip.Push(position, new Vector2(Mathf.Round((-scrollPosition.x - viewRect.x) - ((viewRect.width - position.width) * 0.5f)), Mathf.Round((-scrollPosition.y - viewRect.y) - ((viewRect.height - position.height) * 0.5f))), Vector2.zero, false); }

public override void OnEnable() { team = target as Team; teamScroll = Vector2.zero; base.OnEnable(); name = "Team"; }

private void Spawn_Tile(GameObject Select_Tile, Vector2 Position) { GameObject Tile = Instantiate (Select_Tile); Tile.transform.parent = transform; Tile.transform.position = transform.position; Tile.transform.position += (Vector3)Position; }

public static Vector2 GetIntersectionDepth(Rectangle rectA, Rectangle rectB) { // Calculate half sizes. float halfWidthA = rectA.Width / 2.0f; float halfHeightA = rectA.Height / 2.0f; float halfWidthB = rectB.Width / 2.0f; float halfHeightB = rectB.Height / 2.0f; // Calculate centers. Vector2 centerA = new Vector2(rectA.Left + halfWidthA, rectA.Top + halfHeightA); Vector2 centerB = new Vector2(rectB.Left + halfWidthB, rectB.Top + halfHeightB); // Calculate current and minimum-non-intersecting distances between centers. float distanceX = centerA.X - centerB.X; float distanceY = centerA.Y - centerB.Y; float minDistanceX = halfWidthA + halfWidthB; float minDistanceY = halfHeightA + halfHeightB; // If we are not intersecting at all, return (0, 0). if (Math.Abs(distanceX) >= minDistanceX || Math.Abs(distanceY) >= minDistanceY) return Vector2.Zero; // Calculate and return intersection depths. float depthX = distanceX > 0 ? minDistanceX - distanceX : -minDistanceX - distanceX; float depthY = distanceY > 0 ? minDistanceY - distanceY : -minDistanceY - distanceY; return new Vector2(depthX, depthY); }

public static float AngleBetween(Vector2 v1, Vector2 v2) { v1.Normalize(); v2.Normalize(); float Angle = (float)Math.Acos(Vector2.Dot(v1, v2)); return Angle; }

public void m0002cf(ref bool[] p0, ref bool[] p1) { for (int i = 0; i < p0.Length; i++) { this.f00000a[i] = p0[i]; } for (int j = 0; j < p1.Length; j++) { this.f000056[j] = p1[j]; } this.f000030 = Vector2.Zero; if (this.m000017(enum020a.f00006d)) { this.f000030.X = -1f; } else if (this.m000017(enum020a.f00006e)) { this.f000030.X = 1f; } if (this.m000017(enum020a.f000005)) { this.f000030.Y = -1f; } else if (this.m000017(enum020a.f00006c)) { this.f000030.Y = 1f; } }

public struct0207(ref bool[] p0, ref bool[] p1) { this.f00000a = new bool[p0.Length]; this.f000056 = new bool[p1.Length]; this.f000030 = Vector2.Zero; this.m0002cf(ref p0, ref p1); }

public void Transform(Matrix transform) { Vector2[] transformed = new Vector2[_vertices.Length]; Vector2.Transform(_vertices.ToArray(), ref transform, transformed); _transformedvertices.Clear(); _transformedvertices.vertices.InsertRange(0, transformed); }

public void Update() { if (top == 0 && bottom == 0) { if (up) { top = location.Y; bottom = top + columnHeight; } else { bottom = location.Y; top = bottom - columnHeight; } } if (!up && location.Y < bottom) { physics.Velocity = new Vector2(0, LemmingObjectConstants.DOWNELEVATORVELOCITY); } else if (up && location.Y > top) { physics.Velocity = new Vector2(0, LemmingObjectConstants.UPELEVATORVELOCITY); } else { physics.Velocity = Vector2.Zero; } elevatorSprite.Update(); location = physics.Update(location); }

void AddUVs() { Vector2 _00 = new Vector2( 0f, 0f ); Vector2 _10 = new Vector2( 1f, 0f ); Vector2 _01 = new Vector2( 0f, 1f ); Vector2 _11 = new Vector2( 1f, 1f ); uvs = new Vector2[] { // Bottom _11, _01, _00, _10, // Left _11, _01, _00, _10, // Front _11, _01, _00, _10, // Back _11, _01, _00, _10, // Right _11, _01, _00, _10, // Top _11, _01, _00, _10, }; }

public Emitter(Vector2 position, Texture2D sprite, Color color, int size) { this.position = position; this.sprite = sprite; this.color = color; this.size = size; }

public ObjectClass(Texture2D Img) { Image = Img; Position = Vector2.Zero; Center = Vector2.Zero; Rotation = 0.0f; }

public Fruit(World world, Vector2 position, FruitType fruitType) : base(world, position) { this._fruitType = fruitType; switch (fruitType) { case FruitType.Apple: this.Energy = 6; break; case FruitType.Watermelon: this.Energy = 8; break; case FruitType.Pineapple: this.Energy = 10; break; case FruitType.Strawberry: this.Energy = 12; break; case FruitType.Cherries: this.Energy = 14; break; case FruitType.Acorn: this.Energy = 16; break; default: throw new InvalidOperationException(); } string textureName = string.Format("Sprites/Fruit/{0:G}", _fruitType); var a = Animation.StaticAnimation(World, textureName); this.Ap.PlayAnimation(a); }

public static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount) { float X = MathHelper.SmoothStep(value1.X, value2.X, amount); float Y = MathHelper.SmoothStep(value1.Y, value2.Y, amount); return new Vector2(X, Y); }

public static Vector2 PointOnCircle(Vector2 C, float R, float A) { //A = A - 90; float endX = (C.X + (R * ((float)Math.Cos((float)A)))); float endY = (C.Y + (R * ((float)Math.Sin((float)A)))); return new Vector2(endX, endY); }

/// <summary> /// Checks the mouse's position set in the in-game world plane. /// </summary> /// <param name="mousePosition">Mouse's position on screen</param> /// <param name="camera">Camera object</param> /// <param name="device">Graphics device used in rendering</param> /// <returns></returns> public static Vector3 getMouseWorldPosition(Vector2 mousePosition,CameraAndLights camera,GraphicsDevice device) { Vector3 nearsource = new Vector3(mousePosition,0f); Vector3 farsource = new Vector3(mousePosition,CameraAndLights.nearClip); Vector3 nearPoint = device.Viewport.Unproject(nearsource, camera.projectionMatrix, camera.viewMatrix, Matrix.Identity); Vector3 farPoint = device.Viewport.Unproject(farsource, camera.projectionMatrix, camera.viewMatrix, Matrix.Identity); // Create a ray from the near clip plane to the far clip plane. Vector3 direction = farPoint - nearPoint; direction.Normalize(); Ray pickRay = new Ray(nearPoint,direction); Plane floor = new Plane(new Vector3(0f,1f,0f),0f); float denominator = Vector3.Dot(floor.Normal,pickRay.Direction); float numerator = Vector3.Dot(floor.Normal,pickRay.Position) + floor.D; float dist = -(numerator / denominator); Vector3 mouseWorldPos = nearPoint + direction * dist; return mouseWorldPos * new Vector3(1f,0f,1f); }

public void Spawn(ESpaceObjects e, int count, Vector2 start, Vector2 end) { if (count < 1) return; Debug.Log(string.Format("Spawn {0} {1}", count, e.ToString())); var cahce = _cache[(int)e]; for (int i = 0; i < count; i++) { var so = cahce.Pop(); so.OnDestroy += _destroyDelegates[(int)e]; so.OnReward += OnReward; so.transform.position = new Vector2(Random.Range(start.x, end.x), Random.Range(start.y, end.y)); so.Spawn(); if (e == ESpaceObjects.AlienBig || e == ESpaceObjects.AlienShield || e == ESpaceObjects.AlienSmall) { Alien alien = so as Alien; alien.Spawner = this; } LiveObjects.Add(so); } }

public static void Draw(ISpriteBatch sb, Vector2 source, Vector2 dest, Color color) { var dist = Vector2.Distance(source, dest); var angle = GetAngle(source, dest); // Get the length of the segments var segLen = dist / 6; if (segLen < 5.0f) segLen = 5.0f; if (segLen > 25.0f) segLen = 25.0f; // Primary line var tailLen = dist - (segLen / 2); var pDest = source + (new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * tailLen); RenderLine.Draw(sb, source, pDest, color); // Arrow segment 1 var ang1 = angle - MathHelper.PiOver4; var seg1 = dest - (new Vector2((float)Math.Cos(ang1), (float)Math.Sin(ang1)) * segLen); RenderLine.Draw(sb, dest, seg1, color); // Arrow segment 2 var ang2 = angle + MathHelper.PiOver4; var seg2 = dest - (new Vector2((float)Math.Cos(ang2), (float)Math.Sin(ang2)) * segLen); RenderLine.Draw(sb, dest, seg2, color); // Arrow segment 3 RenderLine.Draw(sb, seg1, seg2, color); }

/// <summary> /// Initializes a new instance of the <see cref="UnityGwenRenderer"/> class. /// </summary> /// <param name="target">Unity render target.</param> public UnityGwenRenderer() { whiteTex = new Texture2D(1, 1); whiteTex.SetPixel(0, 0, UnityEngine.Color.white); whiteTex.Apply(); m_ViewScale = Vector2.one; }

public Paddle(ContentManager theContent, string theAssetName, Input theInput, PaddlePosition thePosition) : base(theContent, theAssetName) { SourceRectangle = new Rectangle(0, 0, 1, 1); Scale = new Vector2(10.0f, 100.0f); mColor = Color.SlateBlue; mPaddlePosition = thePosition; switch (thePosition) { case PaddlePosition.Left: { Boundary = new Rectangle(140, 185, 10, 833); break; } case PaddlePosition.Right: { Boundary = new Rectangle(1130, 185, 10, 833); break; } } Position = Center(Boundary); mInput = theInput; }

public C_Maps() { //init stuff here m_mousePosition = Vector2.Zero; m_font1 = null; m_spriteBatch = null; }

public HardBall(IGame game, Vector2 position) : base(game, game.ContentProvider.GetBallSprite(0), position, 5) { Velocity = 2; var target = new Vector2(Game.Random.Next() - Game.Random.Next(), Game.Random.Next() - Game.Random.Next()); MoveTo(target); }

public void setBoundary(Vector2 bottomLeft, Vector2 topRight, float minZoom, float maxZoom) { this.bottomLeft = bottomLeft; this.topRight = topRight; this.minZoom = minZoom; this.maxZoom = maxZoom; }

public void Init(ContentManager content, Vector2 position, string normalTextureName, string hoverTextureName) { m_Normal = content.Load<Texture2D>(normalTextureName); m_Hover = content.Load<Texture2D>(hoverTextureName); m_ButtonRec = new Rectangle((int)position.X, (int)position.Y, m_Normal.Width, m_Normal.Height); }

public Mob(ushort pID, Vector2 Pos) { ID = pID; Position = Pos; Init(); SetBoundriesFromPointAndRange(Pos, 700); }

public static void SetSize(this RectTransform trans, Vector2 newSize) { Vector2 oldSize = trans.rect.size; Vector2 deltaSize = newSize - oldSize; trans.offsetMin = trans.offsetMin - new Vector2(deltaSize.x * trans.pivot.x, deltaSize.y * trans.pivot.y); trans.offsetMax = trans.offsetMax + new Vector2(deltaSize.x * (1f - trans.pivot.x), deltaSize.y * (1f - trans.pivot.y)); }

void Update() { if (!isActive) return; Vector2 position = transform.position; Vector2 nodePos = path[currentNode]; Vector2 positionDelta = nodePos - position; float dot_product = move_dir.x * positionDelta.x + move_dir.y * positionDelta.y; if (dot_product <= 0) { if (++currentNode == path.Length) { //OnEndReached.Invoke(gameObject); //GetComponent<Animator>().SetBool("Explode", true); Die(); isActive = false; } else { nodePos = path[currentNode]; move_dir = (nodePos - position).normalized; transform.position = position + move_dir * speed * Time.deltaTime; //_animator.SetFloat("SpeedX", move_dir.x); //_animator.SetFloat("SpeedY", move_dir.y); //_animator.SetBool("horizontal_move", Mathf.Abs(move_dir.x) > 0.1f); } } else { transform.position = position + move_dir * speed * Time.deltaTime; } }

public Plane(int xRes, int yRes, float xScale, float yScale) { Vertices = new Vector3[xRes * yRes]; Normals = new Vector3[xRes * yRes]; Indices = new uint[6 * xRes * yRes]; Texcoords = new Vector2[xRes * yRes]; int i = 0; for (int y = -yRes / 2; y < yRes / 2; y++) { for (int x = -xRes / 2; x < xRes / 2; x++) { Vertices[i].X = xScale * x / xRes; Vertices[i].Y = yScale * y / yRes; Vertices[i].Z = 0; Normals[i].X = Normals[i].Y = 0; Normals[i].Z = 1; i++; } } i = 0; for (int y = 0; y < yRes - 1; y++) { for (int x = 0; x < xRes - 1; x++) { Indices[i++] = (uint)((y + 0) * xRes + x); Indices[i++] = (uint)((y + 1) * xRes + x); Indices[i++] = (uint)((y + 0) * xRes + x + 1); Indices[i++] = (uint)((y + 0) * xRes + x + 1); Indices[i++] = (uint)((y + 1) * xRes + x); Indices[i++] = (uint)((y + 1) * xRes + x + 1); } } }

public override void AI() { shooter = Main.npc[(int)projectile.ai[0]]; Vector2 mousePos = Main.MouseWorld; Player player = Main.player[projectile.owner]; if (!shooter.active) { projectile.Kill(); } #region Set projectile position Vector2 diff = new Vector2(0, 14); diff.Normalize(); projectile.velocity = diff; projectile.direction = projectile.Center.X > shooter.Center.X ? 1 : -1; projectile.netUpdate = true; projectile.position = new Vector2(shooter.Center.X, shooter.Center.Y) + projectile.velocity * MoveDistance; projectile.timeLeft = 2; int dir = projectile.direction; /* * player.ChangeDir(dir); * player.heldProj = projectile.whoAmI; * player.itemTime = 2; * player.itemAnimation = 2; * player.itemRotation = (float)Math.Atan2(projectile.velocity.Y * dir, projectile.velocity.X * dir); */ #endregion #region Charging process // Kill the projectile if the player stops channeling // Do we still have enough mana? If not, we kill the projectile because we cannot use it anymore Vector2 offset = projectile.velocity; offset *= MoveDistance - 20; Vector2 pos = new Vector2(shooter.Center.X, shooter.Center.Y) + offset - new Vector2(10, 10); if (Charge < MaxChargeValue) { Charge++; } int chargeFact = (int)(Charge / 20f); #endregion if (Charge < MaxChargeValue) { return; } Vector2 start = new Vector2(shooter.Center.X, shooter.Center.Y); Vector2 unit = projectile.velocity; unit *= -1; for (Distance = MoveDistance; Distance <= 2200f; Distance += 5f) { start = new Vector2(shooter.Center.X, shooter.Center.Y) + projectile.velocity * Distance; /* * if (!Collision.CanHit(new Vector2(shooter.Center.X, shooter.Center.Y), 1, 1, start, 1, 1)) * { * Distance -= 5f; * break; * } */ } //Add lights DelegateMethods.v3_1 = new Vector3(10f, 10f, 10f); Utils.PlotTileLine(projectile.Center, projectile.Center + projectile.velocity * (Distance - MoveDistance), 26, DelegateMethods.CastLight); }

public static Vector3 ToVector3(this Vector2 v, float z) { return new Vector3(v.x, v.y, z); }

public static Vector2Int CeilToInt(Vector2 v) => new Vector2Int(Mathf.CeilToInt(v.x), Mathf.CeilToInt(v.y));

public static float MaxOf(Vector2 v) => Mathf.Max(v.x, v.y);

public static Vector3 ToVector3XZ(this Vector2 v) { return new Vector3(v.x, 0, v.y); }

public static float ToAng(Vector2 v) { return Mathf.Atan2(v.y, v.x) * Mathf.Rad2Deg; }

public static Vector2 Ceil(Vector2 v) => new Vector2(Mathf.Ceil(v.x), Mathf.Ceil(v.y));

public void CreateProjectile(Vector2 pos){ var clone = Instantiate(swordPrefab, pos, Quaternion.identity, transform) as GameObject; clone.GetComponent<SwordHitbox>().actionType = ActionType.Attacking; Debug.Log("Attack!"); }

public static Vector2 Rotate(this Vector2 v, double degrees) { return v.RotateRadians(degrees * DegToRad); }

public static Vector2 RotateRadians(this Vector2 v, double radians) { var ca = Math.Cos(radians); var sa = Math.Sin(radians); return new Vector2((float)(ca * v.X - sa * v.Y), (float)(sa * v.X + ca * v.Y)); }

public void Draw() { // Allow update for non-triggering changes (e.g., changing map view filters or changing a vessel's type) // This is the best way I could find to do periodic refreshes; // RTCore.Instance.InvokeRepeating() would require a search for instances // of AntennaFragment, and would keep running after all target windows // closed. Replace with something less clunky later! -- Starstrider42 if (++refreshCounter >= 100) { Refresh(); refreshCounter = 0; } mScrollPosition = GUILayout.BeginScrollView(mScrollPosition); { Color pushColor = GUI.backgroundColor; TextAnchor pushAlign = GUI.skin.button.alignment; GUI.skin.button.alignment = TextAnchor.MiddleLeft; // Depth-first tree traversal. Stack<Entry> dfs = new Stack<Entry>(); foreach (Entry child in mRootEntry.SubEntries) { dfs.Push(child); } while (dfs.Count > 0) { Entry current = dfs.Pop(); GUI.backgroundColor = current.Color; GUILayout.BeginHorizontal(); { GUILayout.Space(current.Depth * (GUI.skin.button.margin.left + 24)); if (current.SubEntries.Count > 0) { RTUtil.Button(current.Expanded ? " <" : " >", () => { current.Expanded = !current.Expanded; }, GUILayout.Width(24)); } RTUtil.StateButton(current.Text, mSelection == current ? 1 : 0, 1, (s) => { mSelection = current; Antenna.Target = mSelection.Guid; }); } GUILayout.EndHorizontal(); if (current.Expanded) { foreach (Entry child in current.SubEntries) { dfs.Push(child); } } } GUI.skin.button.alignment = pushAlign; GUI.backgroundColor = pushColor; } GUILayout.EndScrollView(); }

/// <summary> /// Create a vector of specified type (fill the blank slots with 0 or ignore unnecessary slots) /// </summary> private static bool CreateVectorFromInput(string input, Type vectorType, out object output) { List <string> tokens = new List <string>(input.Replace(',', ' ').Trim().Split(' ')); int i; for (i = tokens.Count - 1; i >= 0; i--) { tokens[i] = tokens[i].Trim(); if (tokens[i].Length == 0) { tokens.RemoveAt(i); } } float[] tokenValues = new float[tokens.Count]; for (i = 0; i < tokens.Count; i++) { float val; if (float.TryParse(tokens[i], out val) == false) { if (vectorType == typeof(Vector3)) { output = new Vector3(); } else if (vectorType == typeof(Vector2)) { output = new Vector2(); } else { output = new Vector4(); } return(false); } tokenValues[i] = val; } if (vectorType == typeof(Vector3)) { Vector3 result = new Vector3(); for (i = 0; i < tokenValues.Length && i < 3; i++) { result[i] = tokenValues[i]; } for ( ; i < 3; i++) { result[i] = 0; } output = result; } else if (vectorType == typeof(Vector2)) { Vector2 result = new Vector2(); for (i = 0; i < tokenValues.Length && i < 2; i++) { result[i] = tokenValues[i]; } for ( ; i < 2; i++) { result[i] = 0; } output = result; } else { Vector4 result = new Vector4(); for (i = 0; i < tokenValues.Length && i < 4; i++) { result[i] = tokenValues[i]; } for ( ; i < 4; i++) { result[i] = 0; } output = result; } return(true); }

// Start is called before the first frame update void Start() { audioSource = GetComponent<AudioSource>(); rigidbody2D = GetComponent<Rigidbody2D>(); paddleToBallVector = transform.position - paddle1.transform.position; }

public static (bool hit, float distance, Vector2 normal) BoxRaycast(Rect box, Vector2 center, Vector2 direction) { direction = direction.normalized; Vector2 tMin, tMax; if (direction.x == 0 && direction.y == 0) return (false, 0, Vector2.zero);

/// <summary> /// Draw the inspector. /// </summary> public override void OnInspectorGUI() { #if UNITY_4_3 EditorGUIUtility.LookLikeControls(120f); #else EditorGUIUtility.labelWidth = 120f; #endif m = target as UIMiniMapBase; PrefabType type = PrefabUtility.GetPrefabType(m.gameObject); if (m.material == null) { m.material = NJGEditorTools.GetMaterial(m, true); } NJGEditorTools.DrawEditMap(); DrawNotFound(); targetObj = (Transform)EditorGUILayout.ObjectField(new GUIContent("Map Target", "The object that this map is going to follow"), m.target, typeof(Transform), true); if (m.target == null) { if (Application.isPlaying) { EditorGUILayout.HelpBox("No target has been found, assign the tag to your target or drag it manually to the target field.", MessageType.Warning); } else { EditorGUILayout.HelpBox("No target has been assigned, the target can be set automatically by using a tag or drag it manually to the target field.", MessageType.Warning); } } targetTag = EditorGUILayout.TagField(new GUIContent("Target Tag", "Assign a tag to auto search for the Map Target"), m.targetTag); GUILayout.BeginHorizontal(); limitBounds = EditorGUILayout.Toggle("Limit Map Bounds", m.limitBounds, GUILayout.Width(140f)); GUI.contentColor = limitBounds ? Color.cyan : Color.gray; EditorGUILayout.LabelField("Prevent map to display beyond borders."); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); rotateWithPlayer = EditorGUILayout.Toggle("Lock Rotation", m.rotateWithPlayer, GUILayout.Width(140f)); GUI.contentColor = rotateWithPlayer ? Color.cyan : Color.gray; EditorGUILayout.LabelField("Makes the map follow target rotation."); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); ShowSelector("World Map Key", m.mapKey, delegate(KeyCode k) { m.keysInUse[2] = k; m.mapKey = k; EditorUtility.SetDirty(m); }); ShowSelector("Lock Key", m.lockKey, delegate(KeyCode k) { m.keysInUse[0] = k; m.lockKey = k; EditorUtility.SetDirty(m); }); mShader = (NJGMapBase.ShaderType)EditorGUILayout.EnumPopup("Shader Type", m.shaderType); if (mShader == NJGMapBase.ShaderType.ColorMask) { EditorGUILayout.HelpBox("Use the camera background color for masking", MessageType.Info); //m.colorMask = EditorGUILayout.ColorField("Color Mask", m.colorMask); } /*if (mShader != NJGMapBase.ShaderType.FOW) * { * NJGMapBase.instance.fow.enabled = true; * m.shaderType = mShader = NJGMapBase.ShaderType.FOW; * m.material.shader = Shader.Find("NinjutsuGames/Map FOW"); * NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); * //EditorGUILayout.HelpBox("Fog of War is enabled\nIn order to make it work the shader type should be FOW\nIgnore this warning if you don't want to use FOW for this instance.", MessageType.Warning); * } * else * { * NJGMapBase.instance.fow.enabled = false; * m.shaderType = mShader = NJGMapBase.ShaderType.TextureMask; * m.material.shader = Shader.Find("NinjutsuGames/Map TextureMask"); * NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); * }*/ if (m.shaderType != mShader) { m.shaderType = mShader; Shader s = Shader.Find("NinjutsuGames/Map TextureMask"); switch (mShader) { case NJGMapBase.ShaderType.TextureMask: s = Shader.Find("NinjutsuGames/Map TextureMask"); NJGMapBase.instance.fow.enabled = false; break; case NJGMapBase.ShaderType.ColorMask: s = Shader.Find("NinjutsuGames/Map ColorMask"); m.material.SetColor("_MaskColor", NJGMapBase.instance.cameraBackgroundColor); NJGMapBase.instance.fow.enabled = false; break; case NJGMapBase.ShaderType.FOW: s = Shader.Find("NinjutsuGames/Map FOW"); NJGMapBase.instance.fow.enabled = true; break; } m.material.shader = s; if (m.planeRenderer != null) { if (Application.isPlaying) { m.planeRenderer.material.shader = s; } else { m.planeRenderer.sharedMaterial.shader = s; } } NJGEditorTools.RegisterUndo("UIMiniMap Shader Type", m); } m.maskTexture = (Texture2D)EditorGUILayout.ObjectField("Mask", m.maskTexture, typeof(Texture2D), false); if (mMask != m.maskTexture) { mMask = m.maskTexture; m.material.SetTexture("_Mask", m.maskTexture); NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); } bool shouldBeOn = NJGEditorTools.DrawHeader("UI Settings"); if (shouldBeOn) { Color c = Color.grey; c.a = 0.5f; GUI.backgroundColor = c; NJGEditorTools.BeginContents(); GUI.backgroundColor = Color.white; DrawDepth(type == PrefabType.Prefab); mPivot = (UIMiniMapBase.Pivot)EditorGUILayout.EnumPopup("Alignment", m.pivot); if (m.pivot != mPivot) { m.pivot = mPivot; EditorUtility.SetDirty(m); m.UpdateAlignment(); } m.mapColor = EditorGUILayout.ColorField("Color", m.mapColor); if (mColor != m.mapColor) { mColor = m.mapColor; if (m.material != null) { m.material.color = m.mapColor; } NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); } /*GUILayout.BeginHorizontal(); * EditorGUILayout.LabelField("Dimensions", GUILayout.Width(116f)); * EditorGUIUtility.LookLikeControls(10f); * mMapScale.x = EditorGUILayout.IntField((int)m.mapScale.x); * EditorGUIUtility.LookLikeControls(12f); * EditorGUILayout.LabelField("x", GUILayout.Width(15f)); * mMapScale.y = EditorGUILayout.IntField((int)m.mapScale.y); * EditorGUIUtility.LookLikeControls(80f); * GUILayout.EndHorizontal();*/ mMapScale = EditorGUILayout.Vector2Field("Dimensions", m.mapScale); if (m.mapScale != mMapScale) { mMapScale.x = (int)mMapScale.x; mMapScale.y = (int)mMapScale.y; m.mapScale = mMapScale; NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); m.UpdateAlignment(); } /*GUILayout.BeginHorizontal(); * EditorGUILayout.LabelField("Margin", GUILayout.Width(116f)); * EditorGUIUtility.LookLikeControls(10f); * mMargin.x = EditorGUILayout.IntField((int)m.margin.x); * EditorGUIUtility.LookLikeControls(12f); * EditorGUILayout.LabelField("x", GUILayout.Width(15f)); * mMargin.y = EditorGUILayout.IntField((int)m.margin.y); * EditorGUIUtility.LookLikeControls(80f); * GUILayout.EndHorizontal();*/ mMargin = EditorGUILayout.Vector2Field("Margin", m.margin); if (m.margin != mMargin) { m.margin.x = (int)mMargin.x; m.margin.y = (int)mMargin.y; NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); m.UpdateAlignment(); } GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Culling Radius", "If icons get farther this radius they will dissapear"), GUILayout.Width(116f)); GUI.enabled = !m.calculateBorder; #if UNITY_4_3 mapBorderRadius = EditorGUILayout.FloatField(m.mapBorderRadius); #else mapBorderRadius = EditorGUILayout.FloatField(m.mapBorderRadius, GUILayout.Width(158f)); #endif GUI.enabled = true; calculateBorder = EditorGUILayout.Toggle(new GUIContent("Automatic", "Check this option if you want this value to be autmatically calculated at start."), m.calculateBorder); #if UNITY_4_3 EditorGUIUtility.LookLikeControls(120f); #else EditorGUIUtility.labelWidth = 120f; #endif GUILayout.EndHorizontal(); DrawFrameUI(); northIcon = (GameObject)EditorGUILayout.ObjectField(new GUIContent("North Icon", "Optional north icon. Will be automatically placed if its assigned."), m.northIcon, typeof(GameObject), true); //if (northIcon != null) // northIconOffset = EditorGUILayout.IntField(new GUIContent("North Icon Offset", "Adjust the north icon distance from map border"), m.northIconOffset); NJGEditorTools.EndContents(); EditorGUILayout.Separator(); } shouldBeOn = NJGEditorTools.DrawHeader("Zoom Settings"); if (shouldBeOn) { Color c = Color.grey; c.a = 0.5f; GUI.backgroundColor = c; NJGEditorTools.BeginContents(); GUI.backgroundColor = Color.white; //EditorGUILayout.LabelField("Zoom Settings", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); mouseWheel = EditorGUILayout.Toggle("Mouse Wheel", m.mouseWheelEnabled, GUILayout.Width(140f)); GUI.contentColor = mouseWheel ? Color.cyan : Color.gray; EditorGUILayout.LabelField("Enable Mouse Wheel zoom."); GUI.contentColor = Color.white; GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); zoom = EditorGUILayout.Slider(new GUIContent("Zoom", "Current zoom level"), m.zoom, m.minZoom, m.maxZoom); if (m.zoom != zoom) { if (!LeanTween.isTweening(m.gameObject)) { m.zoom = Mathf.Clamp(zoom, m.minZoom, m.maxZoom); } NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); } GUILayout.EndHorizontal(); zoomAmount = EditorGUILayout.Slider(new GUIContent("Amount", "How much should zoom in/out when zoom function is called."), m.zoomAmount, 0.01f, 5); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent("Range", "Min and Max level of zoom"), GUILayout.Width(116.0f)); minZoom = EditorGUILayout.FloatField(m.minZoom, GUILayout.Width(25.0f)); EditorGUILayout.MinMaxSlider(ref minZoom, ref maxZoom, 1, 30); maxZoom = EditorGUILayout.FloatField(m.maxZoom, GUILayout.Width(25.0f)); //minZoom = Mathf.Round(minZoom); //maxZoom = Mathf.Round(maxZoom); GUILayout.EndHorizontal(); mEasing = (LeanTweenType)EditorGUILayout.EnumPopup("Easing", m.zoomEasing); if (m.zoomEasing != mEasing) { m.zoomEasing = mEasing; NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); } zoomSpeed = EditorGUILayout.Slider(new GUIContent("Speed", "Zoom animation speed"), m.zoomSpeed, 0f, 2f); ShowSelector("Zoom In Key", m.zoomInKey, delegate(KeyCode k) { m.keysInUse[0] = k; m.zoomInKey = k; NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); }); ShowSelector("Zoom Out Key", m.zoomOutKey, delegate(KeyCode k) { m.keysInUse[1] = k; m.zoomOutKey = k; NJGEditorTools.RegisterUndo("UIMiniMap Setting", m); }); NJGEditorTools.EndContents(); EditorGUILayout.Separator(); } shouldBeOn = NJGEditorTools.DrawHeader("Panning Settings"); if (shouldBeOn) { Color c = Color.grey; c.a = 0.5f; GUI.backgroundColor = c; NJGEditorTools.BeginContents(); GUI.backgroundColor = Color.white; panning = EditorGUILayout.Toggle("Enabled", m.panning, GUILayout.Width(140f)); GUI.enabled = panning; panningEase = (LeanTweenType)EditorGUILayout.EnumPopup("Easing", m.panningEasing); panningSpeed = EditorGUILayout.Slider(new GUIContent("Speed", "How fast the panning should move"), m.panningSpeed, 0, 5); panningSensitivity = EditorGUILayout.Slider(new GUIContent("Sensitivy", "How fast the panning should respond on mouse move"), m.panningSensitivity, 0.1f, 10f); panningMoveBack = EditorGUILayout.Toggle(new GUIContent("Return on Release", "Moves back the panning to its original position"), m.panningMoveBack, GUILayout.Width(140f)); GUI.enabled = true; NJGEditorTools.EndContents(); EditorGUILayout.Separator(); } if (m.limitBounds != limitBounds || m.rotateWithPlayer != rotateWithPlayer || m.target != targetObj || m.targetTag != targetTag || m.minZoom != minZoom || m.maxZoom != maxZoom || m.zoomSpeed != zoomSpeed || m.mapBorderRadius != mapBorderRadius || m.northIcon != northIcon || //m.northIconOffset != northIconOffset || m.calculateBorder != calculateBorder || m.mouseWheelEnabled != mouseWheel || m.panning != panning || m.panningSpeed != panningSpeed || m.panningEasing != panningEase || m.panningMoveBack != panningMoveBack || m.panningSensitivity != panningSensitivity || m.zoomAmount != zoomAmount) { m.zoomAmount = zoomAmount; m.panningSensitivity = panningSensitivity; m.panningMoveBack = panningMoveBack; m.panning = panning; m.panningSpeed = panningSpeed; m.panningEasing = panningEase; m.limitBounds = limitBounds; m.rotateWithPlayer = rotateWithPlayer; m.target = targetObj; m.targetTag = targetTag; m.minZoom = minZoom; m.maxZoom = maxZoom; m.zoomSpeed = zoomSpeed; m.mapBorderRadius = mapBorderRadius; m.northIcon = northIcon; //m.northIconOffset = northIconOffset; m.calculateBorder = calculateBorder; m.mouseWheelEnabled = mouseWheel; NJGEditorTools.RegisterUndo("Changed Minimap Settings", m); } if (GUI.changed) { EditorUtility.SetDirty(m); } }

public override void AI() { if (body == -1) { int npcID = BaseAI.GetNPC(npc.Center, mod.NPCType("Zero"), 1000, null); if (npcID >= 0) { body = npcID; } } if (body == -1) { return; } NPC zero = Main.npc[body]; if (zero == null || zero.life <= 0 || !zero.active || zero.type != mod.NPCType("Zero")) { npc.active = false; return; } for (int m = npc.oldPos.Length - 1; m > 0; m--) { npc.oldPos[m] = npc.oldPos[m - 1]; } npc.oldPos[0] = npc.position; int probeNumber = ((Zero)zero.modNPC).WeaponCount; if (rotValue == -1f) { rotValue = npc.ai[0] % probeNumber * ((float)Math.PI * 2f / probeNumber); } rotValue += Main.expertMode ? .05f : 0f; while (rotValue > (float)Math.PI * 2f) { rotValue -= (float)Math.PI * 2f; } npc.Center = BaseUtility.RotateVector(zero.Center, zero.Center + new Vector2(((Zero)zero.modNPC).Distance, 0f), rotValue); if (Main.netMode != NetmodeID.MultiplayerClient) { npc.ai[2]++; } Player player = Main.player[zero.target]; int aiTimerFire = Main.expertMode ? 260 : 300; if (npc.ai[2] == aiTimerFire) { npc.ai[2] = 0; if (Collision.CanHit(npc.position, npc.width, npc.height, player.Center, player.width, player.height)) { Vector2 fireTarget = npc.Center; float rot = BaseUtility.RotationTo(npc.Center, player.Center); fireTarget = BaseUtility.RotateVector(npc.Center, fireTarget, rot); BaseAI.FireProjectile(player.Center, fireTarget, mod.ProjectileType("GenocideRocket"), npc.damage / 2, 0f, 4f); } } Vector2 vector2 = new Vector2(npc.position.X + (npc.width * 0.5f), npc.position.Y + (npc.height * 0.5f)); float num1 = Main.player[npc.target].position.X + (Main.player[npc.target].width / 2) - vector2.X; float num2 = Main.player[npc.target].position.Y + (Main.player[npc.target].height / 2) - vector2.Y; float NewRotation = (float)Math.Atan2(num2, num1) - 1.57f; npc.rotation = MathHelper.Lerp(npc.rotation, NewRotation, 1f / 30f); }

public static Vector2 Frac(Vector2 v) => new Vector2(Frac(v.x), Frac(v.y));

public override bool?DrawHealthBar(byte hbPosition, ref float scale, ref Vector2 position) { return(false); }

public static bool LineIntersect(Vector2 o1, Vector2 d1, Vector2 o2, Vector2 d2, out Vector2 point) { var div = (d1.y * d2.x - d1.x * d2.y); point = Vector2.zero; if (Mathf.Abs(div) < 0.001f) return false; var t1 = -(-d2.y * o1.x + d2.x * o1.y + d2.y * o2.x - d2.x * o2.y) / div; point = o1 + d1 * t1; return true; }

public void Update(GameTime gameTime) { bool collision = false; _minDistance = float.MaxValue; for (int i = 0; i < BeansJamGame.planets.Count; i++) { Vector2 vec = (BeansJamGame.planets[i].position - _position); if (vec.Length() - BeansJamGame.planets[i].radius < _minDistance) { _minDistance = vec.Length() - BeansJamGame.planets[i].radius; _mainPlanet = BeansJamGame.planets[i]; } float planetDistance = vec.Length(); vec.Normalize(); Vector2 planetAcceleration = vec * (BeansJamGame.planets[i].radius * 5 / planetDistance) * 0.05f; _velocity += planetAcceleration; } for (int i = 0; i < BeansJamGame.planets.Count; i++) if (Math.Abs(((_position + _velocity) - BeansJamGame.planets[i].position).Length()) <= BeansJamGame.planets[i].radius) collision = true; if (collision) { _velocity = Vector2.Zero; _isJumping = false; } else { _position += _velocity; } Vector2 mainVec = (_mainPlanet.position - _position); mainVec.Normalize(); //rotation = (float)Math.Atan2(mainVec.Y, mainVec.X); if (BeansJamGame.keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left)) { _rVelocity -= 0.0001f; //velocity += new Vector2(-mainVec.Y, mainVec.X) * speed; } if (BeansJamGame.keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right)) { _rVelocity += 0.0001f; //velocity -= new Vector2(-mainVec.Y, mainVec.X) * speed; } _rotation += _rVelocity; //if (!isJumping && BeansJamGame.keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space)) //{ // isJumping = true; // velocity = mainVec * acceleration; //} if (BeansJamGame.keyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Space)) { Vector2 engineVector = new Vector2((float)Math.Cos(_rotation), (float)Math.Sin(_rotation)); _velocity += engineVector * -0.351f; } _playerRectangle.X = (int)(_position.X); _playerRectangle.Y = (int)(_position.Y); }

/// <summary> /// Cross product following right hand rule. /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public static float Cross2(Vector2 u, Vector2 v) => u.x * v.y - u.y * v.x;

public Player() { _position = new Vector2(0, -100); _rotation = (float)Math.PI / 2; }

public static bool Contains(this RectInt rect, Vector2 pos) { if (pos.x >= rect.xMin && pos.y >= rect.yMin && pos.x < rect.xMax && pos.y < rect.yMax) return true; return false; }

//Initialization void Start () { _transform = gameObject.GetComponent<Transform>(); _currentPosition = _transform.position; }

public static Vector2 Max(Vector2 a, Vector2 b) => new Vector2(Mathf.Max(a.x, b.x), Mathf.Max(a.y, b.y));

public bool Draw(Rect parentPosition, ParentNode selectedNode, Vector2 mousePosition, int mouseButtonId, bool hasKeyboardFocus) { bool changeCheck = false; base.Draw(parentPosition, mousePosition, mouseButtonId, hasKeyboardFocus); if (m_nodePropertiesStyle == null) { m_nodePropertiesStyle = UIUtils.GetCustomStyle(CustomStyle.NodePropertiesTitle); m_nodePropertiesStyle.normal.textColor = m_nodePropertiesStyle.active.textColor = EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f) : new Color(0f, 0f, 0f); } if (m_isMaximized) { KeyCode key = Event.current.keyCode; if (m_isMouseInside || hasKeyboardFocus) { if (key == ShortcutsManager.ScrollUpKey) { m_currentScrollPos.y -= 10; if (m_currentScrollPos.y < 0) { m_currentScrollPos.y = 0; } Event.current.Use(); } if (key == ShortcutsManager.ScrollDownKey) { m_currentScrollPos.y += 10; Event.current.Use(); } } if (m_forceUpdate) { if (m_propertyReordableList != null) { m_propertyReordableList.ReleaseKeyboardFocus(); } m_propertyReordableList = null; if (m_functionInputsReordableList != null) { m_functionInputsReordableList.ReleaseKeyboardFocus(); } m_functionInputsReordableList = null; if (m_functionOutputsReordableList != null) { m_functionOutputsReordableList.ReleaseKeyboardFocus(); } m_functionOutputsReordableList = null; m_forceUpdate = false; } GUILayout.BeginArea(m_transformedArea, m_content, m_style); { //Draw selected node parameters if (selectedNode != null) { // this hack is need because without it the several FloatFields/Textfields/... would show wrong values ( different from the ones they were assigned to show ) if (m_lastSelectedNode != selectedNode.UniqueId) { m_lastSelectedNode = selectedNode.UniqueId; GUI.FocusControl(""); } EditorGUILayout.BeginVertical(); { EditorGUILayout.Separator(); if (selectedNode.UniqueId == ParentWindow.CurrentGraph.CurrentMasterNodeId) { m_dummyContent.text = "Output Node"; } else { if (selectedNode.Attributes != null) { m_dummyContent.text = selectedNode.Attributes.Name; } else if (selectedNode is CommentaryNode) { m_dummyContent.text = "Commentary"; } else { m_dummyContent.text = TitleStr; } } EditorGUILayout.LabelField(m_dummyContent, m_nodePropertiesStyle); EditorGUILayout.Separator(); //UIUtils.RecordObject( selectedNode , "Changing properties on node " + selectedNode.UniqueId); m_currentScrollPos = EditorGUILayout.BeginScrollView(m_currentScrollPos, GUILayout.Width(0), GUILayout.Height(0)); float labelWidth = EditorGUIUtility.labelWidth; if (selectedNode.TextLabelWidth > 0) { EditorGUIUtility.labelWidth = selectedNode.TextLabelWidth; } changeCheck = selectedNode.SafeDrawProperties(); EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); if (changeCheck) { if (selectedNode.ConnStatus == NodeConnectionStatus.Connected) { ParentWindow.SetSaveIsDirty(); } } } else { //Draw Graph Params EditorGUILayout.BeginVertical(); { EditorGUILayout.Separator(); EditorGUILayout.LabelField("Graph Properties", m_nodePropertiesStyle); EditorGUILayout.Separator(); m_currentScrollPos = EditorGUILayout.BeginScrollView(m_currentScrollPos, GUILayout.Width(0), GUILayout.Height(0)); float labelWidth = EditorGUIUtility.labelWidth; EditorGUIUtility.labelWidth = 90; bool generalIsVisible = EditorVariablesManager.ExpandedGeneralShaderOptions.Value; NodeUtils.DrawPropertyGroup(ref generalIsVisible, " General", DrawGeneralFunction); EditorVariablesManager.ExpandedGeneralShaderOptions.Value = generalIsVisible; AmplifyShaderFunction function = ParentWindow.CurrentGraph.CurrentShaderFunction; if (function != null) { function.AdditionalIncludes.Draw(ParentWindow.CurrentGraph.CurrentOutputNode); } bool inputIsVisible = EditorVariablesManager.ExpandedFunctionInputs.Value; NodeUtils.DrawPropertyGroup(ref inputIsVisible, " Function Inputs", DrawFunctionInputs); EditorVariablesManager.ExpandedFunctionInputs.Value = inputIsVisible; bool outputIsVisible = EditorVariablesManager.ExpandedFunctionOutputs.Value; NodeUtils.DrawPropertyGroup(ref outputIsVisible, " Function Outputs", DrawFunctionOutputs); EditorVariablesManager.ExpandedFunctionOutputs.Value = outputIsVisible; bool properties = ParentWindow.ExpandedProperties; NodeUtils.DrawPropertyGroup(ref properties, " Material Properties", DrawFunctionProperties); ParentWindow.ExpandedProperties = properties; EditorGUIUtility.labelWidth = labelWidth; EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); } } // Close window area GUILayout.EndArea(); } PostDraw(); return(changeCheck); }

private static BarrierType FindBarrierType() { Vector2 nextPos = PlayerNextPosition(); xTile.Dimensions.Location location = new xTile.Dimensions.Location((int)nextPos.X, (int)nextPos.Y); Vector2 tilePos = new Vector2(location.X / Game1.tileSize, location.Y / Game1.tileSize); GameLocation loc = Game1.currentLocation; Layer buildingsLayer = loc.map.GetLayer("Buildings"); Tile tile = buildingsLayer.PickTile(location, Game1.viewport.Size); if (tile != null) { int i = tile.TileIndex; ModEntry.Log("tile " + tile.TileIndex); if (loc is FarmHouse) { return(BarrierType.Housewall); } else if (i == 184 || i == 1183 || i == 1210 || i == 211 || i == 183 || i == 1182 || i == 185 || i == 1184 || i == 235 || i == 1290 || i == 260 || i == 1315 || i == 259 || i == 258 || i == 1257 || i == 1207 || i == 208 || i == 213 || i == 212 || i == 1232 || i == 233 || i == 1209 || i == 210 || i == 238 || i == 1292 || i == 237 || i == 1291) { return(BarrierType.Water); } else if (i == 383 || i == 384 || i == 385 || i == 436 || i == 411 || i == 386 || i == 434 || i == 832 || i == 833 || i == 834 || i == 866 || i == 898 || i == 930 || i == 900 || i == 929 || i == 928 || i == 896 || i == 864) { return(BarrierType.Fence); } else if (i == 541 || i == 542 || i == 543 || i == 544 || i == 391 || i == 416 || i == 441 || i == 466 || i == 491 || i == 516 || i == 419 || i == 394 || i == 444 || i == 469 || i == 494 || i == 519 || i == 422 || i == 438 || i == 540 || i == 439 || i == 464 || i == 440 || i == 467 || i == 468 || i == 369 || i == 344 || i == 319 || i == 294 || i == 295 || i == 291 || i == 316 || i == 366 || i == 496 || i == 522 || i == 548 || i == 547 || i == 546 || i == 545 || i == 539 || i == 371 || i == 399 || i == 446 || i == 290) { return(BarrierType.Cliff); } else if (i == 1938 || i == 1939) { return(BarrierType.PetWaterBowl); } else if (i == 40 || i == 72 || i == 322 || i == 323 || i == 327 || i == 54 || i == 86) { return(BarrierType.Bench); } else if (i == 1003) { return(BarrierType.Lantern); } return(BarrierType.UnknownWall); } else if (loc.isTerrainFeatureAt((int)tilePos.X, (int)tilePos.Y)) { TerrainFeature terrainFeature = loc.terrainFeatures.ContainsKey(tilePos) ? loc.terrainFeatures[tilePos] : loc.getLargeTerrainFeatureAt((int)tilePos.X, (int)tilePos.Y); //ModEntry.Log("terrain: "+terrainFeature.ToString()); if (terrainFeature is Bush) { return(BarrierType.Bush); } if (terrainFeature is Tree) { return(BarrierType.Tree); } return(BarrierType.UnknownTerrain); } /* * else if (Game1.currentLocation.getLargeTerrainFeatureAt(location.X / Game1.tileSize, location.Y / Game1.tileSize) != null) * { * ModEntry.Log("large terrain"); * return BarrierType.UnknownLargeTerrain; * } */ else if (Game1.currentLocation.getObjectAtTile(location.X / Game1.tileSize, location.Y / Game1.tileSize) is StardewValley.Object obj && obj != null) { switch (obj.ParentSheetIndex) { case 294: case 295: return(BarrierType.Wood); case Object.mineStoneSnow1: case Object.mineStoneSnow2: case Object.mineStoneSnow3: case Object.mineStonePurpleSnowIndex: case Object.mineStoneRed1Index: case Object.mineStoneRed2Index: case Object.mineStoneBlue1Index: case Object.mineStoneBlue2Index: case Object.mineStoneGrey1Index: case Object.mineStoneGrey2Index: case Object.mineStoneBrown1Index: case Object.mineStoneBrown2Index: case Object.mineStoneMysticIndex: case Object.mineStonePurpleIndex: case 343: case 450: return(BarrierType.Stone); //case Object.mineStoneSnow1 case 674: case 675: case 784: case 792: return(BarrierType.Weed); default: ModEntry.Log("obj: " + obj.Name + ", id: " + obj.ParentSheetIndex); return(BarrierType.UnknownObject); } }

public void SetVector2(Vector2 val) { vector_2 = val; }

public static Vector2Int FloorToInt(Vector2 v) => new Vector2Int(Mathf.FloorToInt(v.x), Mathf.FloorToInt(v.y));

public override void AI() { if (Main.netMode != 0) { Vector2 target = new Vector2(npc.ai[0], npc.ai[1]); Vector2 moveTo = new Vector2(target.X, target.Y) - npc.position; npc.velocity = (moveTo) * 1f; } if (Main.expertMode) { shotDamage = (int)(npc.damage / 8 * 1.6f); } else { shotDamage = npc.damage / 4; } Player player = Main.player[npc.target]; npc.TargetClosest(true); if (npc.defense == 2) { fireLaser = true; npc.dontTakeDamage = false; frame = 1; timer++; if (timer > 90) { timer = 30; if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 1 * (float)Math.PI / 12) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +1 * (float)Math.PI / 12) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 3 * (float)Math.PI / 12) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +3 * (float)Math.PI / 12) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 5 * (float)Math.PI / 12) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +5 * (float)Math.PI / 12) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); //Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 7 * (float)Math.PI / 16) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +7 * (float)Math.PI / 16) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -1 * (float)Math.PI / 12) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + + -1 * (float)Math.PI / 12) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -3 * (float)Math.PI / 12) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + + -3 * (float)Math.PI / 12) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -5 * (float)Math.PI / 12) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + + -5 * (float)Math.PI / 12) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); //Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -7 * (float)Math.PI / 16) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +-7 * (float)Math.PI / 16) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); } } else if (timer == 60) { if (Main.netMode != 1) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 0 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +0 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 1 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +1 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 2 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +2 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 3 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +3 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); //Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + 4 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +4 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -1 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + + -1 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -2 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + + -2 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -3 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + + -3 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); //Projectile.NewProjectile(npc.Center.X, npc.Center.Y, (float)Math.Cos(-(float)Math.PI / 2 + -4 * (float)Math.PI / 6) * shotSpeed, -(float)Math.Sin(-(float)Math.PI / 2 + +-4 * (float)Math.PI / 6) * shotSpeed, mod.ProjectileType("TurretShot"), shotDamage, 0, Main.myPlayer); } } } else if (npc.defense == 3) { if (fireLaser) { laser = Main.projectile[Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, 14f, mod.ProjectileType("SuperLaser"), 5 * shotDamage, 3f, Main.myPlayer, npc.whoAmI, npc.rotation + (float)Math.PI / 2)]; fireLaser = false; } npc.dontTakeDamage = false; frame = 1; timer++; if (timer > 600) { laser.Kill(); timer = 0; } } else if (npc.defense == 4) { timer++; if (timer == 120 && Main.netMode != 1) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, 14f, mod.ProjectileType("BlackHoleSeed"), 3 * shotDamage, 3f, Main.myPlayer); } npc.dontTakeDamage = false; frame = 1; } else if (npc.defense == 5 && Main.netMode != 1) { timer++; if (timer == 120) { Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, 7f, mod.ProjectileType("MegaBurst"), shotDamage, 3f, Main.myPlayer); } npc.dontTakeDamage = false; frame = 1; } else { fireLaser = true; timer = 0; npc.dontTakeDamage = true; frame = 0; } if (Math.Abs(player.Center.X - npc.Center.X) > 800 || player.Center.Y - npc.Center.Y > 1000) { npc.dontTakeDamage = true; } npc.defense = 50; }