linting 2
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,3 +3,5 @@ SlaveMatrix/obj/
|
|||||||
2DGAMELIB/bin/
|
2DGAMELIB/bin/
|
||||||
SlaveMatrix/bin/
|
SlaveMatrix/bin/
|
||||||
.vs/
|
.vs/
|
||||||
|
game_folder/save/*
|
||||||
|
/game_folder/save
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ namespace _2DGAMELIB
|
|||||||
private double unitS;
|
private double unitS;
|
||||||
|
|
||||||
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
|
public AreM(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
|
||||||
{
|
|
||||||
Setting(Unit, XRatio, YRatio, Size, DisMag, HitMag, Strength);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Setting(double Unit, double XRatio, double YRatio, double Size, double DisMag, double HitMag, double Strength)
|
|
||||||
{
|
{
|
||||||
SetXYRatio(XRatio, YRatio);
|
SetXYRatio(XRatio, YRatio);
|
||||||
base.Size = Size;
|
base.Size = Size;
|
||||||
@@ -23,6 +18,8 @@ namespace _2DGAMELIB
|
|||||||
disUnit = Unit * DisMag;
|
disUnit = Unit * DisMag;
|
||||||
double num = 1.0 - Strength;
|
double num = 1.0 - Strength;
|
||||||
unitS = disUnit * num;
|
unitS = disUnit * num;
|
||||||
|
|
||||||
|
|
||||||
WH.Width = (int)(base.LocalWidth * Unit);
|
WH.Width = (int)(base.LocalWidth * Unit);
|
||||||
WH.Height = (int)(base.LocalHeight * Unit);
|
WH.Height = (int)(base.LocalHeight * Unit);
|
||||||
WHA.Width = (int)(base.LocalWidth * disUnit);
|
WHA.Width = (int)(base.LocalWidth * disUnit);
|
||||||
@@ -31,6 +28,8 @@ namespace _2DGAMELIB
|
|||||||
gd = Graphics.FromImage(Dis);
|
gd = Graphics.FromImage(Dis);
|
||||||
gd.SmoothingMode = SmoothingMode.None;
|
gd.SmoothingMode = SmoothingMode.None;
|
||||||
gd.PixelOffsetMode = PixelOffsetMode.None;
|
gd.PixelOffsetMode = PixelOffsetMode.None;
|
||||||
|
|
||||||
|
|
||||||
hitUnit = Unit * HitMag;
|
hitUnit = Unit * HitMag;
|
||||||
WHH.Width = (int)(base.LocalWidth * hitUnit);
|
WHH.Width = (int)(base.LocalWidth * hitUnit);
|
||||||
WHH.Height = (int)(base.LocalHeight * hitUnit);
|
WHH.Height = (int)(base.LocalHeight * hitUnit);
|
||||||
@@ -40,15 +39,6 @@ namespace _2DGAMELIB
|
|||||||
gh.PixelOffsetMode = PixelOffsetMode.None;
|
gh.PixelOffsetMode = PixelOffsetMode.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
public new void Draw(ParT ParT)
|
|
||||||
{
|
|
||||||
ParT.Draw(unitS, gd);
|
|
||||||
if (gh != null)
|
|
||||||
{
|
|
||||||
ParT.DrawH(hitUnit, gh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public new void Draw(Pars Pars)
|
public new void Draw(Pars Pars)
|
||||||
{
|
{
|
||||||
Pars.Draw(unitS, gd);
|
Pars.Draw(unitS, gd);
|
||||||
|
|||||||
@@ -50,24 +50,12 @@ namespace _2DGAMELIB
|
|||||||
|
|
||||||
public Pars Pars => pars;
|
public Pars Pars => pars;
|
||||||
|
|
||||||
public But(Par Par, Action<But> Action)
|
|
||||||
{
|
|
||||||
pars = new Pars(Par);
|
|
||||||
this.Action = Action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public But(ParT ParT, Action<But> Action)
|
public But(ParT ParT, Action<But> Action)
|
||||||
{
|
{
|
||||||
pars = new Pars(ParT);
|
pars = new Pars(ParT);
|
||||||
this.Action = Action;
|
this.Action = Action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public But(Pars Pars, Action<But> Action)
|
|
||||||
{
|
|
||||||
pars = Pars;
|
|
||||||
this.Action = Action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Move(ref Color HitColor)
|
public bool Move(ref Color HitColor)
|
||||||
{
|
{
|
||||||
if (Dra && !f2 && pars.IsHit(ref HitColor))
|
if (Dra && !f2 && pars.IsHit(ref HitColor))
|
||||||
@@ -129,14 +117,6 @@ namespace _2DGAMELIB
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw(AreM AreM)
|
|
||||||
{
|
|
||||||
if (dra)
|
|
||||||
{
|
|
||||||
AreM.Draw(pars);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetHitColor(Med Med)
|
public void SetHitColor(Med Med)
|
||||||
{
|
{
|
||||||
foreach (Par item in pars.EnumAllPar())
|
foreach (Par item in pars.EnumAllPar())
|
||||||
|
|||||||
@@ -201,22 +201,6 @@ namespace _2DGAMELIB
|
|||||||
parss.Add(Pars);
|
parss.Add(Pars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draws(Are Are)
|
|
||||||
{
|
|
||||||
foreach (Pars item in parss)
|
|
||||||
{
|
|
||||||
Are.Draw(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Draws(AreM AreM)
|
|
||||||
{
|
|
||||||
foreach (Pars item in parss)
|
|
||||||
{
|
|
||||||
AreM.Draw(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<string> GetHitTags(ref Color HitColor)
|
public List<string> GetHitTags(ref Color HitColor)
|
||||||
{
|
{
|
||||||
List<string> list = new List<string>();
|
List<string> list = new List<string>();
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ namespace _2DGAMELIB
|
|||||||
|
|
||||||
public Dictionary<Pars, Par> pr;
|
public Dictionary<Pars, Par> pr;
|
||||||
|
|
||||||
public List<Dif> Difss => difs;
|
|
||||||
|
|
||||||
public int CountX => difs.Count;
|
public int CountX => difs.Count;
|
||||||
|
|
||||||
public int CountY
|
public int CountY
|
||||||
@@ -366,26 +364,6 @@ namespace _2DGAMELIB
|
|||||||
return difs.FirstOrDefault((Dif d) => d.IsHit(ref HitColor)).Parss.FirstOrDefault((Pars ps) => ps.IsHit(ref HitColor)).EnumAllPar().FirstOrDefault((Par e) => e.HitColor == HitColor);
|
return difs.FirstOrDefault((Dif d) => d.IsHit(ref HitColor)).Parss.FirstOrDefault((Pars ps) => ps.IsHit(ref HitColor)).EnumAllPar().FirstOrDefault((Par e) => e.HitColor == HitColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<string> GetHitTags(ref Color HitColor)
|
|
||||||
{
|
|
||||||
List<string> list = new List<string>();
|
|
||||||
foreach (Dif dif in difs)
|
|
||||||
{
|
|
||||||
list.AddRange(dif.GetHitTags(ref HitColor));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Par> GetHitPars(ref Color HitColor)
|
|
||||||
{
|
|
||||||
List<Par> list = new List<Par>();
|
|
||||||
foreach (Dif dif in difs)
|
|
||||||
{
|
|
||||||
list.AddRange(dif.GetHitPars(ref HitColor));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsHit(ref Color HitColor)
|
public bool IsHit(ref Color HitColor)
|
||||||
{
|
{
|
||||||
foreach (Dif dif in difs)
|
foreach (Dif dif in difs)
|
||||||
|
|||||||
@@ -240,10 +240,5 @@ namespace _2DGAMELIB
|
|||||||
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
|
HSV.ToRGB(H, S, V, out var r, out var g, out var b);
|
||||||
ret = Color.FromArgb(a, r, g, b);
|
ret = Color.FromArgb(a, r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return "H : " + H + " S : " + S + " V : " + V;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,30 +39,6 @@ namespace _2DGAMELIB
|
|||||||
Difs1.JoinPA();
|
Difs1.JoinPA();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void JoinPall()
|
|
||||||
{
|
|
||||||
foreach (Par item in Difs1.EnumJoinRoot)
|
|
||||||
{
|
|
||||||
Difs0.Current.GetPar(Path0).SetJointP(Index, item);
|
|
||||||
}
|
|
||||||
foreach (Pars item2 in Difs1.EnumAllPars())
|
|
||||||
{
|
|
||||||
Difs1.JoinPA(item2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void JoinPAall()
|
|
||||||
{
|
|
||||||
foreach (Par item in Difs1.EnumJoinRoot)
|
|
||||||
{
|
|
||||||
Difs0.Current.GetPar(Path0).SetJointPA(Index, item);
|
|
||||||
}
|
|
||||||
foreach (Pars item2 in Difs1.EnumAllPars())
|
|
||||||
{
|
|
||||||
Difs1.JoinPA(item2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Set(JointS 接続元)
|
public void Set(JointS 接続元)
|
||||||
{
|
{
|
||||||
Difs0 = 接続元.Difs;
|
Difs0 = 接続元.Difs;
|
||||||
|
|||||||
@@ -117,33 +117,6 @@ namespace _2DGAMELIB
|
|||||||
parT.OP[0].ps[3] = new Vector2D(0.0, parT.RectSize.Y);
|
parT.OP[0].ps[3] = new Vector2D(0.0, parT.RectSize.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Double(ref Color HitColor)
|
|
||||||
{
|
|
||||||
//TODO fix?
|
|
||||||
//if (Input && parT.HitColor == HitColor && !Med.BaseControl.Controls.Contains(tb))
|
|
||||||
/*{
|
|
||||||
tb.Text = parT.Text;
|
|
||||||
parT.Text = "";
|
|
||||||
SetRectT();
|
|
||||||
//Med.BaseControl.Controls.Add(tb);
|
|
||||||
tb.SelectAll();
|
|
||||||
tb.Focus();
|
|
||||||
tb.BringToFront();
|
|
||||||
return true;
|
|
||||||
}*/
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Click(ref Color HitColor)
|
|
||||||
{
|
|
||||||
//TODO fix?
|
|
||||||
/*if (Input && parT.HitColor != HitColor && Med.BaseControl.Controls.Contains(tb))
|
|
||||||
{
|
|
||||||
//Med.BaseControl.Controls.Remove(tb);
|
|
||||||
SetText(tb.Text);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
parT.Dispose();
|
parT.Dispose();
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace _2DGAMELIB
|
|
||||||
{
|
|
||||||
public static class Matrix
|
|
||||||
{
|
|
||||||
public static MatrixD RotationZ(this double angle)
|
|
||||||
{
|
|
||||||
MatrixD result = default(MatrixD);
|
|
||||||
result.M11 = System.Math.Cos(angle);
|
|
||||||
result.M12 = System.Math.Sin(angle);
|
|
||||||
result.M13 = 0.0;
|
|
||||||
result.M14 = 0.0;
|
|
||||||
result.M21 = 0.0 - result.M12;
|
|
||||||
result.M22 = result.M11;
|
|
||||||
result.M23 = 0.0;
|
|
||||||
result.M24 = 0.0;
|
|
||||||
result.M31 = 0.0;
|
|
||||||
result.M32 = 0.0;
|
|
||||||
result.M33 = 1.0;
|
|
||||||
result.M34 = 0.0;
|
|
||||||
result.M41 = 0.0;
|
|
||||||
result.M42 = 0.0;
|
|
||||||
result.M43 = 0.0;
|
|
||||||
result.M44 = 1.0;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result)
|
|
||||||
{
|
|
||||||
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
|
|
||||||
result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num;
|
|
||||||
result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform)
|
|
||||||
{
|
|
||||||
Vec.Subtract(ref coord, ref BasePoint, out coord);
|
|
||||||
TransformCoordinate(ref coord, ref transform, out var result);
|
|
||||||
Vec.Add(ref result, ref BasePoint, out result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform)
|
|
||||||
{
|
|
||||||
Vec.Subtract(ref coord, ref BasePoint, out var r);
|
|
||||||
TransformCoordinate(ref r, ref transform, out var result);
|
|
||||||
Vec.Add(ref result, ref BasePoint, out result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,168 +38,6 @@ namespace _2DGAMELIB
|
|||||||
|
|
||||||
public double M44;
|
public double M44;
|
||||||
|
|
||||||
public double this[int row, int col]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
switch (row)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return M11;
|
|
||||||
case 1:
|
|
||||||
return M12;
|
|
||||||
case 2:
|
|
||||||
return M13;
|
|
||||||
case 3:
|
|
||||||
return M14;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return M21;
|
|
||||||
case 1:
|
|
||||||
return M22;
|
|
||||||
case 2:
|
|
||||||
return M23;
|
|
||||||
case 3:
|
|
||||||
return M24;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return M31;
|
|
||||||
case 1:
|
|
||||||
return M32;
|
|
||||||
case 2:
|
|
||||||
return M33;
|
|
||||||
case 3:
|
|
||||||
return M34;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
case 3:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
return M41;
|
|
||||||
case 1:
|
|
||||||
return M42;
|
|
||||||
case 2:
|
|
||||||
return M43;
|
|
||||||
case 3:
|
|
||||||
return M44;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
switch (row)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
M11 = value;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
M12 = value;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
M13 = value;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
M14 = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
M21 = value;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
M22 = value;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
M23 = value;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
M24 = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
M31 = value;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
M32 = value;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
M33 = value;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
M34 = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
switch (col)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
M41 = value;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
M42 = value;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
M43 = value;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
M44 = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
error(row, col);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MatrixD(double M11, double M12, double M13, double M14, double M21, double M22, double M23, double M24, double M31, double M32, double M33, double M34, double M41, double M42, double M43, double M44)
|
public MatrixD(double M11, double M12, double M13, double M14, double M21, double M22, double M23, double M24, double M31, double M32, double M33, double M34, double M41, double M42, double M43, double M44)
|
||||||
{
|
{
|
||||||
this.M11 = M11;
|
this.M11 = M11;
|
||||||
@@ -219,17 +57,5 @@ namespace _2DGAMELIB
|
|||||||
this.M43 = M43;
|
this.M43 = M43;
|
||||||
this.M44 = M44;
|
this.M44 = M44;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void error(int row, int col)
|
|
||||||
{
|
|
||||||
if (row < 0 || row > 3)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException("row", "Rows and columns for matrices run from 0 to 3, inclusive.");
|
|
||||||
}
|
|
||||||
if (col < 0 || col > 3)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException("col", "Rows and columns for matrices run from 0 to 3, inclusive.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,12 +77,12 @@ namespace _2DGAMELIB
|
|||||||
|
|
||||||
private static Vector2D GetTP2()
|
private static Vector2D GetTP2()
|
||||||
{
|
{
|
||||||
return Matrix.TransformCoordinateBP(ref TP1, ref 中央中央, ref m120);
|
return Math.TransformCoordinateBP(ref TP1, ref 中央中央, ref m120);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Vector2D GetTP3()
|
private static Vector2D GetTP3()
|
||||||
{
|
{
|
||||||
return Matrix.TransformCoordinateBP(ref TP1, ref 中央中央, ref m240);
|
return Math.TransformCoordinateBP(ref TP1, ref 中央中央, ref m240);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2D MulX(this Vector2D Vector, double X)
|
public static Vector2D MulX(this Vector2D Vector, double X)
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace _2DGAMELIB
|
|
||||||
{
|
|
||||||
public static class Text
|
|
||||||
{
|
|
||||||
public static void ToText(this string str, string Path, Encoding Encoding)
|
|
||||||
{
|
|
||||||
using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding);
|
|
||||||
streamWriter.Write(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string FromText(this string Path)
|
|
||||||
{
|
|
||||||
using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
|
|
||||||
byte[] array = new byte[fileStream.Length];
|
|
||||||
fileStream.Read(array, 0, array.Length);
|
|
||||||
using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding());
|
|
||||||
return streamReader.ReadToEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string[] ReadLines(this string Path)
|
|
||||||
{
|
|
||||||
return Path.FromText().Replace("\r", "").Split('\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,33 +10,6 @@ namespace _2DGAMELIB
|
|||||||
|
|
||||||
public double Y;
|
public double Y;
|
||||||
|
|
||||||
public double this[int index]
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return index switch
|
|
||||||
{
|
|
||||||
0 => X,
|
|
||||||
1 => Y,
|
|
||||||
_ => throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive."),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
switch (index)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
X = value;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
Y = value;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException("index", "Indices for Vector2D run from 0 to 1, inclusive.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vector2D(int x, int y)
|
public Vector2D(int x, int y)
|
||||||
{
|
{
|
||||||
X = x;
|
X = x;
|
||||||
|
|||||||
@@ -32,26 +32,14 @@ namespace _2DGAMELIB
|
|||||||
return __refvalue(destRef, GLFW.Window);
|
return __refvalue(destRef, GLFW.Window);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe IntPtr WindowToPtr(Window source)
|
|
||||||
{
|
|
||||||
var sourceRef = __makeref(source);
|
|
||||||
var dest = default(IntPtr);
|
|
||||||
var destRef = __makeref(dest);
|
|
||||||
*(IntPtr*)&destRef = *(IntPtr*)&sourceRef;
|
|
||||||
return __refvalue(destRef, IntPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
public GLFW.Window window;
|
public GLFW.Window window;
|
||||||
private uint shader_program;
|
private uint shader_program;
|
||||||
private uint texture;
|
private uint texture;
|
||||||
private uint vertex_buf;
|
private uint vertex_buf;
|
||||||
private uint vao;
|
private uint vao;
|
||||||
|
|
||||||
|
|
||||||
public GlImage() { }
|
public GlImage() { }
|
||||||
|
|
||||||
public void ImageSetting() { }
|
|
||||||
|
|
||||||
public System.Drawing.Point GetCursorPoint() {
|
public System.Drawing.Point GetCursorPoint() {
|
||||||
double x, y;
|
double x, y;
|
||||||
Glfw.GetCursorPosition(window, out x, out y);
|
Glfw.GetCursorPosition(window, out x, out y);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace _2DGAMELIB
|
namespace _2DGAMELIB
|
||||||
@@ -21,6 +22,26 @@ namespace _2DGAMELIB
|
|||||||
{
|
{
|
||||||
return new PointF((float)Vector.X, (float)Vector.Y);
|
return new PointF((float)Vector.X, (float)Vector.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ToText(this string str, string Path, Encoding Encoding)
|
||||||
|
{
|
||||||
|
using StreamWriter streamWriter = new StreamWriter(Path, append: false, Encoding);
|
||||||
|
streamWriter.Write(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string FromText(this string Path)
|
||||||
|
{
|
||||||
|
using FileStream fileStream = new FileStream(Path, FileMode.Open, FileAccess.Read);
|
||||||
|
byte[] array = new byte[fileStream.Length];
|
||||||
|
fileStream.Read(array, 0, array.Length);
|
||||||
|
using StreamReader streamReader = new StreamReader(new MemoryStream(array), array.GetEncoding());
|
||||||
|
return streamReader.ReadToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string[] ReadLines(this string Path)
|
||||||
|
{
|
||||||
|
return Path.FromText().Replace("\r", "").Split('\n');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Math
|
public static class Math
|
||||||
@@ -115,5 +136,50 @@ namespace _2DGAMELIB
|
|||||||
return System.Math.Min(Les - 1, System.Math.Max(Sta, Value));
|
return System.Math.Min(Les - 1, System.Math.Max(Sta, Value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static MatrixD RotationZ(this double angle)
|
||||||
|
{
|
||||||
|
MatrixD result = default(MatrixD);
|
||||||
|
result.M11 = System.Math.Cos(angle);
|
||||||
|
result.M12 = System.Math.Sin(angle);
|
||||||
|
result.M13 = 0.0;
|
||||||
|
result.M14 = 0.0;
|
||||||
|
result.M21 = 0.0 - result.M12;
|
||||||
|
result.M22 = result.M11;
|
||||||
|
result.M23 = 0.0;
|
||||||
|
result.M24 = 0.0;
|
||||||
|
result.M31 = 0.0;
|
||||||
|
result.M32 = 0.0;
|
||||||
|
result.M33 = 1.0;
|
||||||
|
result.M34 = 0.0;
|
||||||
|
result.M41 = 0.0;
|
||||||
|
result.M42 = 0.0;
|
||||||
|
result.M43 = 0.0;
|
||||||
|
result.M44 = 1.0;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TransformCoordinate(ref Vector2D coord, ref MatrixD transform, out Vector2D result)
|
||||||
|
{
|
||||||
|
double num = 1.0 / (coord.X * transform.M14 + coord.Y * transform.M24 + transform.M44);
|
||||||
|
result.X = (coord.X * transform.M11 + coord.Y * transform.M21 + transform.M41) * num;
|
||||||
|
result.Y = (coord.X * transform.M12 + coord.Y * transform.M22 + transform.M42) * num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2D TransformCoordinateBP(this Vector2D coord, Vector2D BasePoint, MatrixD transform)
|
||||||
|
{
|
||||||
|
Vec.Subtract(ref coord, ref BasePoint, out coord);
|
||||||
|
TransformCoordinate(ref coord, ref transform, out var result);
|
||||||
|
Vec.Add(ref result, ref BasePoint, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector2D TransformCoordinateBP(ref Vector2D coord, ref Vector2D BasePoint, ref MatrixD transform)
|
||||||
|
{
|
||||||
|
Vec.Subtract(ref coord, ref BasePoint, out var r);
|
||||||
|
TransformCoordinate(ref r, ref transform, out var result);
|
||||||
|
Vec.Add(ref result, ref BasePoint, out result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace SlaveMatrix
|
|||||||
|
|
||||||
public double 濃度 = 1.0;
|
public double 濃度 = 1.0;
|
||||||
|
|
||||||
//TODO figure out what this broke...
|
//TODO this broke loading saves
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public Type ThisType;
|
public Type ThisType;
|
||||||
|
|
||||||
|
|||||||
@@ -1433,7 +1433,7 @@ namespace SlaveMatrix
|
|||||||
|
|
||||||
public static string[] JSDPaths()
|
public static string[] JSDPaths()
|
||||||
{
|
{
|
||||||
JsonSavePath = Path.Combine(CurrentDirectory, "save", "json");
|
JsonSavePath = Path.Combine(CurrentDirectory, "save");
|
||||||
IEnumerable<string> source = Directory.EnumerateFiles(JsonSavePath);
|
IEnumerable<string> source = Directory.EnumerateFiles(JsonSavePath);
|
||||||
return new string[10]
|
return new string[10]
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user