-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from InvalidArgument3/cores
deditest1soon
- Loading branch information
Showing
72 changed files
with
11,885 additions
and
795 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,11 @@ | ||
<?xml version="1.0"?> | ||
<MyObjectBuilder_ModInfo xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<SteamIDOwner>76561198071098415</SteamIDOwner> | ||
<WorkshopId>0</WorkshopId> | ||
<WorkshopIds> | ||
<WorkshopId> | ||
<Id>3260158135</Id> | ||
<ServiceName>Steam</ServiceName> | ||
</WorkshopId> | ||
</WorkshopIds> | ||
</MyObjectBuilder_ModInfo> |
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,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<EntityComponents> | ||
<EntityComponent xsi:type="MyObjectBuilder_ModStorageComponentDefinition"> | ||
<Id> | ||
<TypeId>ModStorageComponent</TypeId> | ||
<SubtypeId>MIG-SpecCores</SubtypeId> | ||
</Id> | ||
<RegisteredStorageGuids> | ||
<guid>82f6e121-550f-4042-a2b8-185ed2a52abc</guid><!-- CockpitUpgrade --> | ||
<guid>82f6e121-550f-4042-a2b8-185ed2a52abd</guid><!-- CockpitUpgrade --> | ||
</RegisteredStorageGuids> | ||
</EntityComponent> | ||
</EntityComponents> | ||
</Definitions> |
13 changes: 13 additions & 0 deletions
13
TSTSSESCores/Data/Scripts/Scripts/.idea/.idea.Scripts/.idea/.gitignore
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
TSTSSESCores/Data/Scripts/Scripts/.idea/.idea.Scripts/.idea/encodings.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
TSTSSESCores/Data/Scripts/Scripts/.idea/.idea.Scripts/.idea/indexLayout.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
TSTSSESCores/Data/Scripts/Scripts/.idea/.idea.Scripts/.idea/vcs.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/> | ||
</startup> | ||
</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,9 @@ | ||
namespace MIG.Shared.CSharp { | ||
public interface Action2<T, K> { | ||
void run(T t, K k); | ||
} | ||
|
||
public interface Action1<T> { | ||
void run(T t); | ||
} | ||
} |
203 changes: 203 additions & 0 deletions
203
TSTSSESCores/Data/Scripts/Scripts/Shared/BlockIdmatcher.cs
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,203 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using VRage.Game; | ||
|
||
namespace SharedLib | ||
{ | ||
|
||
public class BlockIdMatcherWithCache : BlockIdMatcher | ||
{ | ||
private Dictionary<MyDefinitionId, bool> matches = new Dictionary<MyDefinitionId, bool>(); | ||
public BlockIdMatcherWithCache(string s) : base(s) | ||
{ | ||
} | ||
|
||
public override bool Matches(MyDefinitionId Id) | ||
{ | ||
bool result; | ||
if (!matches.TryGetValue(Id, out result)) | ||
{ | ||
result = base.Matches(Id); | ||
matches[Id] = result; | ||
return result; | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Examples: */*AdminBlock* */*Admin-Block A/*Admin-Block *!Admin-Block */* a/a | ||
/// </summary> | ||
public class BlockIdMatcher | ||
{ | ||
private static Regex regex = new Regex("([*\\w-_0-9]+)?(?:\\/)?([*\\w-_0-9]+)"); | ||
public List<TypeSubtypeMatcher> checks = new List<TypeSubtypeMatcher>(); | ||
|
||
public BlockIdMatcher(string s) | ||
{ | ||
if (s == null) { return; } | ||
var m = regex.Matches(s); | ||
for (var x = 0; x < m.Count; x++) | ||
{ | ||
var match = m[x]; | ||
switch (match.Groups.Count) | ||
{ | ||
case 2: | ||
{ | ||
var w = match.Groups[1].Value; | ||
checks.Add(new TypeSubtypeMatcher(TypeSubtypeMatcher.MODE_ANY, String.Empty, GetMode(w), w.Replace("*", ""))); | ||
break; | ||
} | ||
case 3: | ||
{ | ||
var w1 = match.Groups[1].Value; | ||
var w2 = match.Groups[2].Value; | ||
checks.Add(new TypeSubtypeMatcher(GetMode(w1), w1.Replace("*", ""), GetMode(w2), w2.Replace("*", ""))); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
var s = ""; | ||
foreach(var x in checks) | ||
{ | ||
s += x.ToString() + " "; | ||
} | ||
|
||
return $"BlockIdMatcher:{checks.Count} [{s}]"; | ||
} | ||
|
||
private int GetMode(string w) | ||
{ | ||
var v = !w.Contains("!"); | ||
if (w == "*") return TypeSubtypeMatcher.MODE_ANY; | ||
if (w.StartsWith("*") && w.EndsWith("*")) return v ? TypeSubtypeMatcher.MODE_CONTAINS : TypeSubtypeMatcher.MODE_NOT_CONTAINS; | ||
if (w.StartsWith("*")) return v ? TypeSubtypeMatcher.MODE_ENDS : TypeSubtypeMatcher.MODE_NOT_ENDS; | ||
if (w.EndsWith("*")) return v ? TypeSubtypeMatcher.MODE_STARTS : TypeSubtypeMatcher.MODE_NOT_STARTS; | ||
return TypeSubtypeMatcher.MODE_EXACT; | ||
} | ||
|
||
public virtual bool Matches(string type, string subtype) | ||
{ | ||
foreach (var x in checks) | ||
{ | ||
if (x.Matches(type, subtype)) | ||
{ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
|
||
public virtual bool Matches(MyDefinitionId Id) | ||
{ | ||
return Matches(Id.TypeId.ToString().Replace("MyObjectBuilder_", ""), Id.SubtypeName); | ||
} | ||
|
||
public class TypeSubtypeMatcher | ||
{ | ||
public const int MODE_EXACT = 0; | ||
|
||
public const int MODE_STARTS = 1; | ||
public const int MODE_ENDS = 2; | ||
public const int MODE_CONTAINS = 3; | ||
|
||
public const int MODE_NOT_STARTS = 4; | ||
public const int MODE_NOT_ENDS = 5; | ||
public const int MODE_NOT_CONTAINS = 6; | ||
|
||
public const int MODE_ANY = 7; | ||
|
||
|
||
public int modeType = 0; | ||
public int modeSubType = 0; | ||
public string typeString = null; | ||
public string subtypeString = null; | ||
|
||
|
||
public TypeSubtypeMatcher(int modeType, string typeString, int modeSubType, string subtypeString) | ||
{ | ||
this.modeType = modeType; | ||
this.typeString = typeString; | ||
this.modeSubType = modeSubType; | ||
this.subtypeString = subtypeString; | ||
} | ||
|
||
public bool MatchesType(string type) | ||
{ | ||
switch (modeType) | ||
{ | ||
case MODE_EXACT: | ||
if (type != typeString) return false; | ||
break; | ||
case MODE_STARTS: | ||
if (!type.StartsWith(typeString)) return false; | ||
break; | ||
case MODE_NOT_STARTS: | ||
if (type.StartsWith(typeString)) return false; | ||
break; | ||
case MODE_ENDS: | ||
if (!type.EndsWith(typeString)) return false; | ||
break; | ||
case MODE_NOT_ENDS: | ||
if (type.EndsWith(typeString)) return false; | ||
break; | ||
case MODE_CONTAINS: | ||
if (!type.Contains(typeString)) return false; | ||
break; | ||
case MODE_NOT_CONTAINS: | ||
if (type.Contains(typeString)) return false; | ||
break; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public bool MatchesSubtype(string subtype) | ||
{ | ||
switch (modeSubType) | ||
{ | ||
case MODE_EXACT: | ||
if (subtype != subtypeString) return false; | ||
break; | ||
case MODE_STARTS: | ||
if (!subtype.StartsWith(subtypeString)) return false; | ||
break; | ||
case MODE_NOT_STARTS: | ||
if (subtype.StartsWith(subtypeString)) return false; | ||
break; | ||
case MODE_ENDS: | ||
if (!subtype.EndsWith(subtypeString)) return false; | ||
break; | ||
case MODE_NOT_ENDS: | ||
if (subtype.EndsWith(subtypeString)) return false; | ||
break; | ||
case MODE_CONTAINS: | ||
if (!subtype.Contains(subtypeString)) return false; | ||
break; | ||
case MODE_NOT_CONTAINS: | ||
if (subtype.Contains(subtypeString)) return false; | ||
break; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
public bool Matches(string type, string subtype) | ||
{ | ||
return MatchesType(type) && MatchesSubtype(subtype); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return typeString + "/" + subtypeString + "[" + modeType + "/" + modeSubType + "]"; | ||
} | ||
} | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
TSTSSESCores/Data/Scripts/Scripts/Shared/BlueprintsHelper.cs
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,110 @@ | ||
using Sandbox.Definitions; | ||
using VRage.ObjectBuilders; | ||
|
||
namespace MIG.Shared.SE | ||
{ | ||
|
||
public enum BlueprintType | ||
{ | ||
OreToIngot, | ||
OresToIngots, | ||
OresToOres, | ||
|
||
IngotsToIngots, | ||
IngotsToComponent, | ||
IngotsToComponents, | ||
|
||
ComponentsToComponents, | ||
|
||
OtherToTools, | ||
IngotsToTools, | ||
|
||
Other | ||
} | ||
|
||
public static class BlueprintsHelper | ||
{ | ||
public static readonly MyObjectBuilderType COMPONENT = MyObjectBuilderType.Parse("MyObjectBuilder_Component"); | ||
public static readonly MyObjectBuilderType ORE = MyObjectBuilderType.Parse("MyObjectBuilder_Ore"); | ||
public static readonly MyObjectBuilderType INGOT = MyObjectBuilderType.Parse("MyObjectBuilder_Ingot"); | ||
public static readonly MyObjectBuilderType TOOL = MyObjectBuilderType.Parse("MyObjectBuilder_PhysicalGunObject"); | ||
public static readonly MyObjectBuilderType TOOL2 = MyObjectBuilderType.Parse("MyObjectBuilder_OxygenContainerObject"); | ||
|
||
public static BlueprintType GetBlueprintType(this MyBlueprintDefinitionBase b) | ||
{ | ||
var hasInputOres = false; | ||
var hasInputIngots = false; | ||
var hasInputComponents = false; | ||
var hasInputOther = false; | ||
|
||
var hasOutputOres = false; | ||
var hasOutputIngots = false; | ||
var hasOutputComponents = false; | ||
var hasOutputTools = false; | ||
var hasOutputOther = false; | ||
|
||
foreach (var r in b.Prerequisites) | ||
{ | ||
if (r.Id.TypeId == COMPONENT) | ||
{ | ||
hasInputComponents = true; | ||
continue; | ||
} | ||
if (r.Id.TypeId == ORE) | ||
{ | ||
hasInputOres = true; | ||
continue; | ||
} | ||
if (r.Id.TypeId == INGOT) | ||
{ | ||
hasInputIngots = true; | ||
continue; | ||
} | ||
|
||
hasInputOther = true; | ||
} | ||
|
||
foreach (var r in b.Results) | ||
{ | ||
if (r.Id.TypeId == COMPONENT) | ||
{ | ||
hasOutputComponents = true; | ||
continue; | ||
} | ||
if (r.Id.TypeId == TOOL || r.Id.TypeId == TOOL2) | ||
{ | ||
hasOutputTools = true; | ||
continue; | ||
} | ||
if (r.Id.TypeId == ORE) | ||
{ | ||
hasOutputOres = true; | ||
continue; | ||
} | ||
if (r.Id.TypeId == INGOT) | ||
{ | ||
hasOutputIngots = true; | ||
continue; | ||
} | ||
|
||
hasOutputOther = true; | ||
} | ||
|
||
var i = (hasInputOres ? 1 : 0) + (hasInputIngots ? 1 : 0) + (hasInputComponents ? 1 : 0) + (hasInputOther ? 1 : 0); | ||
var o = (hasOutputOres ? 1 : 0) + (hasOutputIngots ? 1 : 0) + (hasOutputComponents ? 1 : 0) + (hasOutputTools ? 1 : 0) + (hasOutputOther ? 1 : 0); | ||
|
||
if (i != 1) return BlueprintType.Other; | ||
if (o != 1) return BlueprintType.Other; | ||
|
||
if (hasOutputTools) return hasInputIngots ? BlueprintType.IngotsToTools : BlueprintType.OtherToTools; | ||
if (hasInputOres && hasOutputIngots) return b.Results.Length == 1 && b.Prerequisites.Length == 1 ? BlueprintType.OreToIngot : BlueprintType.OresToIngots; | ||
if (hasInputIngots && hasOutputComponents) return b.Results.Length > 1 ? BlueprintType.IngotsToComponents : BlueprintType.IngotsToComponent; | ||
if (hasInputOres && hasOutputOres) return BlueprintType.OresToOres; | ||
if (hasInputIngots && hasOutputIngots) return BlueprintType.IngotsToIngots; | ||
if (hasInputComponents && hasOutputComponents) return BlueprintType.ComponentsToComponents; | ||
if (hasOutputTools) return BlueprintType.IngotsToTools; | ||
|
||
return BlueprintType.Other; | ||
} | ||
} | ||
} |
Oops, something went wrong.