Skip to content

Commit

Permalink
0.9.8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
paissaheavyindustries committed Feb 10, 2023
1 parent 0e59593 commit 951a845
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 52 deletions.
130 changes: 88 additions & 42 deletions Telesto/Doodle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace Telesto
{

internal abstract class Doodle
internal abstract class Doodle : IDisposable
{

internal class Coordinate
Expand All @@ -34,30 +34,48 @@ internal enum CoordinateTypeEnum
internal Doodle doo { get; set; }
internal CoordinateTypeEnum ct { get; set; }
internal Vector3 cp { get; set; }
float ofsx, ofsy, ofsz;

internal string OffsetX { get; set; }
internal string OffsetY { get; set; }
internal string OffsetZ { get; set; }

internal string X { get; set; }
internal string Y { get; set; }
internal string Z { get; set; }
internal ulong id { get; set; }
internal string name { get; set; }

internal Vector3 UnadjustedPosition(Plugin p)
internal Vector3 UntranslatedPosition(Plugin p)
{
ofsx = ofsy = ofsz = 0.0f;
if (OffsetX != "")
{
ofsx = (float)p.EvaluateNumericExpression(doo, OffsetX);
}
if (OffsetY != "")
{
ofsy = (float)p.EvaluateNumericExpression(doo, OffsetY);
}
if (OffsetZ != "")
{
ofsz = (float)p.EvaluateNumericExpression(doo, OffsetZ);
}
switch (ct)
{
default:
case CoordinateTypeEnum.Screen:
return new Vector3(
(float)p.EvaluateNumericExpression(doo, X),
(float)p.EvaluateNumericExpression(doo, Y),
(float)p.EvaluateNumericExpression(doo, Z)
ofsx + (float)p.EvaluateNumericExpression(doo, X),
ofsy + (float)p.EvaluateNumericExpression(doo, Y),
ofsz + (float)p.EvaluateNumericExpression(doo, Z)
);
break;
case CoordinateTypeEnum.World:
return new Vector3(
(float)p.EvaluateNumericExpression(doo, X),
(float)p.EvaluateNumericExpression(doo, Y),
(float)p.EvaluateNumericExpression(doo, Z)
ofsx + (float)p.EvaluateNumericExpression(doo, X),
ofsy + (float)p.EvaluateNumericExpression(doo, Y),
ofsz + (float)p.EvaluateNumericExpression(doo, Z)
);
break;
case CoordinateTypeEnum.Entity:
Expand All @@ -73,17 +91,17 @@ internal Vector3 UnadjustedPosition(Plugin p)
if (go != null)
{
return new Vector3(
go.Position.X,
go.Position.Y,
go.Position.Z
ofsx + go.Position.X,
ofsy + go.Position.Y,
ofsz + go.Position.Z
);
}
else
{
return new Vector3(
(float)p.EvaluateNumericExpression(doo, X),
(float)p.EvaluateNumericExpression(doo, Y),
(float)p.EvaluateNumericExpression(doo, Z)
ofsx + (float)p.EvaluateNumericExpression(doo, X),
ofsy + (float)p.EvaluateNumericExpression(doo, Y),
ofsz + (float)p.EvaluateNumericExpression(doo, Z)
);
}
break;
Expand All @@ -95,7 +113,7 @@ internal Vector3 UnadjustedPosition(Plugin p)
Coordinate c = d.GetCoordinateByName(spl.Length > 1 ? spl[1] : "");
if (c != null)
{
return c.UnadjustedPosition(p);
return c.UntranslatedPosition(p);
}
}
return new Vector3();
Expand All @@ -104,9 +122,9 @@ internal Vector3 UnadjustedPosition(Plugin p)
if (wm != null && wm.Active == true)
{
return new Vector3(
wm.X_Float,
wm.Y_Float,
wm.Z_Float
ofsx + wm.X_Float,
ofsy + wm.Y_Float,
ofsz + wm.Z_Float
);
}
return new Vector3();
Expand All @@ -115,20 +133,33 @@ internal Vector3 UnadjustedPosition(Plugin p)

internal void RefreshVector(Plugin p)
{
ofsx = ofsy = ofsz = 0.0f;
if (OffsetX != "")
{
ofsx = (float)p.EvaluateNumericExpression(doo, OffsetX);
}
if (OffsetY != "")
{
ofsy = (float)p.EvaluateNumericExpression(doo, OffsetY);
}
if (OffsetZ != "")
{
ofsz = (float)p.EvaluateNumericExpression(doo, OffsetZ);
}
switch (ct)
{
case CoordinateTypeEnum.Screen:
cp = new Vector3(
(float)p.EvaluateNumericExpression(doo, X),
(float)p.EvaluateNumericExpression(doo, Y),
(float)p.EvaluateNumericExpression(doo, Z)
ofsx + (float)p.EvaluateNumericExpression(doo, X),
ofsy + (float)p.EvaluateNumericExpression(doo, Y),
ofsz + (float)p.EvaluateNumericExpression(doo, Z)
);
break;
case CoordinateTypeEnum.World:
cp = p.TranslateToScreen(
p.EvaluateNumericExpression(doo, X),
p.EvaluateNumericExpression(doo, Y),
p.EvaluateNumericExpression(doo, Z)
ofsx + p.EvaluateNumericExpression(doo, X),
ofsy + p.EvaluateNumericExpression(doo, Y),
ofsz + p.EvaluateNumericExpression(doo, Z)
);
break;
case CoordinateTypeEnum.Entity:
Expand All @@ -144,17 +175,17 @@ internal void RefreshVector(Plugin p)
if (go != null)
{
cp = p.TranslateToScreen(
go.Position.X,
go.Position.Y,
go.Position.Z
ofsx + go.Position.X,
ofsy + go.Position.Y,
ofsz + go.Position.Z
);
}
else
{
cp = p.TranslateToScreen(
p.EvaluateNumericExpression(doo, X),
p.EvaluateNumericExpression(doo, Y),
p.EvaluateNumericExpression(doo, Z)
ofsx + p.EvaluateNumericExpression(doo, X),
ofsy + p.EvaluateNumericExpression(doo, Y),
ofsz + p.EvaluateNumericExpression(doo, Z)
);
}
break;
Expand All @@ -166,11 +197,11 @@ internal void RefreshVector(Plugin p)
Coordinate c = d.GetCoordinateByName(spl.Length > 1 ? spl[1] : "");
if (c != null)
{
Vector3 uap = c.UnadjustedPosition(p);
Vector3 uap = c.UntranslatedPosition(p);
cp = p.TranslateToScreen(
uap.X,
uap.Y,
uap.Z
ofsx + uap.X,
ofsy + uap.Y,
ofsz + uap.Z
);
}
else
Expand All @@ -188,9 +219,9 @@ internal void RefreshVector(Plugin p)
if (wm != null && wm.Active == true)
{
cp = p.TranslateToScreen(
wm.X_Float,
wm.Y_Float,
wm.Z_Float
ofsx + wm.X_Float,
ofsy + wm.Y_Float,
ofsz + wm.Z_Float
);
}
else
Expand Down Expand Up @@ -225,6 +256,9 @@ internal void Initialize(Dictionary<string, object> d)
X = (d.ContainsKey("x") == true) ? d["x"].ToString() : "0";
Y = (d.ContainsKey("y") == true) ? d["y"].ToString() : "0";
Z = (d.ContainsKey("z") == true) ? d["z"].ToString() : "0";
OffsetX = (d.ContainsKey("offsetx") == true) ? d["offsetx"].ToString() : "";
OffsetY = (d.ContainsKey("offsety") == true) ? d["offsety"].ToString() : "";
OffsetZ = (d.ContainsKey("offsetz") == true) ? d["offsetz"].ToString() : "";
id = 0;
if (d.ContainsKey("id") == true)
{
Expand Down Expand Up @@ -264,15 +298,24 @@ internal enum ExpiryTypeEnum
internal string B { get; set; }
internal string A { get; set; }

abstract internal Coordinate GetCoordinateByName(string id);
internal virtual string DefaultR { get; } = "0";
internal virtual string DefaultG { get; } = "0";
internal virtual string DefaultB { get; } = "0";
internal virtual string DefaultA { get; } = "1";

abstract internal Coordinate GetCoordinateByName(string id);

public virtual void Dispose()
{
}

internal virtual void Initialize(Dictionary<string, object> d)
{
Name = d["name"].ToString();
R = (d.ContainsKey("r") == true) ? d["r"].ToString() : "0";
G = (d.ContainsKey("g") == true) ? d["g"].ToString() : "0";
B = (d.ContainsKey("b") == true) ? d["b"].ToString() : "0";
A = (d.ContainsKey("a") == true) ? d["a"].ToString() : "1";
R = (d.ContainsKey("r") == true) ? d["r"].ToString() : DefaultR;
G = (d.ContainsKey("g") == true) ? d["g"].ToString() : DefaultG;
B = (d.ContainsKey("b") == true) ? d["b"].ToString() : DefaultB;
A = (d.ContainsKey("a") == true) ? d["a"].ToString() : DefaultA;
if (d.ContainsKey("expireson") == true)
{
ExpiryTypeEnum nt = 0;
Expand Down Expand Up @@ -325,6 +368,9 @@ internal static Doodle Deserialize(Dictionary<string, object> d)
case "beam":
doo = new Doodles.Beam();
break;
case "image":
doo = new Doodles.Image();
break;
}
if (doo != null)
{
Expand Down
4 changes: 2 additions & 2 deletions Telesto/Doodles/Arrow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ internal override void Draw()
}
else
{
Vector3 tf = from.UnadjustedPosition(p);
Vector3 tt = to.UnadjustedPosition(p);
Vector3 tf = from.UntranslatedPosition(p);
Vector3 tt = to.UntranslatedPosition(p);
float distance = Vector3.Distance(tf, tt);
double anglexz = Math.Atan2(tf.Z - tt.Z, tf.X - tt.X);
float head = distance * 0.7f;
Expand Down
4 changes: 2 additions & 2 deletions Telesto/Doodles/Beam.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ internal override void Draw()
}
else
{
Vector3 tf = from.UnadjustedPosition(p);
Vector3 tt = at.UnadjustedPosition(p);
Vector3 tf = from.UntranslatedPosition(p);
Vector3 tt = at.UntranslatedPosition(p);
float distance = Vector3.Distance(tf, tt);
float length;
length = lengthchonk < 0.0 ? distance : lengthchonk;
Expand Down
2 changes: 1 addition & 1 deletion Telesto/Doodles/Circle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ internal override void Draw()
}
else
{
Vector3 temp = position.UnadjustedPosition(p);
Vector3 temp = position.UntranslatedPosition(p);
for (int i = 0; i <= 48; i++)
{
Vector3 mauw = p.TranslateToScreen(
Expand Down
Loading

0 comments on commit 951a845

Please sign in to comment.