-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from Sigma88/Heads
Heads v0.1.0
- Loading branch information
Showing
19 changed files
with
1,321 additions
and
5 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 @@ | ||
**v0.1.0** | ||
|
||
- First Beta Release |
Binary file added
BIN
+34.5 KB
Heads/GameData/Sigma/Replacements/Heads/Plugins/SigmaReplacementsHeads.dll
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
Heads/GameData/Sigma/Replacements/Heads/Plugins/SigmaReplacementsHeads.version
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,25 @@ | ||
{ | ||
"NAME": "<b><color=#9B59B6>Sigma Replacements: Heads</color></b>", | ||
"URL": "https://raw.githubusercontent.com/Sigma88/Sigma-Replacements/master/Heads/GameData/Sigma/Replacements/Heads/Plugins/SigmaReplacementsHeads.version", | ||
"DOWNLOAD": "http://forum.kerbalspaceprogram.com/index.php?/topic/167233-0", | ||
"CHANGE_LOG_URL": "https://raw.githubusercontent.com/Sigma88/Sigma-Replacements/master/Heads/Changelog.txt", | ||
"GITHUB": | ||
{ | ||
"USERNAME": "Sigma88", | ||
"REPOSITORY": "Sigma-Replacements", | ||
"ALLOW_PRE_RELEASE": false | ||
}, | ||
"VERSION": | ||
{ | ||
"MAJOR": 0, | ||
"MINOR": 1, | ||
"PATCH": 0, | ||
"BUILD": 0 | ||
}, | ||
"KSP_VERSION": | ||
{ | ||
"MAJOR": 1, | ||
"MINOR": 3, | ||
"PATCH": 1 | ||
} | ||
} |
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,8 @@ | ||
Sigma Replacements: Heads by Sigma88 is released under the following license: | ||
|
||
|
||
All Rights Reserved | ||
|
||
|
||
For more info visit the KSP Forum Thread: | ||
http://forum.kerbalspaceprogram.com/index.php?/topic/167233-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Sigma Replacements: Heads | ||
|
||
|
||
**Customizeable Crew Heads** | ||
|
||
|
||
KSP Forum Thread: http://forum.kerbalspaceprogram.com/index.php?/topic/167233-0/ | ||
|
||
Download Latest Release: https://github.com/Sigma88/Sigma-Replacements/releases | ||
|
||
Dev version: https://github.com/Sigma88/Sigma-Replacements/tree/Heads |
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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
# Sigma Replacements | ||
|
||
|
||
**Hanles replacement of various KSP assets** | ||
**Handles replacement of various KSP assets** | ||
|
||
|
||
KSP Forum Thread: http://forum.kerbalspaceprogram.com/index.php?/topic/-0/ | ||
KSP Forum Thread: http://forum.kerbalspaceprogram.com/index.php?/topic/167233-0/ | ||
|
||
Download Latest Release: https://github.com/Sigma88/Sigma-KerbalReplacements/releases/latest | ||
|
||
Dev versions: | ||
|
||
- *Heads* https://github.com/Sigma88/Sigma-Replacements/tree/Heads | ||
- *Suits* https://github.com/Sigma88/Sigma-Replacements/tree/Suits | ||
- *Textures* https://github.com/Sigma88/Sigma-Replacements/tree/Textures | ||
- Heads - https://github.com/Sigma88/Sigma-Replacements/tree/Heads | ||
- Suits - https://github.com/Sigma88/Sigma-Replacements/tree/Suits | ||
- Textures - https://github.com/Sigma88/Sigma-Replacements/tree/Textures |
Binary file not shown.
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,223 @@ | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
|
||
namespace SigmaReplacements | ||
{ | ||
namespace Heads | ||
{ | ||
internal class CustomHead : MonoBehaviour | ||
{ | ||
// Colors | ||
Color? pupilLeft = null; | ||
Color? pupilRight = null; | ||
Color? eyeballLeft = null; | ||
Color? eyeballRight = null; | ||
Color? upTeeth01 = null; | ||
Color? upTeeth02 = null; | ||
Color? tongue = null; | ||
Color? head = null; | ||
Color? hair = null; | ||
Color? arm = null; | ||
|
||
// Textures | ||
Texture pupilLeftTex = null; | ||
Texture pupilRightTex = null; | ||
Texture eyeballLeftTex = null; | ||
Texture eyeballRightTex = null; | ||
Texture upTeeth01Tex = null; | ||
Texture upTeeth02Tex = null; | ||
Texture tongueTex = null; | ||
Texture headTex = null; | ||
Texture hairTex = null; | ||
Texture armTex = null; | ||
|
||
|
||
// Normals | ||
Texture pupilLeftNrm = null; | ||
Texture pupilRightNrm = null; | ||
Texture eyeballLeftNrm = null; | ||
Texture eyeballRightNrm = null; | ||
Texture upTeeth01Nrm = null; | ||
Texture upTeeth02Nrm = null; | ||
Texture tongueNrm = null; | ||
Texture headNrm = null; | ||
Texture hairNrm = null; | ||
Texture armNrm = null; | ||
|
||
|
||
void Start() | ||
{ | ||
Debug.Log("CustomHead.Start", "In gameObject = " + gameObject); | ||
Apply(); | ||
} | ||
|
||
internal void Apply() | ||
{ | ||
Debug.Log("CustomHead.Apply", "In gameObject = " + gameObject); | ||
|
||
ProtoCrewMember kerbal = GetComponent<KerbalEVA>()?.part?.protoModuleCrew?.FirstOrDefault(); | ||
if (kerbal == null) kerbal = GetComponent<kerbalExpressionSystem>()?.protoCrewMember; | ||
if (kerbal == null) kerbal = GetComponent<UIKerbalMenu>()?.crewMember; | ||
if (kerbal == null) kerbal = GetComponent<UIKerbalWerner>()?.crewMember; | ||
if (kerbal == null) kerbal = GetComponent<UIKerbalGene>()?.crewMember; | ||
if (kerbal == null) kerbal = GetComponent<UIKerbalStrategy>()?.crewMember; | ||
Debug.Log("CustomHead.Apply", "kerbal = " + kerbal); | ||
if (kerbal == null) return; | ||
|
||
LoadFor(kerbal); | ||
|
||
ApplyTo(kerbal); | ||
} | ||
|
||
void LoadFor(ProtoCrewMember kerbal) | ||
{ | ||
Debug.Log("CustomHead.LoadFor", "kerbal = " + kerbal); | ||
|
||
HeadInfo.hash = ""; | ||
int? useChance = null; | ||
|
||
for (int i = 0; i < HeadInfo.DataBase?.Count; i++) | ||
{ | ||
HeadInfo info = HeadInfo.DataBase[i].GetFor(kerbal); | ||
string collection = ""; | ||
|
||
if (info != null) | ||
{ | ||
if (string.IsNullOrEmpty(collection) || collection == info.collection) | ||
{ | ||
if (info.useChance != 1) | ||
useChance = kerbal.Hash(info.useGameSeed) % 100; | ||
|
||
if (info.useChance == 1 || useChance < info.useChance * 100) | ||
{ | ||
// Collection | ||
collection = info.collection; | ||
|
||
// Colors | ||
pupilLeft = pupilLeft ?? info.pupilLeft.Pick(kerbal, info.useGameSeed); | ||
pupilRight = pupilRight ?? info.pupilRight.At(pupilLeft, info.pupilLeft) ?? info.pupilRight.Pick(kerbal, info.useGameSeed); | ||
eyeballLeft = eyeballLeft ?? info.eyeballLeft.Pick(kerbal, info.useGameSeed); | ||
eyeballRight = eyeballRight ?? info.eyeballRight.At(eyeballLeft, info.eyeballLeft) ?? info.eyeballRight.Pick(kerbal, info.useGameSeed); | ||
upTeeth01 = upTeeth01 ?? info.upTeeth01.Pick(kerbal, info.useGameSeed); | ||
upTeeth02 = upTeeth02 ?? info.upTeeth02.At(upTeeth01, info.upTeeth01) ?? info.upTeeth02.Pick(kerbal, info.useGameSeed); | ||
tongue = tongue ?? info.tongue.Pick(kerbal, info.useGameSeed); | ||
head = head ?? info.head.Pick(kerbal, info.useGameSeed); | ||
hair = hair ?? info.hair.At(head, info.head) ?? info.hair.Pick(kerbal, info.useGameSeed); | ||
arm = arm ?? info.arm.Pick(kerbal, info.useGameSeed); | ||
|
||
// Textures | ||
pupilLeftTex = pupilLeftTex ?? info.pupilLeftTex.Pick(kerbal, info.useGameSeed); | ||
pupilRightTex = pupilRightTex ?? info.pupilRightTex.At(pupilLeftTex, info.pupilLeftTex) ?? info.pupilRightTex.Pick(kerbal, info.useGameSeed); | ||
eyeballLeftTex = eyeballLeftTex ?? info.eyeballLeftTex.Pick(kerbal, info.useGameSeed); | ||
eyeballRightTex = eyeballRightTex ?? info.eyeballRightTex.At(eyeballLeftTex, info.eyeballLeftTex) ?? info.eyeballRightTex.Pick(kerbal, info.useGameSeed); | ||
upTeeth01Tex = upTeeth01Tex ?? info.upTeeth01Tex.Pick(kerbal, info.useGameSeed); | ||
upTeeth02Tex = upTeeth02Tex ?? info.upTeeth02Tex.At(upTeeth01Tex, info.upTeeth01Tex) ?? info.upTeeth02Tex.Pick(kerbal, info.useGameSeed); | ||
tongueTex = tongueTex ?? info.tongueTex.Pick(kerbal, info.useGameSeed); | ||
headTex = headTex ?? info.headTex.Pick(kerbal, info.useGameSeed); | ||
hairTex = hairTex ?? info.hairTex.At(headTex, info.headTex) ?? info.hairTex.Pick(kerbal, info.useGameSeed); | ||
armTex = armTex ?? info.armTex.Pick(kerbal, info.useGameSeed); | ||
|
||
// Normals | ||
pupilLeftNrm = pupilLeftNrm ?? info.pupilLeftNrm.At(pupilLeftTex, info.pupilLeftTex) ?? info.pupilLeftNrm.Pick(kerbal, info.useGameSeed); | ||
pupilRightNrm = pupilRightNrm ?? info.pupilRightNrm.At(pupilRightTex, info.pupilRightTex) ?? info.pupilRightNrm.Pick(kerbal, info.useGameSeed); | ||
eyeballLeftNrm = eyeballLeftNrm ?? info.eyeballLeftNrm.At(eyeballLeftTex, info.eyeballLeftTex) ?? info.eyeballLeftNrm.Pick(kerbal, info.useGameSeed); | ||
eyeballRightNrm = eyeballRightNrm ?? info.eyeballRightNrm.At(eyeballRightTex, info.eyeballRightTex) ?? info.eyeballRightNrm.Pick(kerbal, info.useGameSeed); | ||
upTeeth01Nrm = upTeeth01Nrm ?? info.upTeeth01Nrm.At(upTeeth01Tex, info.upTeeth01Tex) ?? info.upTeeth01Nrm.Pick(kerbal, info.useGameSeed); | ||
upTeeth02Nrm = upTeeth02Nrm ?? info.upTeeth02Nrm.At(upTeeth02Tex, info.upTeeth02Tex) ?? info.upTeeth02Nrm.Pick(kerbal, info.useGameSeed); | ||
tongueNrm = tongueNrm ?? info.tongueNrm.At(tongueTex, info.tongueTex) ?? info.tongueNrm.Pick(kerbal, info.useGameSeed); | ||
headNrm = headNrm ?? info.headNrm.At(headTex, info.headTex) ?? info.headNrm.Pick(kerbal, info.useGameSeed); | ||
hairNrm = hairNrm ?? info.hairNrm.At(hairTex, info.hairTex) ?? info.hairNrm.Pick(kerbal, info.useGameSeed); | ||
armNrm = armNrm ?? info.armNrm.At(armTex, info.armTex) ?? info.armNrm.Pick(kerbal, info.useGameSeed); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
void ApplyTo(ProtoCrewMember kerbal) | ||
{ | ||
Debug.Log("CustomHead.ApplyTo", "kerbal = " + kerbal); | ||
|
||
Renderer[] renderers = GetComponentsInChildren<Renderer>(); | ||
|
||
for (int i = 0; i < renderers?.Length; i++) | ||
{ | ||
string name = renderers[i]?.name; | ||
Material material = renderers[i]?.material; | ||
if (material == null) continue; | ||
|
||
if (name == "pupilLeft" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_pupilLeft") | ||
{ | ||
material.SetColor(pupilLeft); | ||
material.SetTexture(pupilLeftTex); | ||
material.SetNormal(pupilLeftNrm); | ||
} | ||
|
||
if (name == "pupilRight" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_pupilRight") | ||
{ | ||
material.SetColor(pupilRight); | ||
material.SetTexture(pupilRightTex); | ||
material.SetNormal(pupilRightNrm); | ||
} | ||
|
||
if (name == "eyeballLeft" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_eyeballLeft") | ||
{ | ||
material.SetColor(eyeballLeft); | ||
material.SetTexture(eyeballLeftTex); | ||
material.SetNormal(eyeballLeftNrm); | ||
} | ||
|
||
if (name == "eyeballRight" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_eyeballRight") | ||
{ | ||
material.SetColor(eyeballRight); | ||
material.SetTexture(eyeballRightTex); | ||
material.SetNormal(eyeballRightNrm); | ||
} | ||
|
||
if (name == "upTeeth01" || name == "downTeeth01" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_downTeeth01") | ||
{ | ||
material.SetColor(upTeeth01); | ||
material.SetTexture(upTeeth01Tex); | ||
material.SetNormal(upTeeth01Nrm); | ||
} | ||
|
||
if (name == "upTeeth02" || name == "upTeeth01" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_upTeeth01") | ||
{ | ||
material.SetColor(upTeeth02); | ||
material.SetTexture(upTeeth02Tex); | ||
material.SetNormal(upTeeth02Nrm); | ||
} | ||
|
||
if (name == "tongue") | ||
{ | ||
material.SetColor(tongue); | ||
material.SetTexture(tongueTex); | ||
material.SetNormal(tongueNrm); | ||
} | ||
|
||
if (name == "headMesh01" || name == "headMesh" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_polySurface51") | ||
{ | ||
material.SetColor(head); | ||
material.SetTexture(headTex); | ||
material.SetNormal(headNrm); | ||
} | ||
|
||
if (name == "ponytail" || name == "mesh_female_kerbalAstronaut01_kerbalGirl_mesh_pCube1") | ||
{ | ||
material.SetColor(hair); | ||
material.SetTexture(hairTex); | ||
material.SetNormal(hairNrm); | ||
} | ||
|
||
if (name == "hand_left01" || name == "hand_right01") | ||
{ | ||
material.SetColor(arm); | ||
material.SetTexture(armTex); | ||
material.SetNormal(armNrm); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,51 @@ | ||
using UnityEngine; | ||
|
||
|
||
namespace SigmaReplacements | ||
{ | ||
internal static class Debug | ||
{ | ||
internal static bool debug = false; | ||
internal static string Tag = "[SigmaLog SR]"; | ||
|
||
internal static void Log(string message) | ||
{ | ||
if (debug) | ||
{ | ||
UnityEngine.Debug.Log(Tag + ": " + message); | ||
} | ||
} | ||
|
||
internal static void Log(string Method, string message) | ||
{ | ||
if (debug) | ||
{ | ||
UnityEngine.Debug.Log(Tag + " " + Method + ": " + message); | ||
} | ||
} | ||
} | ||
|
||
[KSPAddon(KSPAddon.Startup.MainMenu, true)] | ||
class DebugWarning : MonoBehaviour | ||
{ | ||
void Start() | ||
{ | ||
if (Debug.debug) | ||
{ | ||
PopupDialog.SpawnPopupDialog | ||
( | ||
new Vector2(0.5f, 0.5f), | ||
new Vector2(0.5f, 0.5f), | ||
UserSettings.nodeName, | ||
UserSettings.nodeName + " Warning", | ||
"\n<color=#FF9231><b>Debug Spam is activated.</b>\n\n" + | ||
"This feature will greatly affect performance:\n" + | ||
"use it only for debugging purposes.</color>", | ||
"OK", | ||
true, | ||
UISkinManager.GetSkin("MainMenuSkin") | ||
); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.