Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ obj/
*.user


.vs/
Binary file added .vs/ProjectEvaluation/scuffedwalls.metadata.v2
Binary file not shown.
Binary file added .vs/ProjectEvaluation/scuffedwalls.projects.v2
Binary file not shown.
Binary file modified .vs/ScuffedWalls/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file not shown.
Empty file.
Binary file modified .vs/ScuffedWalls/v17/.futdcache.v1
Binary file not shown.
Binary file modified .vs/ScuffedWalls/v17/.suo
Binary file not shown.
54 changes: 19 additions & 35 deletions ScuffedWalls/Program/Functions/ModelToEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,26 @@ namespace ScuffedWalls.Functions
[SFunction("ModelToEnvironment")]
public class ModelToEnvironment : ScuffedFunction
{
//KDA VALUES GLOWLINE
//float scalerX = 30;
//float scalerY = 1.2f;
//float scalerZ = 30;
//float YOffset = 0f;
//float ZOffset = 1.1f;
//float XOffset = 0f;
//int Index = 31;
//REGEX @$"\[{Index}\]GlowLine \(2\)"
protected override void Update()
{
string Path = GetParam("path", DefaultValue: string.Empty, p => System.IO.Path.Combine(ScuffedWallsContainer.ScuffedConfig.MapFolderPath, p.RemoveWhiteSpace()));
Path = GetParam("fullpath", DefaultValue: Path, p => p);
float scalerX = GetParam("scalerx", 30, CustomDataParser.FloatConverter);
float scalerY = GetParam("scalerY", 1.2f, CustomDataParser.FloatConverter);
float scalerZ = GetParam("scalerZ", 30, CustomDataParser.FloatConverter);
float scalerX = GetParam("scalerX", 1, CustomDataParser.FloatConverter);
float scalerY = GetParam("scalerY", 1, CustomDataParser.FloatConverter);
float scalerZ = GetParam("scalerZ", 1, CustomDataParser.FloatConverter);
float YOffset = GetParam("YOffset", 0, CustomDataParser.FloatConverter);
float ZOffset = GetParam("ZOffset", 1.1f, CustomDataParser.FloatConverter);
float ZOffset = GetParam("ZOffset", 0, CustomDataParser.FloatConverter);
float XOffset = GetParam("XOffset", 0, CustomDataParser.FloatConverter);
int Index = GetParam("Index", 31, p => int.Parse(p));
int IndexFirstCloned = GetParam("IndexFirstCloned", 118, p => int.Parse(p));
string RegexStatement = GetParam("Regex", @$"GlowLine \(2\)", p => p);
string OuterRegexStatement = GetParam("OuterRegex", "", p => p);
string RegexStatement = GetParam("Regex", null, p => p);

Model model = new Model(Path);
if (RegexStatement is null)
{
ScuffedWalls.Print("Regex is required for ModelToEnvironment function! The function will not execute.", ScuffedWalls.LogSeverity.Error);
return;
}

// int Index = 31;
string IdRegex() => @$"{OuterRegexStatement}\[{Index}\]{RegexStatement}";
Model model = new Model(Path);

InstanceWorkspace.Environment.Add(new TreeDictionary()
{
[_id] = IdRegex() + "$",
[_lookupMethod] = "Regex",
[_duplicate] = model.Objects.Length
});
Index = IndexFirstCloned;
foreach (var cube in model.Objects)
{
Vector3 Scale = cube.Transformation.Scale;
Expand All @@ -56,23 +40,23 @@ protected override void Update()
Matrix4x4 Transform = cube.Matrix.Value.TransformLoc(new Vector3(0, -1f, 0));
Transformation DecomposedTransform = Transformation.fromMatrix(Transform);
DecomposedTransform.Position *= new Vector3(-1, 1, 1);
DecomposedTransform.Position += new Vector3(0, 0, ZOffset);
DecomposedTransform.Position += new Vector3(XOffset, YOffset, ZOffset);
DecomposedTransform.RotationEul *= new Vector3(1, -1, -1);


InstanceWorkspace.Environment.Add(new TreeDictionary()
{
[_id] = IdRegex() + @"\(Clone\)$",
[_id] = RegexStatement,
[_lookupMethod] = "Regex",
[_localPosition] = DecomposedTransform.Position.ToFloatArray(),
[_localRotation] = DecomposedTransform.RotationEul.ToFloatArray(),
[_scale] = Scale.ToFloatArray()
[_duplicate] = 1,
[_position] = DecomposedTransform.Position.ToFloatArray(),
[_rotation] = DecomposedTransform.RotationEul.ToFloatArray(),
[_scale] = Scale.ToFloatArray(),
[_track] = GetParam("track", null, p => (object)p),
[_active] = GetParam("active", null, p => (object)bool.Parse(p)),
});

Index++;

}
RegisterChanges("Duplications", model.Objects.Length);
}
}
}