-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of split/migrated base
- Loading branch information
0 parents
commit 287a858
Showing
32 changed files
with
3,799 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# EditorConfig is awesome: http://editorconfig.org | ||
root = true | ||
|
||
[*.cs] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.csproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sln merge=binary | ||
#*.sqlproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# Behavior for image files | ||
# | ||
# Image files are treated as binary by default. | ||
############################################################################### | ||
*.gif binary | ||
*.ico binary | ||
*.jpg binary | ||
*.png binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ins. | ||
|
||
# Build output | ||
[Bb]in/ | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Oo]bj/ | ||
[Rr]elease/ | ||
[Rr]eleases/ | ||
|
||
# Build testing | ||
## MSTest | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
## NUnit | ||
*.VisualState.xml | ||
TestResult.xml | ||
|
||
# NuGet packages | ||
*.nupkg | ||
**/packages/* | ||
!**/packages/build/ | ||
!**/packages/repositories.config | ||
|
||
# OS-specific files | ||
.*DS_Store | ||
._* | ||
|
||
# Roslyn caches | ||
*.ide/ | ||
|
||
# User-specific files | ||
.idea/ | ||
*.sln.docstates | ||
*.suo | ||
*.user | ||
*.userosscache | ||
*.userprefs | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio | ||
.vs/ | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# Visual Studio add-ins | ||
## DotCover code coverage tool | ||
*.dotCover | ||
## JustCode add-in | ||
.JustCode | ||
## ReSharper add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
## TeamCity add-in | ||
_TeamCity* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2014-2017 Oxide Team and Contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<config> | ||
<add key="globalPackagesFolder" value="packages" /> | ||
</config> | ||
<packageRestore> | ||
<add key="enabled" value="True" /> | ||
<add key="automatic" value="True" /> | ||
</packageRestore> | ||
<activePackageSource> | ||
<add key="All" value="(Aggregate source)" /> | ||
</activePackageSource> | ||
<packageSources> | ||
<add key="Oxide" value="https://www.myget.org/F/oxide" /> | ||
</packageSources> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27004.2008 | ||
MinimumVisualStudioVersion = 15.0 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Oxide.CSharp", "Oxide.CSharp\Oxide.CSharp.csproj", "{9103D682-D1AA-4A95-A499-896F551AAA62}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Debug|x64 = Debug|x64 | ||
Release|Any CPU = Release|Any CPU | ||
Release|x64 = Release|x64 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Debug|x64.ActiveCfg = Debug|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Debug|x64.Build.0 = Debug|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Release|x64.ActiveCfg = Release|Any CPU | ||
{9103D682-D1AA-4A95-A499-896F551AAA62}.Release|x64.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {E0FBE60B-9AEB-45B1-9BB0-2116D724C65F} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using Oxide.Core; | ||
using Oxide.Core.Extensions; | ||
using Oxide.Core.Plugins.Watchers; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Oxide.Plugins | ||
{ | ||
/// <summary> | ||
/// The extension class that represents this extension | ||
/// </summary> | ||
public class CSharpExtension : Extension | ||
{ | ||
internal static Assembly Assembly = Assembly.GetExecutingAssembly(); | ||
internal static AssemblyName AssemblyName = Assembly.GetName(); | ||
internal static VersionNumber AssemblyVersion = new VersionNumber(AssemblyName.Version.Major, AssemblyName.Version.Minor, AssemblyName.Version.Build); | ||
internal static string AssemblyAuthors = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(Assembly, typeof(AssemblyCompanyAttribute), false)).Company; | ||
|
||
/// <summary> | ||
/// Gets whether this extension is a core extension | ||
/// </summary> | ||
public override bool IsCoreExtension => true; | ||
|
||
/// <summary> | ||
/// Gets the name of this extension | ||
/// </summary> | ||
public override string Name => "CSharp"; | ||
|
||
/// <summary> | ||
/// Gets the author of this extension | ||
/// </summary> | ||
public override string Author => AssemblyAuthors; | ||
|
||
/// <summary> | ||
/// Gets the version of this extension | ||
/// </summary> | ||
public override VersionNumber Version => AssemblyVersion; | ||
|
||
public FSWatcher Watcher { get; private set; } | ||
|
||
// The .cs plugin loader | ||
private CSharpPluginLoader loader; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the CSharpExtension class | ||
/// </summary> | ||
/// <param name="manager"></param> | ||
public CSharpExtension(ExtensionManager manager) : base(manager) | ||
{ | ||
if (Environment.OSVersion.Platform == PlatformID.Unix) | ||
{ | ||
Cleanup.Add(Path.Combine(Interface.Oxide.ExtensionDirectory, "Mono.Posix.dll.config")); | ||
|
||
var extDir = Interface.Oxide.ExtensionDirectory; | ||
var configPath = Path.Combine(extDir, "Oxide.References.dll.config"); | ||
if (File.Exists(configPath) && !(new[] { "target=\"x64", "target=\"./x64" }.Any(File.ReadAllText(configPath).Contains))) return; | ||
|
||
File.WriteAllText(configPath, $"<configuration>\n<dllmap dll=\"MonoPosixHelper\" target=\"{extDir}/x86/libMonoPosixHelper.so\" os=\"!windows,osx\" wordsize=\"32\" />\n" + | ||
$"<dllmap dll=\"MonoPosixHelper\" target=\"{extDir}/x64/libMonoPosixHelper.so\" os=\"!windows,osx\" wordsize=\"64\" />\n</configuration>"); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Loads this extension | ||
/// </summary> | ||
public override void Load() | ||
{ | ||
// Register our loader | ||
loader = new CSharpPluginLoader(this); | ||
Manager.RegisterPluginLoader(loader); | ||
|
||
// Register engine frame callback | ||
Interface.Oxide.OnFrame(OnFrame); | ||
} | ||
|
||
/// <summary> | ||
/// Loads plugin watchers used by this extension | ||
/// </summary> | ||
/// <param name="pluginDirectory"></param> | ||
public override void LoadPluginWatchers(string pluginDirectory) | ||
{ | ||
// Register the watcher | ||
Watcher = new FSWatcher(pluginDirectory, "*.cs"); | ||
Manager.RegisterPluginChangeWatcher(Watcher); | ||
} | ||
|
||
/// <summary> | ||
/// Called when all other extensions have been loaded | ||
/// </summary> | ||
public override void OnModLoad() => loader.OnModLoaded(); | ||
|
||
public override void OnShutdown() | ||
{ | ||
base.OnShutdown(); | ||
loader.OnShutdown(); | ||
} | ||
|
||
/// <summary> | ||
/// Called by engine every server frame | ||
/// </summary> | ||
private void OnFrame(float delta) | ||
{ | ||
var args = new object[] { delta }; | ||
foreach (var kv in loader.LoadedPlugins) | ||
{ | ||
var plugin = kv.Value as CSharpPlugin; | ||
if (plugin != null && plugin.HookedOnFrame) plugin.CallHook("OnFrame", args); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.