-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on new mod to allow for land claiming whilst being open compatible with other mods using interfaces
- Loading branch information
NimbusFox
committed
Feb 24, 2018
1 parent
de30b06
commit 0162afb
Showing
17 changed files
with
510 additions
and
30 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,3 @@ | ||
[submodule "Staxel-FoxCore"] | ||
path = Staxel-FoxCore | ||
url = https://github.com/NimbusFox/Staxel-FoxCore.git |
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,14 @@ | ||
using Plukit.Base; | ||
using Staxel.Logic; | ||
|
||
namespace NimbusFox.LandClaim.Interfaces { | ||
public interface ILandClaim { | ||
void AddPos1(Entity entity, Vector3D position); | ||
void AddPos2(Entity entity, Vector3D position); | ||
void Confirm(Entity entity); | ||
void Clear(Entity entity); | ||
void Purge(Entity entity); | ||
void ToggleAdmin(Entity entity); | ||
bool IsInArea(Entity entity); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
NimbusFox.LandClaim.Interfaces/NimbusFox.LandClaim.Interfaces.csproj
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,64 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{929DA8AE-B4CA-4294-B66D-23656978EB1D}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>NimbusFox.LandClaim.Interfaces</RootNamespace> | ||
<AssemblyName>NimbusFox.LandClaim.Interfaces</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" /> | ||
<Reference Include="Plukit.Base"> | ||
<HintPath>..\..\..\Steam\steamapps\common\Staxel\bin\Plukit.Base.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Staxel"> | ||
<HintPath>..\..\..\Steam\steamapps\common\Staxel\bin\Staxel.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ILandClaim.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Staxel-FoxCore\NimbusFox.FoxCore.csproj"> | ||
<Project>{8b473a82-8c34-44ea-b13d-39d0418e021f}</Project> | ||
<Name>NimbusFox.FoxCore</Name> | ||
<Private>False</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Classes\" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("NimbusFox.LandClaim.Interfaces")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("NimbusFox.LandClaim.Interfaces")] | ||
[assembly: AssemblyCopyright("Copyright © 2018")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("929da8ae-b4ca-4294-b66d-23656978eb1d")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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
This file was deleted.
Oops, something went wrong.
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,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NimbusFox.FoxCore.Classes; | ||
|
||
namespace NimbusFox.LandClaim.Classes { | ||
public class ClaimAreaV1 { | ||
public string OwnerUid { get; set; } | ||
public string OwnerName { get; set; } | ||
public VectorSquareI Area { get; set; } | ||
public List<string> Guests { get; set; } | ||
public bool IsAdminArea { get; set; } | ||
|
||
public ClaimAreaV1() { | ||
Guests = new List<string>(); | ||
} | ||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NimbusFox.FoxCore.Classes; | ||
using Staxel.Logic; | ||
|
||
namespace NimbusFox.LandClaim.Classes { | ||
public class ClaimDataV1 { | ||
public List<ClaimAreaV1> ClaimedAreas { get; set; } | ||
|
||
public ClaimDataV1() { | ||
ClaimedAreas = new List<ClaimAreaV1>(); | ||
} | ||
|
||
public List<ClaimAreaV1> CloneClaimedAreas() { | ||
return new List<ClaimAreaV1>(ClaimedAreas); | ||
} | ||
} | ||
} |
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,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Plukit.Base; | ||
|
||
namespace NimbusFox.LandClaim.Classes { | ||
public class Positions { | ||
public Vector3D Start { get; set; } | ||
public Vector3D End { get; set; } | ||
} | ||
} |
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,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NimbusFox.FoxCore.Classes; | ||
using Staxel.Logic; | ||
|
||
namespace NimbusFox.LandClaim.Classes { | ||
public class TempData { | ||
public Dictionary<Entity, Positions> ClaimMarkers = new Dictionary<Entity, Positions>(); | ||
|
||
public Dictionary<Entity, Positions> CloneMarkers() { | ||
return new Dictionary<Entity, Positions>(ClaimMarkers); | ||
} | ||
} | ||
} |
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,109 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json; | ||
using NimbusFox.FoxCore; | ||
using NimbusFox.LandClaim.Classes; | ||
using NimbusFox.LandClaim.Interfaces; | ||
using Plukit.Base; | ||
using Staxel.Logic; | ||
|
||
namespace NimbusFox.LandClaim { | ||
public class LandManager : ILandClaim { | ||
internal static FxCore FoxCore { get; } = new FxCore("NimbusFox", "LandClaim", "v0.1"); | ||
internal static TempData TempData { get; set; } | ||
internal static ClaimDataV1 ClaimData { get; set; } | ||
private const string ClaimFile = "LC.db"; | ||
|
||
internal static void Init() { | ||
TempData = new TempData(); | ||
|
||
if (!FoxCore.FileManager.FileExists(ClaimFile)) { | ||
ClaimData = new ClaimDataV1(); | ||
Flush(); | ||
} else { | ||
var data = FoxCore.FileManager.ReadFile<object>(ClaimFile); | ||
|
||
ClaimData = JsonConvert.DeserializeObject<ClaimDataV1>(JsonConvert.SerializeObject(data)); | ||
} | ||
} | ||
|
||
private static void Flush() { | ||
FoxCore.FileManager.WriteFile(ClaimFile, ClaimData); | ||
} | ||
|
||
internal static void CheckPlayerMarkers(Entity entity) { | ||
if (entity != null) { | ||
if (!TempData.CloneMarkers().ContainsKey(entity)) { | ||
TempData.ClaimMarkers.Add(entity, new Positions()); | ||
} | ||
} | ||
} | ||
|
||
internal static void _AddPos1(Entity entity, Vector3D position) { | ||
CheckPlayerMarkers(entity); | ||
|
||
TempData.ClaimMarkers[entity].Start = position; | ||
} | ||
|
||
public void AddPos1(Entity entity, Vector3D position) { | ||
_AddPos1(entity, position); | ||
} | ||
|
||
internal static void _AddPos2(Entity entity, Vector3D position) { | ||
CheckPlayerMarkers(entity); | ||
|
||
TempData.ClaimMarkers[entity].End = position; | ||
} | ||
|
||
public void AddPos2(Entity entity, Vector3D position) { | ||
_AddPos2(entity, position); | ||
} | ||
|
||
internal static void _Confirm(Entity entity) { | ||
Flush(); | ||
} | ||
|
||
public void Confirm(Entity entity) { | ||
_Confirm(entity); | ||
} | ||
|
||
internal static void _Clear(Entity entity) { | ||
if (TempData.CloneMarkers().Any(x => x.Key == entity)) { | ||
TempData.ClaimMarkers.Remove(entity); | ||
} | ||
} | ||
|
||
public void Clear(Entity entity) { | ||
_Clear(entity); | ||
} | ||
|
||
internal static void _Purge(Entity entity) { | ||
var target = ClaimData.CloneClaimedAreas().FirstOrDefault(x => x.OwnerUid == entity.PlayerEntityLogic.Uid()); | ||
if (target != null) { | ||
ClaimData.ClaimedAreas.Remove(target); | ||
Flush(); | ||
} | ||
} | ||
|
||
public void Purge(Entity entity) { | ||
_Purge(entity); | ||
} | ||
|
||
public void ToggleAdmin(Entity entity) { } | ||
|
||
internal static bool _IsInArea(Entity entity) { | ||
return ClaimData.ClaimedAreas.Any(x => x.Area.IsInside(entity.Physics.Position)); | ||
} | ||
|
||
public bool IsInArea(Entity entity) { | ||
return _IsInArea(entity); | ||
} | ||
|
||
internal static ClaimAreaV1 GetArea(Entity entity) { | ||
return ClaimData.CloneClaimedAreas().FirstOrDefault(x => _IsInArea(entity)); | ||
} | ||
} | ||
} |
Oops, something went wrong.