Skip to content

Commit

Permalink
Add utility
Browse files Browse the repository at this point in the history
  • Loading branch information
jixxed committed Jan 28, 2024
1 parent 15e230c commit 7191196
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 0 deletions.
7 changes: 7 additions & 0 deletions StationieersMods/StationeersMods.Interface/ShaderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StationeersMods.Interface
{
public enum ShaderType
{
EMISSIVE, NORMAL, CUTABLE
}
}
18 changes: 18 additions & 0 deletions StationieersMods/StationeersMods.Interface/StationeersColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace StationeersMods.Interface
{
public enum StationeersColor
{
BLUE=0,
GRAY=1,
GREEN=2,
ORANGE=3,
RED=4,
YELLOW=5,
WHITE=6,
BLACK=7,
BROWN=8,
KHAKI=9,
PINK=10,
PURPLE=11
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<Compile Include="ContentHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="..\AssemblyInfo.cs" />
<Compile Include="ShaderType.cs" />
<Compile Include="StationeersColor.cs" />
<Compile Include="StationeersModsUtility.cs" />
<Compile Include="StationeersTool.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Assets.Scripts;
using Assets.Scripts.Objects;
using Assets.Scripts.Util;
using UnityEngine;

namespace StationeersMods.Interface
{
public class StationeersModsUtility
{

public static Material GetMaterial(StationeersColor color, ShaderType shaderType)
{
ref List<ColorSwatch> customColors = ref Singleton<GameManager>.Instance.CustomColors;
ColorSwatch customColor = customColors[(int)color];
switch (shaderType)
{
case ShaderType.NORMAL:
return customColor.Normal;
case ShaderType.EMISSIVE:
return customColor.Emissive;
case ShaderType.CUTABLE:
return customColor.Cutable;
default:
throw new ArgumentOutOfRangeException(nameof(shaderType), shaderType, null);
}
}

public static Material GetMaterial(string materialName)
{
return (Material) Resources.Load("Objects/Models/Materials/" + materialName, typeof(Material));
}

public static Material[] GetBlueprintMaterials(int size)
{
var blueprintMaterial = FindPrefab("StructureFrame").Blueprint.GetComponent<MeshRenderer>().materials[0];
var materials = new Material[size];
Array.Fill(materials, blueprintMaterial, 0, size);
return materials;
}

public static Thing FindPrefab(string prefabName)
{
return WorldManager.Instance.SourcePrefabs.Find((Thing prefab) => prefab != null && prefabName.Equals(prefab.PrefabName));
}

public static Item FindTool(StationeersTool tool)
{
return FindPrefab(tool.PrefabName).GetComponent<Item>();
}
}
}
24 changes: 24 additions & 0 deletions StationieersMods/StationeersMods.Interface/StationeersTool.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace StationeersMods.Interface
{
public class StationeersTool
{
public static StationeersTool ANGLE_GRINDER = new StationeersTool( "ItemAngleGrinder");
public static StationeersTool WELDER = new StationeersTool( "ItemWeldingTorch");
public static StationeersTool CABLE_CUTTERS = new StationeersTool( "ItemWireCutters");
public static StationeersTool CROWBAR = new StationeersTool( "ItemCrowbar");
public static StationeersTool DRILL = new StationeersTool( "ItemDrill");
public static StationeersTool MINING_DRILL = new StationeersTool( "ItemMiningDrill");
public static StationeersTool PICKAXE = new StationeersTool( "ItemPickaxe");
public static StationeersTool DUCT_TAPE = new StationeersTool( "ItemDuctTape");
public static StationeersTool FIRE_EXTINGUISHER = new StationeersTool( "ItemFireExtinguisher");
public static StationeersTool LABELLER = new StationeersTool( "ItemLabeller");
public static StationeersTool WRENCH = new StationeersTool( "ItemWrench");
public static StationeersTool SCREWDRIVER = new StationeersTool( "ItemScrewdrive");
public string PrefabName { get; private set; }

public StationeersTool(string prefabName)
{
PrefabName = prefabName;
}
}
}

0 comments on commit 7191196

Please sign in to comment.