diff --git a/NLua b/NLua deleted file mode 160000 index cdab112..0000000 --- a/NLua +++ /dev/null @@ -1 +0,0 @@ -Subproject commit cdab11261b858f4f47c1b1f17eafee44602c82ea diff --git a/NimbusFox.FoxCore.Client/ClientHook.cs b/NimbusFox.FoxCore.Client/ClientHook.cs index 3f88e92..28ded86 100644 --- a/NimbusFox.FoxCore.Client/ClientHook.cs +++ b/NimbusFox.FoxCore.Client/ClientHook.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Plukit.Base; +using Plukit.Base; using Staxel.Items; using Staxel.Logic; using Staxel.Modding; diff --git a/NimbusFox.FoxCore.Client/NimbusFox.FoxCore.Client.csproj b/NimbusFox.FoxCore.Client/NimbusFox.FoxCore.Client.csproj index de76f0e..9409c98 100644 --- a/NimbusFox.FoxCore.Client/NimbusFox.FoxCore.Client.csproj +++ b/NimbusFox.FoxCore.Client/NimbusFox.FoxCore.Client.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + latest pdbonly @@ -29,6 +30,7 @@ TRACE prompt 4 + latest @@ -39,26 +41,6 @@ C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.dll False - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.Auth.dll - False - - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.Checks.dll - False - - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.ToolUtilities.dll - False - - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.Trace.dll - False - - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.ValueSource.dll - False - False diff --git a/NimbusFox.FoxCore.Client/Properties/AssemblyInfo.cs b/NimbusFox.FoxCore.Client/Properties/AssemblyInfo.cs index f5c5d6a..fcfbe71 100644 --- a/NimbusFox.FoxCore.Client/Properties/AssemblyInfo.cs +++ b/NimbusFox.FoxCore.Client/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/NimbusFox.FoxCore.Client/Staxel/Builders/Logic/ParticleHostEntityLogic.cs b/NimbusFox.FoxCore.Client/Staxel/Builders/Logic/ParticleHostEntityLogic.cs index 7a275f6..8b73a8e 100644 --- a/NimbusFox.FoxCore.Client/Staxel/Builders/Logic/ParticleHostEntityLogic.cs +++ b/NimbusFox.FoxCore.Client/Staxel/Builders/Logic/ParticleHostEntityLogic.cs @@ -1,15 +1,10 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Plukit.Base; using Staxel; using Staxel.Core; using Staxel.Effects; using Staxel.Logic; using Staxel.Particles; -using Staxel.Tiles; namespace NimbusFox.FoxCore.Client.Staxel.Builders.Logic { public class ParticleHostEntityLogic : EntityLogic { diff --git a/NimbusFox.FoxCore.Client/Staxel/Builders/Painter/ParticleHostEntityPainter.cs b/NimbusFox.FoxCore.Client/Staxel/Builders/Painter/ParticleHostEntityPainter.cs index 405868e..29d2e35 100644 --- a/NimbusFox.FoxCore.Client/Staxel/Builders/Painter/ParticleHostEntityPainter.cs +++ b/NimbusFox.FoxCore.Client/Staxel/Builders/Painter/ParticleHostEntityPainter.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Plukit.Base; +using Plukit.Base; using Staxel; using Staxel.Client; -using Staxel.Core; using Staxel.Draw; using Staxel.Effects; using Staxel.Logic; diff --git a/NimbusFox.FoxCore.Client/Staxel/Builders/ParticleEntityBuilder.cs b/NimbusFox.FoxCore.Client/Staxel/Builders/ParticleEntityBuilder.cs index cb2d6a9..4889504 100644 --- a/NimbusFox.FoxCore.Client/Staxel/Builders/ParticleEntityBuilder.cs +++ b/NimbusFox.FoxCore.Client/Staxel/Builders/ParticleEntityBuilder.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NimbusFox.FoxCore.Client.Staxel.Builders.Logic; +using NimbusFox.FoxCore.Client.Staxel.Builders.Logic; using NimbusFox.FoxCore.Client.Staxel.Builders.Painter; using Staxel.Logic; diff --git a/NimbusFox.FoxCore.Tests/App.config b/NimbusFox.FoxCore.Tests/App.config index 88fa402..0954a28 100644 --- a/NimbusFox.FoxCore.Tests/App.config +++ b/NimbusFox.FoxCore.Tests/App.config @@ -1,6 +1,14 @@ - + + + + + + + + + \ No newline at end of file diff --git a/NimbusFox.FoxCore.Tests/NimbusFox.FoxCore.Tests.csproj b/NimbusFox.FoxCore.Tests/NimbusFox.FoxCore.Tests.csproj index 0d32ef7..34bacc2 100644 --- a/NimbusFox.FoxCore.Tests/NimbusFox.FoxCore.Tests.csproj +++ b/NimbusFox.FoxCore.Tests/NimbusFox.FoxCore.Tests.csproj @@ -53,6 +53,7 @@ + diff --git a/NimbusFox.FoxCore.Tests/Program.cs b/NimbusFox.FoxCore.Tests/Program.cs index 9a59e3d..7a01f86 100644 --- a/NimbusFox.FoxCore.Tests/Program.cs +++ b/NimbusFox.FoxCore.Tests/Program.cs @@ -1,15 +1,4 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NimbusFox.FoxCore.Managers; -using Plukit.Base; -using Staxel.FoxCore.Classes; -using Staxel.FoxCore.Managers; - -namespace NimbusFox.FoxCore.Tests { +namespace NimbusFox.FoxCore.Tests { class Program { // Writes blobs to files made from an object //static void Main(string[] args) { @@ -54,20 +43,20 @@ class Program { //} static void Main(string[] args) { - var dic = new Dictionary>(); - for (var i = 0; i < 10; i++) { - var list = new List(); - for (var j = 0; j < 10; j++) { - list.Add(Guid.NewGuid()); - } - dic.Add(Guid.NewGuid(), list); - } - - if (!Directory.Exists("./Results")) { - Directory.CreateDirectory("./Results"); - } - - File.WriteAllText($"./Results/{Guid.NewGuid().ToString()}.txt", FileManager.SerializeObject(dic)); + //var dic = new Dictionary>(); + //for (var i = 0; i < 10; i++) { + // var list = new List(); + // for (var j = 0; j < 10; j++) { + // list.Add(Guid.NewGuid()); + // } + // dic.Add(Guid.NewGuid(), list); + //} + + //if (!Directory.Exists("./Results")) { + // Directory.CreateDirectory("./Results"); + //} + + //File.WriteAllText($"./Results/{Guid.NewGuid().ToString()}.txt", FileManager.SerializeObject(dic)); } } } diff --git a/NimbusFox.FoxCore.Tests/Properties/AssemblyInfo.cs b/NimbusFox.FoxCore.Tests/Properties/AssemblyInfo.cs index cc24c25..fef5736 100644 --- a/NimbusFox.FoxCore.Tests/Properties/AssemblyInfo.cs +++ b/NimbusFox.FoxCore.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/NimbusFox.FoxCore.Tests/packages.config b/NimbusFox.FoxCore.Tests/packages.config new file mode 100644 index 0000000..0872bee --- /dev/null +++ b/NimbusFox.FoxCore.Tests/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/NimbusFox.FoxCore.VersionCheck/NimbusFox.FoxCore.VersionCheck.csproj b/NimbusFox.FoxCore.VersionCheck/NimbusFox.FoxCore.VersionCheck.csproj index 380e7ba..8afc89b 100644 --- a/NimbusFox.FoxCore.VersionCheck/NimbusFox.FoxCore.VersionCheck.csproj +++ b/NimbusFox.FoxCore.VersionCheck/NimbusFox.FoxCore.VersionCheck.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + latest pdbonly @@ -28,6 +29,7 @@ TRACE prompt 4 + latest diff --git a/NimbusFox.FoxCore.VersionCheck/Properties/AssemblyInfo.cs b/NimbusFox.FoxCore.VersionCheck/Properties/AssemblyInfo.cs index d2c88d4..a6c515b 100644 --- a/NimbusFox.FoxCore.VersionCheck/Properties/AssemblyInfo.cs +++ b/NimbusFox.FoxCore.VersionCheck/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/NimbusFox.FoxCore.VersionCheck/VersionCheck.cs b/NimbusFox.FoxCore.VersionCheck/VersionCheck.cs index fa30743..4354886 100644 --- a/NimbusFox.FoxCore.VersionCheck/VersionCheck.cs +++ b/NimbusFox.FoxCore.VersionCheck/VersionCheck.cs @@ -1,16 +1,14 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace NimbusFox.FoxCore.VersionCheck { public static class VersionCheck { private static string[] VersionToRemove => new [] { "NimbusFox.FoxCore.V1-20180228", - "NimbusFox.FoxCore.V1-20180226" + "NimbusFox.FoxCore.V1-20180226", + "NimbusFox.FoxCore.V1.2" }; public static void Check() { diff --git a/NimbusFox.FoxCore/Classes/CodeEntry.cs b/NimbusFox.FoxCore/Classes/CodeEntry.cs index 108788e..87c58c5 100644 --- a/NimbusFox.FoxCore/Classes/CodeEntry.cs +++ b/NimbusFox.FoxCore/Classes/CodeEntry.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NimbusFox.FoxCore.Classes { +namespace NimbusFox.FoxCore.Classes { public class CodeEntry { public readonly string Code; public readonly uint Rotation; diff --git a/NimbusFox.FoxCore/Classes/Converters.cs b/NimbusFox.FoxCore/Classes/Converters.cs index 97299d7..e3e1fd5 100644 --- a/NimbusFox.FoxCore/Classes/Converters.cs +++ b/NimbusFox.FoxCore/Classes/Converters.cs @@ -1,8 +1,7 @@ using System; using Plukit.Base; using Staxel.Core; -using Staxel.FoxCore; -using Staxel.FoxCore.Enums; +using NimbusFox.FoxCore.Enums; namespace NimbusFox.FoxCore { public static class Converters { diff --git a/NimbusFox.FoxCore/Classes/Delegates.cs b/NimbusFox.FoxCore/Classes/Delegates.cs new file mode 100644 index 0000000..245ba86 --- /dev/null +++ b/NimbusFox.FoxCore/Classes/Delegates.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plukit.Base; + +namespace NimbusFox.FoxCore.Delegates { + public delegate string Command(TStringArray array, TBlob blob, TClientServer clientServer, TICommands commandsApi, out TObjectArray objectArray); +} diff --git a/NimbusFox.FoxCore/Classes/Extensions.cs b/NimbusFox.FoxCore/Classes/Extensions.cs index 3b450e9..f9aac8d 100644 --- a/NimbusFox.FoxCore/Classes/Extensions.cs +++ b/NimbusFox.FoxCore/Classes/Extensions.cs @@ -2,12 +2,9 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Plukit.Base; -namespace Staxel.FoxCore.Classes { +namespace NimbusFox.FoxCore.Classes { public static class Extensions { public static void ObjectToBlob(this Blob blob, string key, object data) { @@ -245,6 +242,14 @@ private static object SetProcessProperty(Blob blob, string key, Type type, objec return Convert.ChangeType(blob.GetDouble(key), type); } + if (blob.KeyValueIteratable[key].Kind != BlobEntryKind.Blob) { + try { + return blob.GetString(key); + } catch { + return blob.GetBool(key); + } + } + Blob blob2; if (blob.TryGetBlob(key, out blob2)) { diff --git a/NimbusFox.FoxCore/Classes/UserCache.cs b/NimbusFox.FoxCore/Classes/UserCache.cs index 32f3342..048f688 100644 --- a/NimbusFox.FoxCore/Classes/UserCache.cs +++ b/NimbusFox.FoxCore/Classes/UserCache.cs @@ -1,10 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Staxel.FoxCore.Classes { +namespace NimbusFox.FoxCore.Classes { public class UserCache { public string DisplayName { get; set; } public string Uid { get; set; } diff --git a/NimbusFox.FoxCore/Classes/VectorCubeD.cs b/NimbusFox.FoxCore/Classes/VectorCubeD.cs index fa39a2d..dfd247c 100644 --- a/NimbusFox.FoxCore/Classes/VectorCubeD.cs +++ b/NimbusFox.FoxCore/Classes/VectorCubeD.cs @@ -1,6 +1,5 @@ using System; using Plukit.Base; -using Staxel.FoxCore; namespace NimbusFox.FoxCore.Classes { [Serializable] diff --git a/NimbusFox.FoxCore/Classes/VectorCubeI.cs b/NimbusFox.FoxCore/Classes/VectorCubeI.cs index 8e630cb..a92e0cc 100644 --- a/NimbusFox.FoxCore/Classes/VectorCubeI.cs +++ b/NimbusFox.FoxCore/Classes/VectorCubeI.cs @@ -1,6 +1,5 @@ using System; using Plukit.Base; -using Staxel.FoxCore; namespace NimbusFox.FoxCore.Classes { [Serializable] diff --git a/NimbusFox.FoxCore/Classes/VectorData.cs b/NimbusFox.FoxCore/Classes/VectorData.cs index 785b767..f7e7f68 100644 --- a/NimbusFox.FoxCore/Classes/VectorData.cs +++ b/NimbusFox.FoxCore/Classes/VectorData.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace NimbusFox.FoxCore.Classes { +namespace NimbusFox.FoxCore.Classes { public class VectorData { public string Code { get; set; } public uint Rotation { get; set; } diff --git a/NimbusFox.FoxCore/Classes/VectorFileData.cs b/NimbusFox.FoxCore/Classes/VectorFileData.cs index 4e866df..1431ab5 100644 --- a/NimbusFox.FoxCore/Classes/VectorFileData.cs +++ b/NimbusFox.FoxCore/Classes/VectorFileData.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using Plukit.Base; namespace NimbusFox.FoxCore.Classes { diff --git a/NimbusFox.FoxCore/Classes/VectoSquareI.cs b/NimbusFox.FoxCore/Classes/VectorSquareI.cs similarity index 100% rename from NimbusFox.FoxCore/Classes/VectoSquareI.cs rename to NimbusFox.FoxCore/Classes/VectorSquareI.cs diff --git a/NimbusFox.FoxCore/Classes/VoxelOutput.cs b/NimbusFox.FoxCore/Classes/VoxelOutput.cs index 7030e44..4ad1ec8 100644 --- a/NimbusFox.FoxCore/Classes/VoxelOutput.cs +++ b/NimbusFox.FoxCore/Classes/VoxelOutput.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NimbusFox.FoxCore.Classes; -using Staxel.Voxel; +using Staxel.Voxel; -namespace Staxel.FoxCore.Classes { +namespace NimbusFox.FoxCore.Classes { public class VoxelOutput { public VoxelObject Voxels { get; internal set; } public VectorFileData JsonData { get; internal set; } diff --git a/NimbusFox.FoxCore/Classes/Voxels.Core/MagicaVoxel.cs b/NimbusFox.FoxCore/Classes/Voxels.Core/MagicaVoxel.cs index e4e476f..c9f3f68 100644 --- a/NimbusFox.FoxCore/Classes/Voxels.Core/MagicaVoxel.cs +++ b/NimbusFox.FoxCore/Classes/Voxels.Core/MagicaVoxel.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Linq; namespace Voxels diff --git a/NimbusFox.FoxCore/Classes/Voxels.Core/MeshBuilder.cs b/NimbusFox.FoxCore/Classes/Voxels.Core/MeshBuilder.cs index c65ac3e..fee1a44 100644 --- a/NimbusFox.FoxCore/Classes/Voxels.Core/MeshBuilder.cs +++ b/NimbusFox.FoxCore/Classes/Voxels.Core/MeshBuilder.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace Voxels { public enum MeshType { diff --git a/NimbusFox.FoxCore/Classes/Voxels.Core/QbclFile.cs b/NimbusFox.FoxCore/Classes/Voxels.Core/QbclFile.cs index 8dc347e..1280af8 100644 --- a/NimbusFox.FoxCore/Classes/Voxels.Core/QbclFile.cs +++ b/NimbusFox.FoxCore/Classes/Voxels.Core/QbclFile.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Text; namespace Voxels { diff --git a/NimbusFox.FoxCore/CoreHook.cs b/NimbusFox.FoxCore/CoreHook.cs index 613be86..4a250b9 100644 --- a/NimbusFox.FoxCore/CoreHook.cs +++ b/NimbusFox.FoxCore/CoreHook.cs @@ -1,19 +1,11 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Windows.Forms; -using Microsoft.Xna.Framework; -using NimbusFox.FoxCore.Client.Staxel.Builders; -using NimbusFox.FoxCore.Client.Staxel.Builders.Logic; -using NimbusFox.FoxCore.VersionCheck; using Plukit.Base; +using NimbusFox.FoxCore.Forms; +using NimbusFox.FoxCore.Managers; using Staxel; -using Staxel.Collections; -using Staxel.Core; -using Staxel.Effects; -using Staxel.FoxCore.Forms; -using Staxel.FoxCore.Managers; +using Staxel.Commands; using Staxel.Items; using Staxel.Logic; using Staxel.Modding; @@ -23,7 +15,7 @@ namespace NimbusFox { public class CoreHook : IModHookV2 { internal static UserManager UserManager; - public static Universe Universe; + internal static Universe Universe; private static long _cacheTick; public void Dispose() { @@ -60,7 +52,9 @@ public void UniverseUpdateBefore(Universe universe, Timestep step) { _cacheTick = DateTime.Now.AddSeconds(30).Ticks; } } - public void UniverseUpdateAfter() { } + + public void UniverseUpdateAfter() { + } public bool CanPlaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { return true; } diff --git a/NimbusFox.FoxCore/Enums/Compass.cs b/NimbusFox.FoxCore/Enums/Compass.cs index b77e6c1..7b9acca 100644 --- a/NimbusFox.FoxCore/Enums/Compass.cs +++ b/NimbusFox.FoxCore/Enums/Compass.cs @@ -1,4 +1,4 @@ -namespace Staxel.FoxCore.Enums { +namespace NimbusFox.FoxCore.Enums { public enum Compass { NORTH, EAST, diff --git a/NimbusFox.FoxCore/FodyWeavers.xml b/NimbusFox.FoxCore/FodyWeavers.xml new file mode 100644 index 0000000..ebd4e33 --- /dev/null +++ b/NimbusFox.FoxCore/FodyWeavers.xml @@ -0,0 +1,31 @@ + + + + + Plukit.Base + Staxel + Simplex + Staxel.Auth + Staxel.Server + Staxel.Server.NoConsole + Newtonsoft.Json + LZ4Net + FNA + YarnSpinner + CefSharp + Steamworks.NET + Plukit.ReliableEndpoint + Staxel.Checks + Staxel.Trace + Staxel.ValueSource + Staxel.OggVorbis + Open.Nat + NetMQ + CefSharp.Core + NimbusFox.FoxCore.VersionCheck + Simplex + Staxel.Auth + NimbusFox.FoxCore.Client.V1 + + + \ No newline at end of file diff --git a/NimbusFox.FoxCore/Forms/ExceptionViewer.Designer.cs b/NimbusFox.FoxCore/Forms/ExceptionViewer.Designer.cs new file mode 100644 index 0000000..db99869 --- /dev/null +++ b/NimbusFox.FoxCore/Forms/ExceptionViewer.Designer.cs @@ -0,0 +1,77 @@ +namespace NimbusFox.FoxCore.Forms { + partial class ExceptionViewer { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) { + if (disposing && (components != null)) { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() { + this.txtException = new System.Windows.Forms.RichTextBox(); + this.btnOk = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtException + // + this.txtException.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtException.Location = new System.Drawing.Point(13, 12); + this.txtException.Name = "txtException"; + this.txtException.ReadOnly = true; + this.txtException.Size = new System.Drawing.Size(422, 272); + this.txtException.TabIndex = 0; + this.txtException.Text = ""; + // + // btnOk + // + this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.btnOk.Location = new System.Drawing.Point(13, 290); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(421, 23); + this.btnOk.TabIndex = 1; + this.btnOk.Text = "Confirm"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.btnOk_Click); + // + // ExceptionViewer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(447, 325); + this.ControlBox = false; + this.Controls.Add(this.btnOk); + this.Controls.Add(this.txtException); + this.Name = "ExceptionViewer"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "FoxCore Script Loader"; + this.TopMost = true; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.RichTextBox txtException; + private System.Windows.Forms.Button btnOk; + } +} \ No newline at end of file diff --git a/NimbusFox.FoxCore/Forms/ExceptionViewer.cs b/NimbusFox.FoxCore/Forms/ExceptionViewer.cs new file mode 100644 index 0000000..861cf21 --- /dev/null +++ b/NimbusFox.FoxCore/Forms/ExceptionViewer.cs @@ -0,0 +1,18 @@ +using System; +using System.Threading; +using System.Windows.Forms; + +namespace NimbusFox.FoxCore.Forms { + internal partial class ExceptionViewer : Form { + + internal ExceptionViewer(Exception exception, string mod) { + InitializeComponent(); + Text = @"FoxCore Script Loader - " + mod; + txtException.Text = $@"{exception.Message}{Environment.NewLine}{Environment.NewLine}{exception.StackTrace}"; + } + + private void btnOk_Click(object sender, EventArgs e) { + Close(); + } + } +} diff --git a/NimbusFox.FoxCore/Forms/ExceptionViewer.resx b/NimbusFox.FoxCore/Forms/ExceptionViewer.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/NimbusFox.FoxCore/Forms/ExceptionViewer.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/NimbusFox.FoxCore/Forms/VariantLoader.Designer.cs b/NimbusFox.FoxCore/Forms/VariantLoader.Designer.cs index e957686..b646f6d 100644 --- a/NimbusFox.FoxCore/Forms/VariantLoader.Designer.cs +++ b/NimbusFox.FoxCore/Forms/VariantLoader.Designer.cs @@ -1,4 +1,4 @@ -namespace Staxel.FoxCore.Forms { +namespace NimbusFox.FoxCore.Forms { partial class VariantLoader { /// /// Required designer variable. diff --git a/NimbusFox.FoxCore/Forms/VariantLoader.cs b/NimbusFox.FoxCore/Forms/VariantLoader.cs index 08a6eed..bce9e41 100644 --- a/NimbusFox.FoxCore/Forms/VariantLoader.cs +++ b/NimbusFox.FoxCore/Forms/VariantLoader.cs @@ -1,19 +1,14 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Diagnostics; -using System.Drawing; using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; +using NimbusFox.FoxCore.Managers; using Plukit.Base; using Staxel.Core; -using Staxel.FoxCore.Managers; +using Staxel; using Color = Microsoft.Xna.Framework.Color; -namespace Staxel.FoxCore.Forms { +namespace NimbusFox.FoxCore.Forms { public partial class VariantLoader : Form { private Dictionary> _colors; public VariantLoader() { @@ -32,7 +27,7 @@ private void CycleGetPalettes(DirectoryManager dir) { var current = blob.GetBlob(palette.Key); if (!_colors.ContainsKey(palette.Key)) { - _colors.Add(palette.Key, new Dictionary()); + _colors.Add(palette.Key, new Dictionary()); } foreach (var colorKey in current.KeyValueIteratable.Keys) { @@ -41,9 +36,7 @@ private void CycleGetPalettes(DirectoryManager dir) { if (!_colors[palette.Key].ContainsKey(colorK)) { _colors[palette.Key].Add(colorK, colorV); } - Application.DoEvents(); } - Application.DoEvents(); } wait = false; }, true); @@ -80,7 +73,6 @@ private void CycleGenerate(DirectoryManager dir) { foreach (var tile in tiles.KeyValueIteratable.Keys) { index++; - Application.DoEvents(); prgrssTileItems.Value = index; lblTileItem.Text = $@"{tile} ({index} of {total})"; @@ -123,7 +115,6 @@ private void CycleGenerate(DirectoryManager dir) { foreach (var item in items.KeyValueIteratable.Keys) { index++; - Application.DoEvents(); prgrssTileItems.Value = index; lblTileItem.Text = $@"{item} ({index} of {total})"; diff --git a/NimbusFox.FoxCore/Core.cs b/NimbusFox.FoxCore/FoxCore.cs similarity index 80% rename from NimbusFox.FoxCore/Core.cs rename to NimbusFox.FoxCore/FoxCore.cs index f1f10aa..3f8c5bb 100644 --- a/NimbusFox.FoxCore/Core.cs +++ b/NimbusFox.FoxCore/FoxCore.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; @@ -8,23 +7,22 @@ using NimbusFox.FoxCore.Managers; using NimbusFox.FoxCore.Managers.Particles; using Plukit.Base; -using Staxel.FoxCore.Managers; -using Staxel.FoxCore.Managers.Particles; using WorldManager = NimbusFox.FoxCore.Managers.WorldManager; namespace NimbusFox.FoxCore { public class Fox_Core { - public readonly ExceptionManager ExceptionManager; - [Obsolete("Please use the new DirectoryManager")] - public readonly FileManager FileManager; - public readonly WorldManager WorldManager; - public readonly ParticleManager ParticleManager; - public readonly EntityParticleManager EntityParticleManager; - public readonly EntityFollowParticleManager EntityFollowParticleManager; + public ExceptionManager ExceptionManager { get; } + public WorldManager WorldManager { get; } + [Obsolete("Can be buggy at times so will be removed in the next version")] + public ParticleManager ParticleManager { get; } + [Obsolete("Can be buggy at times so will be removed in the next version")] + public EntityParticleManager EntityParticleManager { get; } + [Obsolete("Can be buggy at times so will be removed in the next version")] + public EntityFollowParticleManager EntityFollowParticleManager { get; } // ReSharper disable once MemberCanBeMadeStatic.Global public UserManager UserManager => CoreHook.UserManager; - public readonly DirectoryManager DirectoryManager; - public readonly DirectoryManager ModDirectory; + public DirectoryManager SaveDirectory { get; } + public DirectoryManager ModDirectory { get; } /// /// @@ -33,13 +31,12 @@ public class Fox_Core { /// Must match your mod directory name /// public Fox_Core(string author, string mod, string modVersion) { - ExceptionManager = new ExceptionManager(author, mod, modVersion); - FileManager = new FileManager(author, mod); + ExceptionManager = new ExceptionManager(mod, modVersion); WorldManager = new WorldManager(); ParticleManager = new ParticleManager(); EntityParticleManager = new EntityParticleManager(); EntityFollowParticleManager = new EntityFollowParticleManager(); - DirectoryManager = new DirectoryManager(author, mod); + SaveDirectory = new DirectoryManager(author, mod); ModDirectory = new DirectoryManager(mod); VersionCheck.VersionCheck.Check(); } diff --git a/NimbusFox.FoxCore/Global.cs b/NimbusFox.FoxCore/Global.cs index 1c93f18..3ff572c 100644 --- a/NimbusFox.FoxCore/Global.cs +++ b/NimbusFox.FoxCore/Global.cs @@ -1,11 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Plukit.Base; - -namespace Staxel.FoxCore { +using Plukit.Base; + +namespace NimbusFox.FoxCore { internal static class Global { public static void Sort3D(Vector3D first, Vector3D second, out Vector3D start, out Vector3D end) { var startx = 0.0; diff --git a/NimbusFox.FoxCore/Interpreters/Classes/CContext.cs b/NimbusFox.FoxCore/Interpreters/Classes/CContext.cs new file mode 100644 index 0000000..7dee02b --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/Classes/CContext.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using Staxel; +using Staxel.Browser; +using Staxel.Client; +using Staxel.Input; +using Staxel.Items; +using Staxel.Mumble; +using Staxel.Particles; +using Staxel.Peripherals; +using Staxel.Player; +using Staxel.Rendering; +using Staxel.Sky; +using Staxel.Sound; +using Staxel.Steam; +using Staxel.Translation; +using Staxel.Weather; + +namespace NimbusFox.FoxCore.Interpreters.Classes { + internal class CContext { + public List SupportedResolutions => ClientContext.SupportedResolutions; + + public SteamManager SteamManager => ClientContext.SteamManager; + public PlayerFacade PlayerFacade => ClientContext.PlayerFacade; + public LastPlayedCharacterStorage LastPlayedCharacter => ClientContext.LastPlayedCharacter; + public UserInput UserInput => ClientContext.UserInput; + public OptionsStorage OptionsStorage => ClientContext.OptionsStorage; + public BrowserCore BrowserCore => ClientContext.BrowserCore; + public LocalServerManager LocalServerManager => ClientContext.LocalServerManager; + public InputSource InputSource => ClientContext.InputSource; + public ItemRendererManager ItemRendererManager => ClientContext.ItemRendererManager; + public LanguageDatabase LanguageDatabase => ClientContext.LanguageDatabase; + public WeatherRenderer WeatherRenderer => ClientContext.WeatherRenderer; + public LagThresholdEstimator ServerLagEstimator => ClientContext.ServerLagEstimator; + public SingleplayerWorldDatabase WorldDatabase => ClientContext.WorldDatabase; + public TextToSpeechDatabase TextToSpeechDatabase => ClientContext.TextToSpeechDatabase; + public PeripheralsManager PeripheralsManager => ClientContext.PeripheralsManager; + public MumblePositionalAudioProvider MumblePositionalAudioProvider => ClientContext.MumblePositionalAudioProvider; + public string[] NightTransitionTipCodes => ClientContext.NightTransitionTipCodes; + public OverlayController OverlayController => ClientContext.OverlayController; + public WebOverlayRenderer WebOverlayRenderer => ClientContext.WebOverlayRenderer; + public ChunkRenderer ChunkRenderer => ClientContext.ChunkRenderer; + public NameTagRenderer NameTagRenderer => ClientContext.NameTagRenderer; + public EntityRenderer EntityRenderer => ClientContext.EntityRenderer; + public OverlayRenderer OverlayRenderer => ClientContext.OverlayRenderer; + public UniverseRenderer UniverseRenderer => ClientContext.UniverseRenderer; + public GpuResources GpuResources => ClientContext.GpuResources; + public SoundManager SoundManager => ClientContext.SoundManager; + public ParticleManager ParticleManager => ClientContext.ParticleManager; + public OptionProcessor OptionProcessor => ClientContext.OptionProcessor; + public SkyBoxRenderer SkyBoxRenderer => ClientContext.SkyBoxRenderer; + public int ReloadRevision => ClientContext.ReloadRevision; + + public void CleanupOldSession() { + ClientContext.CleanupOldSession(); + } + + public void ClearCaches() { + ClientContext.ClearCaches(); + } + + public void Deinitialize(bool reload = false) { + ClientContext.Deinitialize(reload); + } + + public void Initialize(bool skipResourceInitializations, bool disableSteam, bool reload = false) { + ClientContext.Initialize(skipResourceInitializations, disableSteam, reload); + } + + public void Reload() { + ClientContext.Reload(); + } + + public void ResourceInitializations() { + ClientContext.ResourceIntializations(); + } + } +} diff --git a/NimbusFox.FoxCore/Interpreters/Classes/CommandBuilder.cs b/NimbusFox.FoxCore/Interpreters/Classes/CommandBuilder.cs new file mode 100644 index 0000000..00e9ffa --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/Classes/CommandBuilder.cs @@ -0,0 +1,18 @@ +using System; +using Plukit.Base; +using Staxel.Commands; +using Staxel.Server; + +namespace NimbusFox.FoxCore.Interpreters.Classes { + internal class CommandBuilder { + public Func Execute { get; set; } + + public string Usage { get; set; } + public bool Public { get; set; } + } + + internal class CommandOutput { + public string TranslationCode { get; set; } + public object[] ResponseParams { get; set; } + } +} diff --git a/NimbusFox.FoxCore/Interpreters/Classes/GContext.cs b/NimbusFox.FoxCore/Interpreters/Classes/GContext.cs new file mode 100644 index 0000000..83eed56 --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/Classes/GContext.cs @@ -0,0 +1,205 @@ +using System.Collections.Generic; +using Plukit.Base; +using Simplex; +using Staxel; +using Staxel.Achievements; +using Staxel.Behavior.Conversation; +using Staxel.Behavior.Conversation.DialogueCommands; +using Staxel.Characters; +using Staxel.Core; +using Staxel.Crafting; +using Staxel.Docks; +using Staxel.Draw; +using Staxel.Effects; +using Staxel.EntityActions; +using Staxel.Expressions; +using Staxel.FarmAnimals; +using Staxel.FarmAnimals.Pets; +using Staxel.Farming; +using Staxel.Gatherables; +using Staxel.Gfx; +using Staxel.Items; +using Staxel.Journal; +using Staxel.Lighting; +using Staxel.Logic; +using Staxel.Mail; +using Staxel.Merchants; +using Staxel.Modding; +using Staxel.Notifications; +using Staxel.Particles; +using Staxel.Rendering; +using Staxel.Rendering.Palettes; +using Staxel.Sound; +using Staxel.Tiles; +using Staxel.TileStates; +using Staxel.TileStates.Totems; +using Staxel.Treasures; +using Staxel.ValueImage; +using Staxel.Weather; +using Staxel.WorldGen.Biomes; +using Staxel.WorldGen.Structures; + +namespace NimbusFox.FoxCore.Interpreters.Classes { + internal class GContext { + public NoiseSource StableNoiseSource { + get => GameContext.StableNoiseSource; + set => GameContext.StableNoiseSource = value; + } + + public DeterministicRandom RandomSource { + get => GameContext.RandomSource; + set => GameContext.RandomSource = value; + } + + public DebugGraphics DebugGraphics { + get => GameContext.DebugGraphics; + set => GameContext.DebugGraphics = value; + } + + + public TileConfigurationHolder[] TileMapping { + get => GameContext.TileMapping; + set => GameContext.TileMapping = value; + } + + public bool[] SolidTileMapping { + get => GameContext.SolidTileMapping; + set => GameContext.SolidTileMapping = value; + } + + public bool Revalidate { + get => GameContext.Revalidate; + set => GameContext.Revalidate = value; + } + + public bool StoreBundle { + get => GameContext.StoreBundle; + set => GameContext.StoreBundle = value; + } + + public int ReloadRevision { + get => GameContext.ReloadRevision; + set => GameContext.ReloadRevision = value; + } + + public bool ResourcesInitialised { + get => GameContext.ResourcesInitialised; + set => GameContext.ResourcesInitialised = value; + } + + public AssetBundleManager AssetBundleManager => GameContext.AssetBundleManager; + + public ContentLoader ContentLoader => GameContext.ContentLoader; + + public ResourceManager Resources => GameContext.Resources; + + public WorkerManager Worker => GameContext.Worker; + + public EntityFactory EntityFactory => GameContext.EntityFactory; + + public GraphicalContextFlag GraphicalContextFlag => GameContext.GraphicalContextFlag; + + public ColorCorrectionDatabase ColorCorrectionDatabase => GameContext.ColorCorrectionDatabase; + + public ParticleDatabase ParticleDatabase => GameContext.ParticleDatabase; + + public DockDatabase DockDatabase => GameContext.DockDatabase; + + public TileDatabase TileDatabase => GameContext.TileDatabase; + + public ItemDatabase ItemDatabase => GameContext.ItemDatabase; + + public CategoryDatabase CategoryDatabase => GameContext.CategoryDatabase; + + public AchievementDatabase AchievementDatabase => GameContext.AchievementDatabase; + + public AnimationDatabase AnimationDatabase => GameContext.AnimationDatabase; + + public SoundDatabase SoundDatabase => GameContext.SoundDatabase; + + public SystemStatus SystemStatus => GameContext.SystemStatus; + + public PlantDatabase PlantDatabase => GameContext.PlantDatabase; + + public ReactionDatabase ReactionDatabase => GameContext.ReactionDatabase; + + public RecipeDatabase RecipeDatabase => GameContext.RecipeDatabase; + + public FarmingDatabase FarmingDatabase => GameContext.FarmingDatabase; + + public GatheringDatabase GatheringDatabase => GameContext.GatheringDatabase; + + public EmoteDatabase EmoteDatabase => GameContext.EmoteDatabase; + + public LightingWorker LightingWorker => GameContext.LightingWorker; + + public StructureDatabase StructureDatabase => GameContext.StructureDatabase; + + public BiomeDatabase BiomeDatabase => GameContext.BiomeDatabase; + + public ExpressionDatabase ExpressionDatabase => GameContext.ExpressionDatabase; + + public EntityActionDatabase EntityActionDatabase => GameContext.EntityActionDatabase; + + public EffectDatabase EffectDatabase => GameContext.EffectDatabase; + + public PaletteDatabase PaletteDatabase => GameContext.PaletteDatabase; + + public CharacterDesignDatabase CharacterDesignDatabase => GameContext.CharacterDesignDatabase; + + public TileStateDatabase TileStateDatabase => GameContext.TileStateDatabase; + + public TreasureDatabase TreasureDatabase => GameContext.TreasureDatabase; + + public ModdingController ModdingController => GameContext.ModdingController; + + public FarmAnimalBehaviourDatabase FarmAnimalBehaviourDatabase => GameContext.FarmAnimalBehaviourDatabase; + + public FarmAnimalDatabase FarmAnimalDatabase => GameContext.FarmAnimalDatabase; + + public MerchantDatabase MerchantDatabase => GameContext.MerchantDatabase; + + public WeatherDatabase WeatherDatabase => GameContext.WeatherDatabase; + + public NotificationDatabase NotificationDatabase => GameContext.NotificationDatabase; + + public PetDatabase PetDatabase => GameContext.PetDatabase; + + public TotemDatabase TotemDatabase => GameContext.TotemDatabase; + + public DialogueCommandsManager DialogueCommandsManager => GameContext.DialogueCommandsManager; + + public DialogueDatabase DialogueDatabase => GameContext.DialogueDatabase; + + public ValueImageDatabase ValueImageDatabase => GameContext.ValueImageDatabase; + + public MailDatabase MailDatabase => GameContext.MailDatabase; + + public JournalQuestDatabase JournalQuestDatabase => GameContext.JournalQuestDatabase; + + public Dictionary GeneralComponentBuilders => GameContext.GeneralComponentBuilders; + + public Dictionary ItemComponentBuilders => GameContext.ItemComponentBuilders; + + public Dictionary TileComponentBuilders => GameContext.TileComponentBuilders; + + public Dictionary WeatherComponentBuilders => + GameContext.WeatherComponentBuilders; + + public void ContentPath(string storageName, out string fullContentRootPath, out string fullStoragePath) { + GameContext.ContentPath(storageName, out fullContentRootPath, out fullStoragePath); + } + + public void Initialize(GameContextInitFlags flags, string storageName) { + GameContext.Initialize(flags, storageName); + } + + public void ResourceInitializations(bool revalidate, bool client, bool storeBundle) { + GameContext.ResourceInitializations(revalidate, client, storeBundle); + } + + public void Deinitialize(bool reload = false) { + GameContext.Deinitialize(reload); + } + } +} diff --git a/NimbusFox.FoxCore/Interpreters/Classes/SContext.cs b/NimbusFox.FoxCore/Interpreters/Classes/SContext.cs new file mode 100644 index 0000000..b1537d3 --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/Classes/SContext.cs @@ -0,0 +1,42 @@ +using Staxel; +using System.Collections.Generic; +using Plukit.Base; +using Staxel.Activities; +using Staxel.Behavior; +using Staxel.Commands; +using Staxel.EntityStorage; +using Staxel.Festivals; +using Staxel.Rights; +using Staxel.Server; +using Staxel.Storage; +using Staxel.TileBlobStorage; + +namespace NimbusFox.FoxCore.Interpreters.Classes { + internal class SContext { + public static ScriptDatabase ScriptDatabase => ServerContext.ScriptDatabase; + public static StatisticsMonitor Statistics => ServerContext.Statistics; + public static VillageDirector VillageDirector => ServerContext.VillageDirector; + public static FestivalDatabase FestivalDatabase => ServerContext.FestivalDatabase; + public static VillagerDefinitionDatabase VillagerDefinitionDatabase => ServerContext.VillagerDefinitionDatabase; + public static VillagerLogicDatabase VillagerLogicDatabase => ServerContext.VillagerLogicDatabase; + public static VillagerJobDatabase VillagerJobDatabase => ServerContext.VillagerJobDatabase; + public static VillagerPersonalityDatabase VillagerPersonalityDatabase => ServerContext.VillagerPersonalityDatabase; + public static Dictionary QuestDefBuilders => ServerContext.QuestDefBuilders; + public static int ReloadRevision => ServerContext.ReloadRevision; + public static DirectorFacade DirectorFacade => ServerContext.DirectorFacade; + public static EntityBlobDatabase EntityBlobDatabase => ServerContext.EntityBlobDatabase; + public static TileBlobDatabase TileBlobDatabase => ServerContext.TileBlobDatabase; + public static ChunkActivityDatabase ChunkActivityDatabase => ServerContext.ChunkActivityDatabase; + public static CommandsManager CommandsManager => ServerContext.CommandsManager; + public static RightsManager RightsManager => ServerContext.RightsManager; + public static BlobStorage BlobStorage => ServerContext.BlobStorage; + + public void Deinitialize() { + ServerContext.Deinitialize(); + } + + public void Initialize(bool startDatabase, bool revalidate, string storageName) { + ServerContext.Initialize(startDatabase, revalidate, storageName); + } + } +} diff --git a/NimbusFox.FoxCore/Interpreters/CoreInt.cs b/NimbusFox.FoxCore/Interpreters/CoreInt.cs new file mode 100644 index 0000000..89607e9 --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/CoreInt.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NimbusFox.FoxCore.Interpreters.Classes; +using NimbusFox.FoxCore.Managers; +using Plukit.Base; +using Staxel.Items; +using Staxel.Logic; +using Staxel.Tiles; + +namespace NimbusFox.FoxCore.Interpreters { + //internal class CoreInt { + // protected string script = ""; + // internal DirectoryManager Directory; + // internal ExceptionManager ExceptionManager; + // internal bool Debug = false; + + // protected void ParseScripts(string ext, DirectoryManager currentDir) { + // foreach (var dir in currentDir.Directories.Select(currentDir.FetchDirectory)) { + // ParseScripts(ext, dir); + // } + + // foreach (var file in currentDir.Files.Where(f => f.Contains(ext))) { + // var wait = true; + // currentDir.ReadFile(file, code => { + // script += Environment.NewLine + code; + // wait = false; + // }, true); + + // while (wait) { } + // } + // } + + // public virtual void AddCommand(string command, CommandBuilder obj) { + // if (CoreIntMods.Commands.ContainsKey(command)) { + // throw new Exception("A command with this command call already exists"); + // } + + // CoreIntMods.Commands.Add(command, obj); + // } + + // public virtual void Dispose() { } + // public virtual void GameContextInitializeInit() { } + // public virtual void GameContextInitializeBefore() { } + // public virtual void GameContextInitializeAfter() { } + // public virtual void GameContextDeinitialize() { } + // public virtual void GameContextReloadBefore() { } + // public virtual void GameContextReloadAfter() { } + // public virtual void UniverseUpdateBefore(Universe universe, Timestep step) { } + // public virtual void UniverseUpdateAfter() { } + // public virtual bool CanPlaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { + // return true; + // } + + // public virtual bool CanReplaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { + // return true; + // } + + // public virtual bool CanRemoveTile(Entity entity, Vector3I location, TileAccessFlags accessFlags) { + // return true; + // } + + // public virtual void ClientContextInitializeInit() { } + // public virtual void ClientContextInitializeBefore() { } + // public virtual void ClientContextInitializeAfter() { } + // public virtual void ClientContextDeinitialize() { } + // public virtual void ClientContextReloadBefore() { } + // public virtual void ClientContextReloadAfter() { } + // public virtual void CleanupOldSession() { } + // public virtual bool CanInteractWithTile(Entity entity, Vector3F location, Tile tile) { + // return true; + // } + + // public virtual bool CanInteractWithEntity(Entity entity, Entity lookingAtEntity) { + // return true; + // } + //} +} diff --git a/NimbusFox.FoxCore/Interpreters/CoreIntMods.cs b/NimbusFox.FoxCore/Interpreters/CoreIntMods.cs new file mode 100644 index 0000000..a99562b --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/CoreIntMods.cs @@ -0,0 +1,453 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Threading; +using System.Windows.Forms; +using NimbusFox.FoxCore.Forms; +using NimbusFox.FoxCore.Interpreters.Classes; +using NimbusFox.FoxCore.Managers; +using Plukit.Base; +using Staxel; +using Staxel.Commands; +using Staxel.Items; +using Staxel.Logic; +using Staxel.Modding; +using Staxel.Server; +using Staxel.Tiles; + +namespace NimbusFox.FoxCore.Interpreters { + /*public class CoreIntMods : IModHookV3 { + internal static List IntMods = new List(); + internal static bool AllowDebug = true; + internal static readonly Dictionary Commands = new Dictionary(); + private static bool ScriptsLoaded; + + public CoreIntMods() { + new Thread(() => { + while (ServerContext.CommandsManager == null) { + + } + + ServerContextInitializeAfter(); + }).Start(); + } + + public static void ServerContextInitializeAfter() { + if (ServerContext.CommandsManager != null) { + var commandDic = (Dictionary)ServerContext.CommandsManager.GetType() + .GetField("_commandBuilders", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) + ?.GetValue(ServerContext.CommandsManager); + + if (commandDic != null) { + foreach (var command in Commands) { + var commandC = new ScriptCommand { + Kind = command.Key, + Usage = command.Value.Usage, + Public = command.Value.Public, + Command = (string[] array, Blob blob, ClientServerConnection server, ICommandsApi api, + out object[] objectArray) => { + var output = command.Value.Execute(array, blob, server, api); + + objectArray = output.ResponseParams; + return output.TranslationCode; + } + }; + commandDic.Add(command.Key, commandC); + } + } + } + } + + public void Dispose() { + foreach (var mod in IntMods) { + mod.Dispose(); + } + + Commands.Clear(); + AllowDebug = true; + ScriptsLoaded = false; + } + + public void GameContextInitializeInit() { + foreach (var mod in IntMods) { + try { + mod.GameContextInitializeInit(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + + public void GameContextInitializeBefore() { + foreach (var mod in IntMods) { + try { + mod.GameContextInitializeBefore(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + + internal static void ReloadMods(bool reload = false) { + foreach (var mod in IntMods) { + mod.Dispose(); + } + + if (ServerContext.CommandsManager != null) { + var commandDic = (Dictionary) ServerContext.CommandsManager.GetType() + .GetField("_commandBuilders", + BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static) + .GetValue(ServerContext.CommandsManager); + + if (commandDic != null) { + foreach (var command in Commands) { + commandDic.Remove(command.Key); + } + } + } + + Commands.Clear(); + + IntMods.Clear(); + AllowDebug = true; + + var modDir = new DirectoryManager().FetchDirectory("mods"); + + var debugMods = new List(); + + foreach (var dir in modDir.Directories.Select(dir => modDir.FetchDirectory(dir))) { + if (dir.FileExists("fxCode.json")) { + var wait = true; + dir.ReadFile("fxCode.json", data => { + var debug = false; + if (!data.Contains("debug")) { + AllowDebug = false; + } else { + debug = data.GetBool("debug", false); + if (debug) { + debugMods.Add(dir.Folder); + } else { + AllowDebug = false; + } + } + + if (data.Contains("language")) { + try { + CoreInt currentMod; + switch (data.GetString("language", null)?.ToLower()) { + case "js": + case "javascript": + currentMod = new JSInt(dir, debug); + IntMods.Add(currentMod); + break; + case "lua": + currentMod = new LuaInt(dir, debug); + IntMods.Add(currentMod); + break; + } + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + if (debug) { + Application.Run(new ExceptionViewer(new Exception($"{dir.Folder} was not loaded due to the following error:\n\nParse Error: {ex.Message}", ex), dir.Folder)); + } + } + } + + wait = false; + }, true); + + while (wait) { } + } + } + + if (!AllowDebug && debugMods.Any() && !reload) { + Application.Run(new ExceptionViewer( + new Exception( + $"You are currently running non compiled scripts which can be dangerous. Please get in touch with the mod creators to get their scripts compiled.\n\nThe following mods are not compiled:\n\n{string.Join("\n", debugMods)}"), + "Fox Core")); + } + + foreach (var mod in IntMods) { + try { + mod.GameContextInitializeAfter(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + + if (reload) { + ServerContextInitializeAfter(); + } + } + + public void GameContextInitializeAfter() { + if (!ScriptsLoaded) { + + ReloadMods(); + + ScriptsLoaded = true; + } else { + foreach (var mod in IntMods) { + try { + mod.GameContextInitializeAfter(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + + } + public void GameContextDeinitialize() { + foreach (var mod in IntMods) { + try { + mod.GameContextDeinitialize(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void GameContextReloadBefore() { + foreach (var mod in IntMods) { + try { + mod.GameContextReloadBefore(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void GameContextReloadAfter() { + foreach (var mod in IntMods) { + try { + mod.GameContextReloadAfter(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void UniverseUpdateBefore(Universe universe, Timestep step) { + foreach (var mod in IntMods) { + try { + mod.UniverseUpdateBefore(universe, step); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void UniverseUpdateAfter() { + foreach (var mod in IntMods) { + try { + mod.UniverseUpdateAfter(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public bool CanPlaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { + var result = true; + foreach (var mod in IntMods) { + try { + result &= mod.CanPlaceTile(entity, location, tile, accessFlags); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + return result; + } + + public bool CanReplaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { + var result = true; + foreach (var mod in IntMods) { + try { + result &= mod.CanReplaceTile(entity, location, tile, accessFlags); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + return result; + } + + public bool CanRemoveTile(Entity entity, Vector3I location, TileAccessFlags accessFlags) { + var result = true; + foreach (var mod in IntMods) { + try { + result &= mod.CanRemoveTile(entity, location, accessFlags); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + return result; + } + + public void ClientContextInitializeInit() { + foreach (var mod in IntMods) { + try { + mod.ClientContextInitializeInit(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void ClientContextInitializeBefore() { + foreach (var mod in IntMods) { + try { + mod.ClientContextInitializeBefore(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void ClientContextInitializeAfter() { + foreach (var mod in IntMods) { + try { + mod.ClientContextInitializeAfter(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void ClientContextDeinitialize() { + foreach (var mod in IntMods) { + try { + mod.ClientContextDeinitialize(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void ClientContextReloadBefore() { + foreach (var mod in IntMods) { + try { + mod.ClientContextReloadBefore(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void ClientContextReloadAfter() { + foreach (var mod in IntMods) { + try { + mod.ClientContextReloadAfter(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public void CleanupOldSession() { + foreach (var mod in IntMods) { + try { + mod.CleanupOldSession(); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + } + public bool CanInteractWithTile(Entity entity, Vector3F location, Tile tile) { + var result = true; + foreach (var mod in IntMods) { + try { + result &= mod.CanInteractWithTile(entity, location, tile); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + return result; + } + + public bool CanInteractWithEntity(Entity entity, Entity lookingAtEntity) { + var result = true; + foreach (var mod in IntMods) { + try { + result &= mod.CanInteractWithEntity(entity, lookingAtEntity); + } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { + mod.ExceptionManager.HandleException(ex); + + if (mod.Debug) { + Application.Run(new ExceptionViewer(ex, mod.Directory.Folder)); + } + } + } + return result; + } + }*/ +} diff --git a/NimbusFox.FoxCore/Interpreters/JSInt.cs b/NimbusFox.FoxCore/Interpreters/JSInt.cs new file mode 100644 index 0000000..5c29d39 --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/JSInt.cs @@ -0,0 +1,328 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Windows.Forms; +//using Jint; +//using Jint.Native; +//using Jint.Parser; +//using Jint.Runtime; +//using Jint.Runtime.Interop; +//using NimbusFox.FoxCore.Forms; +//using NimbusFox.FoxCore.Interpreters.Classes; +//using NimbusFox.FoxCore.Managers; +//using Plukit.Base; +//using Staxel.Items; +//using Staxel.Logic; +//using Staxel.Tiles; + +//namespace NimbusFox.FoxCore.Interpreters { +// internal class JSInt : CoreInt { +// private readonly Engine _jsEngine; +// public JSInt(DirectoryManager directory, bool debug) { +// Debug = debug; + +// Directory = directory; + +// ExceptionManager = new ExceptionManager(directory.Folder, "null"); + +// _jsEngine = new Engine(clr => { +// clr.CatchClrExceptions(exception => { +// ExceptionManager.HandleException(exception); +// return true; +// }); + +// clr.LimitRecursion(10); +// }); + +// ParseScripts(".js.code", directory); + +// _jsEngine.SetValue("log", new Action(Logger.WriteLine)); +// _jsEngine.SetValue("Fox_Core", TypeReference.CreateTypeReference(_jsEngine, typeof(Fox_Core))); +// _jsEngine.SetValue("GameContext", new GContext()); +// _jsEngine.SetValue("ClientContext", new CContext()); +// _jsEngine.SetValue("ServerContext", new SContext()); +// _jsEngine.SetValue("RegisterCommand", new Action(AddCommand)); + +// _jsEngine.Execute(script); + +// Directory._jsEngine = _jsEngine; +// } + +// private void AddCommand(string command, JsValue obj) { +// var location = _jsEngine.GetLastSyntaxNode().Location.Start.Line - 1; +// try { +// var commandBuilder = new CommandBuilder(); + +// if (!obj.IsObject()) { +// throw new JavaScriptException(_jsEngine.Error, "2nd Argument must be an object at line " + location); +// } + +// var dataObj = obj.AsObject(); + +// if (!dataObj.HasProperty("execute")) { +// throw new JavaScriptException(_jsEngine.Error, +// "Object must have the property \"execute\" as function at line " + location); +// } + +// if (dataObj.Get("execute").IsUndefined() || !dataObj.Get("execute").IsObject()) { +// throw new JavaScriptException(_jsEngine.Error, "execute must have a value of function at line " + location); +// } + +// commandBuilder.Execute = (bits, blob, connection, api) => { +// var jsBits = JsValue.FromObject(_jsEngine, bits); +// var jsBlob = JsValue.FromObject(_jsEngine, blob); +// var jsConnection = JsValue.FromObject(_jsEngine, connection); +// var jsApi = JsValue.FromObject(_jsEngine, api); +// var output = dataObj.Get("execute").Invoke(jsBits, jsBlob, jsConnection, jsApi); + +// if (!output.IsObject()) { +// throw new JavaScriptException(_jsEngine.Error, +// "execute must return an object containing \"translationCode\" and \"resonseParams\" properties at line " + location); +// } + +// var cOutput = new CommandOutput(); + +// var oObj = output.AsObject(); + +// if (oObj.Get("responseParams").IsUndefined() || !oObj.Get("responseParams").IsArray()) { +// cOutput.ResponseParams = new object[0]; +// } else { +// cOutput.ResponseParams = oObj.Get("responseParams").AsArray().GetOwnProperties() +// .Select(property => property.Value.Value.ToObject()).ToArray(); +// } + +// if (oObj.Get("translationCode").IsUndefined()) { +// throw new JavaScriptException(_jsEngine.Error, +// "execute must return an object with a \"translationCode\" at line " + location); +// } + +// cOutput.TranslationCode = oObj.Get("translationCode").AsString(); + +// return cOutput; +// }; + +// if (dataObj.Get("usage").IsUndefined() || !dataObj.Get("usage").IsString()) { +// throw new JavaScriptException(_jsEngine.Error, "Object must have the property \"usage\" as string at line " + location); +// } + +// commandBuilder.Usage = dataObj.Get("usage").AsString(); + +// if (dataObj.Get("public").IsUndefined() || !dataObj.Get("public").IsBoolean()) { + +// throw new JavaScriptException(_jsEngine.Error, "Object must have the property \"public\" as bool at line " + location); +// } + +// commandBuilder.Public = dataObj.Get("public").AsBoolean(); + +// AddCommand(command, commandBuilder); +// } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { +// ExceptionManager.HandleException(ex); + +// if (Debug) { +// Application.Run(new ExceptionViewer(ex, Directory.Folder)); +// } +// } +// } + +// public override void GameContextInitializeInit() { +// var function = _jsEngine.GetValue("gameContextInitializeInit"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void GameContextInitializeBefore() { +// var function = _jsEngine.GetValue("gameContextInitializeBefore"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void GameContextInitializeAfter() { +// var function = _jsEngine.GetValue("gameContextInitializeAfter"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void GameContextDeinitialize() { +// var function = _jsEngine.GetValue("gameContextDeinitialize"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void GameContextReloadBefore() { +// var function = _jsEngine.GetValue("gameContextReloadBefore"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void GameContextReloadAfter() { +// var function = _jsEngine.GetValue("gameContextReloadAfter"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void UniverseUpdateBefore(Universe universe, Timestep step) { +// var function = _jsEngine.GetValue("universeUpdateBefore"); + +// if (!function.IsUndefined()) { +// function.Invoke(JsValue.FromObject(_jsEngine, universe), JsValue.FromObject(_jsEngine, step)); +// } +// } + +// public override void UniverseUpdateAfter() { +// var function = _jsEngine.GetValue("universeUpdateAfter"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override bool CanPlaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { +// var function = _jsEngine.GetValue("canPlaceTile"); + +// if (!function.IsUndefined()) { +// var result = function.Invoke( +// JsValue.FromObject(_jsEngine, entity), +// JsValue.FromObject(_jsEngine, location), +// JsValue.FromObject(_jsEngine, tile), +// JsValue.FromObject(_jsEngine, accessFlags)); + +// if (result.IsBoolean()) { +// return result.AsBoolean(); +// } +// } +// return true; +// } + +// public override bool CanReplaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { +// var function = _jsEngine.GetValue("canReplaceTile"); + +// if (!function.IsUndefined()) { +// var result = function.Invoke( +// JsValue.FromObject(_jsEngine, entity), +// JsValue.FromObject(_jsEngine, location), +// JsValue.FromObject(_jsEngine, tile), +// JsValue.FromObject(_jsEngine, accessFlags)); + +// if (result.IsBoolean()) { +// return result.AsBoolean(); +// } +// } +// return true; +// } + +// public override bool CanRemoveTile(Entity entity, Vector3I location, TileAccessFlags accessFlags) { +// var function = _jsEngine.GetValue("canRemoveTile"); + +// if (!function.IsUndefined()) { +// var result = function.Invoke( +// JsValue.FromObject(_jsEngine, entity), +// JsValue.FromObject(_jsEngine, location), +// JsValue.FromObject(_jsEngine, accessFlags)); + +// if (result.IsBoolean()) { +// return result.AsBoolean(); +// } +// } +// return true; +// } + +// public override void ClientContextInitializeInit() { +// var function = _jsEngine.GetValue("clientContextInitializeInit"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void ClientContextInitializeBefore() { +// var function = _jsEngine.GetValue("clientContextInitializeBefore"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void ClientContextInitializeAfter() { +// var function = _jsEngine.GetValue("clientContextInitializeAfter"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void ClientContextDeinitialize() { +// var function = _jsEngine.GetValue("clientContextDeinitialize"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void ClientContextReloadBefore() { +// var function = _jsEngine.GetValue("clientContextReloadBefore"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void ClientContextReloadAfter() { +// var function = _jsEngine.GetValue("clientContextReloadAfter"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override void CleanupOldSession() { +// var function = _jsEngine.GetValue("cleanupOldSession"); + +// if (!function.IsUndefined()) { +// function.Invoke(); +// } +// } + +// public override bool CanInteractWithTile(Entity entity, Vector3F location, Tile tile) { +// var function = _jsEngine.GetValue("canInteractWithTile"); + +// if (!function.IsUndefined()) { +// var result = function.Invoke( +// JsValue.FromObject(_jsEngine, entity), +// JsValue.FromObject(_jsEngine, location), +// JsValue.FromObject(_jsEngine, tile)); + +// if (result.IsBoolean()) { +// return result.AsBoolean(); +// } +// } +// return true; +// } + +// public override bool CanInteractWithEntity(Entity entity, Entity lookingAtEntity) { +// var function = _jsEngine.GetValue("canInteractWithEntity"); + +// if (!function.IsUndefined()) { +// var result = function.Invoke( +// JsValue.FromObject(_jsEngine, entity), +// JsValue.FromObject(_jsEngine, lookingAtEntity)); + +// if (result.IsBoolean()) { +// return result.AsBoolean(); +// } +// } +// return true; +// } +// } +//} diff --git a/NimbusFox.FoxCore/Interpreters/LuaInt.cs b/NimbusFox.FoxCore/Interpreters/LuaInt.cs new file mode 100644 index 0000000..7018da8 --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/LuaInt.cs @@ -0,0 +1,309 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Windows.Forms; +//using Neo.IronLua; +//using NimbusFox.FoxCore.Forms; +//using NimbusFox.FoxCore.Interpreters.Classes; +//using NimbusFox.FoxCore.Managers; +//using Plukit.Base; +//using Staxel.Commands; +//using Staxel.Items; +//using Staxel.Logic; +//using Staxel.Server; +//using Staxel.Tiles; + +//namespace NimbusFox.FoxCore.Interpreters { +// internal class LuaInt : CoreInt { +// private readonly LuaGlobalPortable _luaEngine; + +// public LuaInt(DirectoryManager directory, bool debug) { +// Debug = debug; +// Directory = directory; + +// ExceptionManager = new ExceptionManager(directory.Folder, "null"); + +// ParseScripts(".lua.code", directory); + +// _luaEngine = new Lua().CreateEnvironment(); + +// Directory._luaEngine = _luaEngine; + +// _luaEngine["log"] = new Action(Logger.WriteLine); +// _luaEngine["Fox_Core"] = +// new Func((author, mod, version) => +// new Fox_Core(author, mod, version)); + +// _luaEngine["GameContext"] = new GContext(); +// _luaEngine["ClientContext"] = new CContext(); +// _luaEngine["ServerContext"] = new SContext(); +// _luaEngine["RegisterCommand"] = new Action(AddCommand); + +// _luaEngine.DoChunk(script, $"{directory.Folder}.lua"); + +// } + +// private void AddCommand(string command, LuaTable obj) { +// try { +// var commandBuilder = new CommandBuilder(); + +// if (obj["execute"] == null) { +// throw new LuaRuntimeException("Object must contain a \"execute\" member", null); +// } + +// commandBuilder.Execute = (bits, blob, connection, api) => { +// var bitTable = new LuaTable(); + +// foreach (var bit in bits) { +// bitTable.Add(bit); +// } + +// object[] result; +// try { +// result = obj.CallMember("execute", bitTable, blob, connection, api).Values; +// } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { +// throw new LuaRuntimeException("\"execute\" must be a function", ex); +// } + +// if (!result.Any() || result[0] is LuaTable == false) { +// throw new LuaRuntimeException( +// "Expected an object containing \"translationCode\" and \"responseParams\" members", null); +// } + +// var output = new CommandOutput(); + +// var resultTable = (LuaTable)result[0]; + +// if (resultTable["responseParams"] == null) { +// output.ResponseParams = new object[0]; +// } else { +// var array = resultTable["responseParams"]; + +// if (array is LuaTable == false) { +// throw new LuaRuntimeException("Expecting member \"responseParams\" as an array", null); +// } + +// output.ResponseParams = ((LuaTable)array).ArrayList.ToArray(); +// } + +// if (resultTable["translationCode"] == null || resultTable["translationCode"] is string == false) { +// throw new LuaRuntimeException("Object must contain a \"translationCode\" member as string", +// null); +// } + +// output.TranslationCode = (string)resultTable["translationCode"]; + +// return output; +// }; + +// if (obj["usage"] == null || obj["usage"] is string == false) { +// throw new LuaRuntimeException("Object must have the member \"usage\" as string", null); +// } + +// commandBuilder.Usage = (string)obj["usage"]; + +// if (obj["public"] == null || obj["public"] is bool == false) { +// throw new LuaRuntimeException("Object must have the member \"public\" as bool", null); +// } + +// commandBuilder.Public = (bool)obj["public"]; + +// AddCommand(command, commandBuilder); +// } catch (LuaRuntimeException ex) when (!System.Diagnostics.Debugger.IsAttached) { +// var exce = LuaExceptionData.GetData(ex); + +// var exe = new Exception(exce.StackTrace, ex); + +// ExceptionManager.HandleException(exe); + +// if (Debug) { +// Application.Run(new ExceptionViewer(exe, Directory.Folder)); +// } +// } catch (Exception ex) when (!System.Diagnostics.Debugger.IsAttached) { +// ExceptionManager.HandleException(ex); + +// if (Debug) { +// Application.Run(new ExceptionViewer(ex, Directory.Folder)); +// } +// } +// } + +// public override void GameContextInitializeInit() { +// if (_luaEngine["gameContextInitializeInit"] != null && +// _luaEngine["gameContextInitializeInit"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void GameContextInitializeBefore() { +// if (_luaEngine["gameContextInitializeBefore"] != null && +// _luaEngine["gameContextInitializeBefore"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void GameContextInitializeAfter() { +// if (_luaEngine["gameContextInitializeAfter"] != null && +// _luaEngine["gameContextInitializeAfter"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void GameContextDeinitialize() { +// if (_luaEngine["gameContextDeinitialize"] != null && +// _luaEngine["gameContextDeinitialize"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void GameContextReloadBefore() { +// if (_luaEngine["gameContextReloadBefore"] != null && +// _luaEngine["gameContextReloadBefore"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void GameContextReloadAfter() { +// if (_luaEngine["gameContextReloadAfter"] != null && +// _luaEngine["gameContextReloadAfter"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void UniverseUpdateBefore(Universe universe, Timestep step) { +// if (_luaEngine["universeUpdateBefore"] != null && +// _luaEngine["universeUpdateBefore"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void UniverseUpdateAfter() { +// if (_luaEngine["universeUpdateAfter"] != null && +// _luaEngine["universeUpdateAfter"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override bool CanPlaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { +// if (_luaEngine["canPlaceTile"] != null && +// _luaEngine["canPlaceTile"] is LuaMethod f) { +// var result = _luaEngine.CallMember(f.Name, entity, location, tile, accessFlags).Values.FirstOrDefault(); + +// if (result == null || result is bool == false) { +// throw new LuaRuntimeException("Was expecting a boolean as the first result", null); +// } + +// return (bool)result; +// } + +// return true; +// } + +// public override bool CanReplaceTile(Entity entity, Vector3I location, Tile tile, TileAccessFlags accessFlags) { +// if (_luaEngine["canReplaceTile"] != null && +// _luaEngine["canReplaceTile"] is LuaMethod f) { +// var result = _luaEngine.CallMember(f.Name, entity, location, tile, accessFlags).Values.FirstOrDefault(); + +// if (result == null || result is bool == false) { +// throw new LuaRuntimeException("Was expecting a boolean as the first result", null); +// } + +// return (bool)result; +// } + +// return true; +// } + +// public override bool CanRemoveTile(Entity entity, Vector3I location, TileAccessFlags accessFlags) { +// if (_luaEngine["canRemoveTile"] != null && +// _luaEngine["canRemoveTile"] is LuaMethod f) { +// var result = _luaEngine.CallMember(f.Name, entity, location, accessFlags).Values.FirstOrDefault(); + +// if (result == null || result is bool == false) { +// throw new LuaRuntimeException("Was expecting a boolean as the first result", null); +// } + +// return (bool)result; +// } + +// return true; +// } + +// public override void ClientContextInitializeInit() { +// if (_luaEngine["gameContextInitializeInit"] != null && +// _luaEngine["gameContextInitializeInit"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void ClientContextInitializeBefore() { +// if (_luaEngine["gameContextInitializeInit"] != null && +// _luaEngine["gameContextInitializeInit"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void ClientContextInitializeAfter() { +// if (_luaEngine["clientContextInitializeAfter"] != null && +// _luaEngine["clientContextInitializeAfter"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void ClientContextDeinitialize() { +// if (_luaEngine["clientContextDeinitialize"] != null && +// _luaEngine["clientContextDeinitialize"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void ClientContextReloadBefore() { +// if (_luaEngine["clientContextReloadBefore"] != null && +// _luaEngine["clientContextReloadBefore"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void ClientContextReloadAfter() { +// if (_luaEngine["clientContextReloadAfter"] != null && +// _luaEngine["clientContextReloadAfter"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override void CleanupOldSession() { +// if (_luaEngine["clientContextReloadAfter"] != null && +// _luaEngine["clientContextReloadAfter"] is LuaMethod f) { +// _luaEngine.CallMember(f.Name); +// } +// } + +// public override bool CanInteractWithTile(Entity entity, Vector3F location, Tile tile) { +// if (_luaEngine["canInteractWithTile"] != null && +// _luaEngine["canInteractWithTile"] is LuaMethod f) { +// var result = _luaEngine.CallMember(f.Name, entity, location, tile).Values.FirstOrDefault(); + +// if (result == null || result is bool == false) { +// throw new LuaRuntimeException("Was expecting a boolean as the first result", null); +// } + +// return (bool)result; +// } +// return true; +// } + +// public override bool CanInteractWithEntity(Entity entity, Entity lookingAtEntity) { +// if (_luaEngine["canInteractWithEntity"] != null && +// _luaEngine["canInteractWithEntity"] is LuaMethod f) { +// var result = _luaEngine.CallMember(f.Name, entity, lookingAtEntity).Values.FirstOrDefault(); + +// if (result == null || result is bool == false) { +// throw new LuaRuntimeException("Was expecting a boolean as the first result", null); +// } + +// return (bool)result; +// } +// return true; +// } +// } +//} diff --git a/NimbusFox.FoxCore/Interpreters/NLua.csproj b/NimbusFox.FoxCore/Interpreters/NLua.csproj new file mode 100644 index 0000000..3855121 --- /dev/null +++ b/NimbusFox.FoxCore/Interpreters/NLua.csproj @@ -0,0 +1,138 @@ + + + + Debug + AnyCPU + {3CE4CCB6-3465-43E3-B5ED-5FB9B70D20E5} + Exe + Properties + NLua + NLua + 1.3.2 + v4.5 + + + + True + full + False + ..\..\tests\ + DEBUG + prompt + 4 + AllRules.ruleset + true + + + none + True + ..\..\tests\ + RELEASE + prompt + 4 + AnyCPU + AllRules.ruleset + + + True + full + False + ..\..\Run\Debug_x64 + DEBUG + prompt + 4 + x64 + AllRules.ruleset + + + none + True + ..\..\Run\Release_x64 + RELEASE + prompt + 4 + x64 + AllRules.ruleset + + + true + ..\..\tests\ + DEBUG + full + AnyCPU + prompt + AllRules.ruleset + 4 + false + + + true + bin\x64\DebugKopiLua\ + DEBUG + full + x64 + prompt + AllRules.ruleset + 4 + false + + + ..\..\tests\ + 4 + false + + + bin\x64\ReleaseKopiLua\ + 4 + false + + + NLua.ico + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + + + + + + + + {F55CABBB-4108-4A39-94E1-581FD46DC021} + NLua.Net45 + + + \ No newline at end of file diff --git a/NimbusFox.FoxCore/Managers/DirectoryManager.cs b/NimbusFox.FoxCore/Managers/DirectoryManager.cs index 5c8b7ef..ea5903b 100644 --- a/NimbusFox.FoxCore/Managers/DirectoryManager.cs +++ b/NimbusFox.FoxCore/Managers/DirectoryManager.cs @@ -2,27 +2,32 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; using System.Text.RegularExpressions; using System.Threading; -using System.Threading.Tasks; +using Jint; +using Jint.Native; +using Jint.Native.Object; +using Jint.Runtime; using Microsoft.Xna.Framework; -using NimbusFox; -using NimbusFox.FoxCore; +using Neo.IronLua; using NimbusFox.FoxCore.Classes; using Plukit.Base; +using Staxel; using Staxel.Core; -using Staxel.FoxCore.Classes; using Staxel.Items; using Staxel.Tiles; using Staxel.Voxel; -namespace Staxel.FoxCore.Managers { +namespace NimbusFox.FoxCore.Managers { public class DirectoryManager { + private static List FilesInUse = new List(); private string _localContentLocation; private string _root; private DirectoryManager _parent { get; set; } + internal Engine _jsEngine { get; set; } + internal LuaGlobalPortable _luaEngine { get; set; } + + public string Folder { get; private set; } public DirectoryManager Parent => _parent ?? this; @@ -44,6 +49,7 @@ internal DirectoryManager(string author, string mod) { var streamLocation = Path.Combine("Mods", author, mod); _localContentLocation = Path.Combine(GameContext.ContentLoader.LocalContentDirectory, streamLocation); _root = _localContentLocation; + Folder = mod; if (!Directory.Exists(_localContentLocation)) { Directory.CreateDirectory(_localContentLocation); @@ -52,19 +58,22 @@ internal DirectoryManager(string author, string mod) { internal DirectoryManager(string mod) { _localContentLocation = Path.Combine(GameContext.ContentLoader.RootDirectory, "mods", mod); - _root = _localContentLocation; + _root = GameContext.ContentLoader.RootDirectory; + Folder = mod; } internal DirectoryManager() { _localContentLocation = GameContext.ContentLoader.RootDirectory; _root = _localContentLocation; + Folder = "content"; } public DirectoryManager FetchDirectory(string name) { var dir = new DirectoryManager { _localContentLocation = Path.Combine(_localContentLocation, name), _root = _root, - _parent = this + _parent = this, + Folder = name }; CreateDirectory(name); @@ -72,7 +81,7 @@ public DirectoryManager FetchDirectory(string name) { return dir; } - public void CreateDirectory(string name) { + private void CreateDirectory(string name) { if (!DirectoryExists(name)) { Directory.CreateDirectory(Path.Combine(_localContentLocation, name)); } @@ -91,16 +100,116 @@ public bool DirectoryExists(string name) { } public static Blob SerializeObject(T data) { - if (data is Blob) { - return (Blob)(object)data; + if (data is Blob o) { + return o; } var blob = BlobAllocator.AcquireAllocator().NewBlob(true); blob.ObjectToBlob(null, data); return blob; } + public void WriteFileLua(string fileName, LuaTable data, Func onFinish = null, bool outputAsText = false) { + var dictionary = data.Cast().ToDictionary(key => key, key => data[key]); + + WriteFile(fileName, dictionary, () => { + onFinish?.Invoke(); + }, outputAsText); + } + + public void ReadFileLua(string fileName, Func onLoad, bool inputIsText) { + ReadFile>(fileName, data => { + var output = new LuaTable(); + + foreach (var item in data) { + output[item.Key] = item.Value; + } + + onLoad(output); + }, inputIsText); + } + + public void WriteFileJS(string fileName, JsValue data, Action onFinish = null, bool outputAsText = false) { + var blob = BlobAllocator.AcquireAllocator().NewBlob(false); + + JSToBlob(blob, data); + + WriteFile(fileName, blob, onFinish, outputAsText); + } + + public void ReadFileJS(string fileName, Action onLoad, bool inputIsText) { + var js = new JsValue(new ObjectInstance(_jsEngine)); + var wait = true; + ReadFile(fileName, blob => { + BlobToJS(blob, js); + wait = false; + }, inputIsText); + + while (wait) { } + onLoad.Invoke(js); + } + + private void JSToBlob(Blob parent, JsValue data) { + if (data.IsObject()) { + foreach (var property in data.AsObject().GetOwnProperties()) { + switch (property.Value.Value.Type) { + case Types.Boolean: + parent.SetBool(property.Key, property.Value.Value.AsBoolean()); + break; + case Types.Null: + parent.SetString(property.Key, ""); + break; + case Types.Number: + parent.SetDouble(property.Key, property.Value.Value.AsNumber()); + break; + case Types.String: + parent.SetString(property.Key, property.Value.Value.AsString()); + break; + case Types.None: + break; + case Types.Object: + JSToBlob(parent.FetchBlob(property.Key), property.Value.Value); + break; + } + } + } + } + + private void BlobToJS(Blob container, JsValue parent) { + foreach (var key in container.KeyValueIteratable) { + switch (key.Value.Kind) { + case BlobEntryKind.Bool: + parent.AsObject().FastAddProperty(key.Key, new JsValue(container.GetBool(key.Key)), true, false, false); + break; + case BlobEntryKind.Float: + parent.AsObject().FastAddProperty(key.Key, new JsValue(container.GetDouble(key.Key)), true, false, false); + break; + case BlobEntryKind.String: + if (container.GetString(key.Key).IsNullOrEmpty()) { + parent.AsObject().FastAddProperty(key.Key, JsValue.Null, true, false, false); + break; + } + parent.AsObject().FastAddProperty(key.Key, new JsValue(container.GetString(key.Key)), true, false, false); + break; + case BlobEntryKind.Blob: + parent.AsObject().FastAddProperty(key.Key, new JsValue(new ObjectInstance(_jsEngine)), true, false, false); + BlobToJS(container.FetchBlob(key.Key), parent.AsObject().Get(key.Key)); + break; + } + } + } + public void WriteFile(string fileName, T data, Action onFinish = null, bool outputAsText = false) { new Thread(() => { + var target = Path.Combine(GetPath(Path.DirectorySeparatorChar), fileName); + var collection = new List(); + collection.AddAll(FilesInUse); + while (collection.Any(x => x == target)) { + collection.Clear(); + collection.AddAll(FilesInUse); + } + + FilesInUse.Add(target); + var stream = new MemoryStream(); var output = SerializeObject(data); stream.Seek(0L, SeekOrigin.Begin); @@ -112,26 +221,52 @@ public void WriteFile(string fileName, T data, Action onFinish = null, bool o stream.Seek(0L, SeekOrigin.Begin); File.WriteAllBytes(Path.Combine(_localContentLocation, fileName), stream.ReadAllBytes()); onFinish?.Invoke(); + + FilesInUse.Remove(target); }).Start(); } - public void WriteFileStream(string filename, Stream stream, Action onWrite = null) { + public void WriteFileStream(string fileName, Stream stream, Action onWrite = null) { new Thread(() => { + var target = Path.Combine(GetPath(Path.DirectorySeparatorChar), fileName); + var collection = new List(); + collection.AddAll(FilesInUse); + while (collection.Any(x => x == target)) { + collection.Clear(); + collection.AddAll(FilesInUse); + } + + FilesInUse.Add(target); + stream.Seek(0L, SeekOrigin.Begin); - File.WriteAllBytes(Path.Combine(_localContentLocation, filename), stream.ReadAllBytes()); + File.WriteAllBytes(Path.Combine(_localContentLocation, fileName), stream.ReadAllBytes()); onWrite?.Invoke(); + + FilesInUse.Remove(target); }).Start(); } - public void ReadFile(string filename, Action onLoad, bool inputIsText = false) { + public void ReadFile(string fileName, Action onLoad, bool inputIsText = false) { new Thread(() => { - if (FileExists(filename)) { + var target = Path.Combine(GetPath(Path.DirectorySeparatorChar), fileName); + var collection = new List(); + collection.AddAll(FilesInUse); + while (collection.Any(x => x == target)) { + collection.Clear(); + collection.AddAll(FilesInUse); + } + + if (FileExists(fileName)) { var stream = - GameContext.ContentLoader.ReadStream(Path.Combine(GetPath('/'), filename)); + GameContext.ContentLoader.ReadStream(Path.Combine(GetPath('/'), fileName)); Blob input; if (!inputIsText) { input = stream.ReadBlob(); } else { + if (typeof(T) == typeof(string)) { + onLoad((T)(object)stream.ReadAllText()); + return; + } input = BlobAllocator.AcquireAllocator().NewBlob(false); var sr = new StreamReader(stream); input.ReadJson(sr.ReadToEnd()); @@ -139,22 +274,30 @@ public void ReadFile(string filename, Action onLoad, bool inputIsText = fa stream.Seek(0L, SeekOrigin.Begin); if (typeof(T) == input.GetType()) { - onLoad((T) (object) input); + onLoad((T)(object)input); return; } - onLoad(input.BlobToObject(null, (T) Activator.CreateInstance(typeof(T)))); + onLoad(input.BlobToObject(null, (T)Activator.CreateInstance(typeof(T)))); return; } - onLoad((T) Activator.CreateInstance(typeof(T))); + onLoad((T)Activator.CreateInstance(typeof(T))); }).Start(); } - public void ReadFileStream(string filename, Action onLoad, bool required = false) { + public void ReadFileStream(string fileName, Action onLoad, bool required = false) { new Thread(() => { + var target = Path.Combine(GetPath(Path.DirectorySeparatorChar), fileName); + var collection = new List(); + collection.AddAll(FilesInUse); + while (collection.Any(x => x == target)) { + collection.Clear(); + collection.AddAll(FilesInUse); + } + var stream = - GameContext.ContentLoader.ReadStream(Path.Combine(GetPath('/'), filename)); + GameContext.ContentLoader.ReadStream(Path.Combine(GetPath('/'), fileName)); stream.Seek(0L, SeekOrigin.Begin); onLoad?.Invoke(stream); }).Start(); @@ -162,12 +305,28 @@ public void ReadFileStream(string filename, Action onLoad, bool required public void DeleteFile(string name) { if (FileExists(name)) { + var target = Path.Combine(GetPath(Path.DirectorySeparatorChar), name); + var collection = new List(); + collection.AddAll(FilesInUse); + while (collection.Any(x => x == target)) { + collection.Clear(); + collection.AddAll(FilesInUse); + } + File.Delete(Path.Combine(_localContentLocation, name)); } } public void DeleteDirectory(string name, bool recursive) { if (DirectoryExists(name)) { + var target = Path.Combine(GetPath(Path.DirectorySeparatorChar), name); + var collection = new List(); + collection.AddAll(FilesInUse); + while (collection.Any(x => x == target)) { + collection.Clear(); + collection.AddAll(FilesInUse); + } + Directory.Delete(Path.Combine(_localContentLocation, name), recursive); } } @@ -274,7 +433,7 @@ public VoxelObject ReadQBFile(string name, Vector3I offSet, Vector3I sizeLimit) output = VoxelLoader.LoadQb(data, name + "qb", offSet, sizeLimit); }, true); - while(output == null) { } + while (output == null) { } return output; } @@ -308,7 +467,7 @@ void Action(Color color, int run) { var num = 1; if (run > 2) { bw.Write(2U); - bw.Write((uint) run); + bw.Write((uint)run); } else num = run; diff --git a/NimbusFox.FoxCore/Managers/ExceptionManager.cs b/NimbusFox.FoxCore/Managers/ExceptionManager.cs index 638ecae..ddbae61 100644 --- a/NimbusFox.FoxCore/Managers/ExceptionManager.cs +++ b/NimbusFox.FoxCore/Managers/ExceptionManager.cs @@ -1,17 +1,14 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using Staxel; -using Staxel.FoxCore.Managers; namespace NimbusFox.FoxCore.Managers { public class ExceptionManager { private string _modVersion; private readonly DirectoryManager ErrorsDir; - internal ExceptionManager(string author, string mod, string modVersion) { - ErrorsDir = new DirectoryManager(author, mod).FetchDirectory("Errors"); + internal ExceptionManager(string mod, string modVersion) { + ErrorsDir = new DirectoryManager(mod).FetchDirectory("Errors"); _modVersion = modVersion; } @@ -33,6 +30,8 @@ public void HandleException(Exception ex, Dictionary extras = nu } } } + + } } } diff --git a/NimbusFox.FoxCore/Managers/FileManager.cs b/NimbusFox.FoxCore/Managers/FileManager.cs index bf79ba8..5671cf6 100644 --- a/NimbusFox.FoxCore/Managers/FileManager.cs +++ b/NimbusFox.FoxCore/Managers/FileManager.cs @@ -1,18 +1,12 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Reflection; using System.Runtime.Serialization.Formatters.Binary; using System.Threading; -using System.Timers; -using System.Web.Script.Serialization; using Newtonsoft.Json; -using Plukit.Base; using Staxel; -using Staxel.FoxCore.Classes; namespace NimbusFox.FoxCore.Managers { - [Obsolete("Please use the new DirectoryManager")] + [Obsolete("Please use the new DirectoryManager", true)] public class FileManager { internal readonly string StreamLocation; private readonly string LocalContentLocation; diff --git a/NimbusFox.FoxCore/Managers/Particles/EntityFollowParticleManager.cs b/NimbusFox.FoxCore/Managers/Particles/EntityFollowParticleManager.cs index 2d22e18..c6c4266 100644 --- a/NimbusFox.FoxCore/Managers/Particles/EntityFollowParticleManager.cs +++ b/NimbusFox.FoxCore/Managers/Particles/EntityFollowParticleManager.cs @@ -1,17 +1,11 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NimbusFox; -using NimbusFox.FoxCore; using NimbusFox.FoxCore.Classes; using NimbusFox.FoxCore.Client.Staxel.Builders.Logic; -using NimbusFox.FoxCore.Managers.Particles; using Plukit.Base; using Staxel.Logic; -namespace Staxel.FoxCore.Managers.Particles { +namespace NimbusFox.FoxCore.Managers.Particles { public class EntityFollowParticleManager : EntityParticleManager { public Guid Add(Entity entity, string particleCode, int xOffset = 0, int yOffset = 0, int zoffset = 0) { var particleHost = new VectorRangeI { diff --git a/NimbusFox.FoxCore/Managers/Particles/EntityParticleManager.cs b/NimbusFox.FoxCore/Managers/Particles/EntityParticleManager.cs index 3e68b5f..ec42dae 100644 --- a/NimbusFox.FoxCore/Managers/Particles/EntityParticleManager.cs +++ b/NimbusFox.FoxCore/Managers/Particles/EntityParticleManager.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using NimbusFox.FoxCore.Classes; using NimbusFox.FoxCore.Client.Staxel.Builders.Logic; diff --git a/NimbusFox.FoxCore/Managers/UserManager.cs b/NimbusFox.FoxCore/Managers/UserManager.cs index 4dfa274..bc26aa0 100644 --- a/NimbusFox.FoxCore/Managers/UserManager.cs +++ b/NimbusFox.FoxCore/Managers/UserManager.cs @@ -1,16 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NimbusFox; -using NimbusFox.FoxCore; -using NimbusFox.FoxCore.Managers; using Plukit.Base; -using Staxel.FoxCore.Classes; +using NimbusFox.FoxCore.Classes; using Staxel.Logic; -namespace Staxel.FoxCore.Managers { +namespace NimbusFox.FoxCore.Managers { public class UserManager { private static readonly DirectoryManager FileManager = new DirectoryManager("NimbusFox", "FoxCore"); private const string CacheFile = "User.cache"; @@ -35,7 +30,7 @@ private List CloneCache() { } private void Flush() { - FileManager.WriteFile(CacheFile, _cache); + //FileManager.WriteFile(CacheFile, _cache); } private Universe Universe => CoreHook.Universe; diff --git a/NimbusFox.FoxCore/Managers/VariantManager.cs b/NimbusFox.FoxCore/Managers/VariantManager.cs index fea1b17..b251858 100644 --- a/NimbusFox.FoxCore/Managers/VariantManager.cs +++ b/NimbusFox.FoxCore/Managers/VariantManager.cs @@ -2,19 +2,15 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; -using NimbusFox.FoxCore; using Plukit.Base; -using Staxel.Core; -using Staxel.Items; +using Staxel; using Staxel.Tiles; using Staxel.Voxel; using Voxels; using Color = Microsoft.Xna.Framework.Color; -namespace Staxel.FoxCore.Managers { +namespace NimbusFox.FoxCore.Managers { public static class VariantManager { public static void CreateTile(Tile baseTile, Dictionary replaceColorsWith, string newVariantTileCode, Fox_Core modFoxCore, Blob overrides) { diff --git a/NimbusFox.FoxCore/Managers/WorldManager.cs b/NimbusFox.FoxCore/Managers/WorldManager.cs index 1233f29..7dfb372 100644 --- a/NimbusFox.FoxCore/Managers/WorldManager.cs +++ b/NimbusFox.FoxCore/Managers/WorldManager.cs @@ -1,6 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using NimbusFox.FoxCore.Classes; +using NimbusFox.FoxCore.Classes; using Plukit.Base; using Staxel.Logic; diff --git a/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj b/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj index 7c03de2..ff624a8 100644 --- a/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj +++ b/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj @@ -7,8 +7,8 @@ {8B473A82-8C34-44EA-B13D-39D0418E021F} Library Properties - Staxel.FoxCore - NimbusFox.FoxCore.V1.2 + NimbusFox.FoxCore + NimbusFox.FoxCore.V2 v4.5.2 512 @@ -25,6 +25,8 @@ 4 + x64 + latest pdbonly @@ -33,13 +35,26 @@ TRACE prompt 4 + latest + + ..\..\packages\Costura.Fody.2.0.0\lib\net452\Costura.dll + C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\FNA.dll False + + ..\..\packages\Jint.2.11.58\lib\net451\Jint.dll + + + ..\..\packages\NeoLua.1.2.24\lib\net45\Neo.Lua.dll + + + ..\..\packages\NeoLua.1.2.24\lib\net45\Neo.Lua.Desktop.dll + False C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Newtonsoft.Json.dll @@ -49,6 +64,10 @@ C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Plukit.Base.dll False + + C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Simplex.dll + False + C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.dll False @@ -57,18 +76,6 @@ C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.Auth.dll False - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.Checks.dll - False - - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.Trace.dll - False - - - C:\Program Files (x86)\Steam\steamapps\common\Staxel\bin\Staxel.ValueSource.dll - False - @@ -84,6 +91,7 @@ + @@ -93,7 +101,7 @@ - + @@ -108,8 +116,17 @@ - + + DtsGenerator + Core.cs.d.ts + + + Form + + + ExceptionViewer.cs + Form @@ -117,6 +134,14 @@ VariantLoader.cs + + + + + + + + @@ -127,12 +152,13 @@ + {690691FF-8AEF-43FE-A5B9-6FD6131ECF87} NimbusFox.FoxCore.Client - False + True {0fc13651-c865-49f9-a642-3a59b9958720} @@ -140,14 +166,28 @@ - - + + + ExceptionViewer.cs + VariantLoader.cs + + + + Always + + + + + + + + del $(TargetDir)\*.mod @@ -155,4 +195,13 @@ echo {} > $(TargetDir)$(TargetName).mod + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj.DotSettings b/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj.DotSettings new file mode 100644 index 0000000..96331d1 --- /dev/null +++ b/NimbusFox.FoxCore/NimbusFox.FoxCore.csproj.DotSettings @@ -0,0 +1,2 @@ + + CSharp72 \ No newline at end of file diff --git a/NimbusFox.FoxCore/Staxel/Commands/ScriptRefreshCommand.cs b/NimbusFox.FoxCore/Staxel/Commands/ScriptRefreshCommand.cs new file mode 100644 index 0000000..bb01c24 --- /dev/null +++ b/NimbusFox.FoxCore/Staxel/Commands/ScriptRefreshCommand.cs @@ -0,0 +1,36 @@ +//using System; +//using System.Collections.Generic; +//using System.Linq; +//using System.Text; +//using System.Threading; +//using System.Threading.Tasks; +//using NimbusFox.FoxCore.Interpreters; +//using Plukit.Base; +//using Staxel.Commands; +//using Staxel.Server; + +//namespace NimbusFox.FoxCore.Commands { +// internal class ScriptRefreshCommand : ICommandBuilder { +// public string Execute(string[] bits, Blob blob, ClientServerConnection connection, ICommandsApi api, +// out object[] responseParams) { +// responseParams = new object[] { }; +// new Thread(() => { +// var msg = "mods.nimbusfox.foxcore.scriptrefresh.success"; + +// try { +// CoreIntMods.ReloadMods(true); +// } catch { +// msg = "mods.nimbusfox.foxcore.scriptrefresh.fail"; +// } + +// api.MessagePlayer(connection.Credentials.Uid, msg, new object[0]); +// }).Start(); + +// return ""; +// } + +// public string Kind => "sr"; +// public string Usage => "mods.nimbusfox.foxcore.scriptrefresh.description"; +// public bool Public => false; +// } +//} diff --git a/NimbusFox.FoxCore/Staxel/Translations/en-gb.lang b/NimbusFox.FoxCore/Staxel/Translations/en-gb.lang new file mode 100644 index 0000000..79eac6b --- /dev/null +++ b/NimbusFox.FoxCore/Staxel/Translations/en-gb.lang @@ -0,0 +1,10 @@ +language.code=en-GB +language=English + +mods.nimbusfox.exception.message=:^c:FF0000;An error occured in {0-mod} and an error log has been stored in the save folder under Mods\\Nimbusfox\\{1-mod}\\Errors. Currently there are no ways of sending the errors to me. If you see me in Discord don't hesitate to send me the file there. No personal information is gathered. Only what is public and what is stored in memory that {2-mod} has access to is present in the error files + +mods.nimbusfox.foxcore.scriptrefresh.success=^c:00FF00;Reload Complete +mods.nimbusfox.foxcore.scriptrefresh.fail=^c:FF0000;Reload encountered an error. Please visit the mod folders for the error +mods.nimbusfox.foxcore.scriptrefresh.description=Reloads all scripts + +mods.nimbusfox.foxcore.scriptcommand.description=Runs a command registered by a script \ No newline at end of file diff --git a/NimbusFox.FoxCore/packages.config b/NimbusFox.FoxCore/packages.config new file mode 100644 index 0000000..72d0e27 --- /dev/null +++ b/NimbusFox.FoxCore/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/jint b/jint deleted file mode 160000 index c364bf9..0000000 --- a/jint +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c364bf9a4b5451be42ccd3616671de065d2e1b27