Integrate fuel line and strut variants

1-10-updates
Andrew Cassidy 4 years ago
parent 2e6a9d5190
commit 1671a65656
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1

@ -64,7 +64,6 @@ Localization
#LOC_Restock_variant-mounting_compact = Compact
#LOC_Restock_variant-mounting_mounted = Mounted
#LOC_Restock_variant-gold-truss = Gold (Mounted)
#LOC_Restock_variant-silver-truss = Silver (Mounted)
@ -96,12 +95,18 @@ Localization
#LOC_Restock_variant-surface_truss = Truss
#LOC_Restock_variant-surface_warningStripes = Warning Stripes
#LOC_Restock_variant-surface_thermalblankets = Insulated
#LOC_Restock_variant-decoupler_metal = Metal
#LOC_Restock_variant-decoupler_grey-orange = Orange/Grey
#LOC_Restock_variant-surface_yellow = Yellow
#LOC_Restock_variant-surface_black = Black
#LOC_Restock_variant-surface_white = White
#LOC_Restock_variant-surface_blue = Blue
#LOC_Restock_variant-strut_classic_metal = Metal
#LOC_Restock_variant-strut_classic_white = White
#LOC_Restock_variant-strut_compact_metal = Metal (Compact)
#LOC_Restock_variant-strut_compact_white = White (Compact)
#LOC_Restock_variant-decoupler_metal = Metal
#LOC_Restock_variant-decoupler_grey-orange = Orange/Grey
#LOC_Restock_variant-service-bay-opaque = Solid Caps
#LOC_Restock_variant-service-bay-transparent = Truss Caps

@ -26,14 +26,16 @@
stretchAxis = x
stretchTextures = _MainTex _BumpMap
}
!MODULE[ModulePartVariants] {}
MODULE
{
name = ModulePartVariants
useMultipleDragCubes = false
baseVariant = Yellow
baseVariant = YellowAndWhite
VARIANT
{
name = Yellow
name = YellowAndWhite
displayName = #LOC_Restock_variant-surface_yellow
themeName = YellowAndWhite
primaryColor = #B08D43
@ -44,6 +46,8 @@
line_black = false
line_metal = false
line_sofi = false
line_white = false
line_blue = false
}
}
VARIANT
@ -59,6 +63,8 @@
line_black = true
line_metal = false
line_sofi = false
line_white = false
line_blue = false
}
}
VARIANT
@ -74,6 +80,8 @@
line_black = false
line_metal = true
line_sofi = false
line_white = false
line_blue = false
}
}
VARIANT
@ -81,7 +89,7 @@
name = Orange
displayName = #autoLOC_8007123
themeName = Orange
primaryColor = #B08D43
primaryColor = #A55929
secondaryColor = #999999
GAMEOBJECTS
{
@ -89,6 +97,42 @@
line_black = false
line_metal = false
line_sofi = true
line_white = false
line_blue = false
}
}
VARIANT
{
name = White
displayName = #LOC_Restock_variant-surface_white
themeName = White
primaryColor = #ffffff
secondaryColor = #999999
GAMEOBJECTS
{
line_yellow = false
line_black = false
line_metal = false
line_sofi = false
line_white = true
line_blue = false
}
}
VARIANT
{
name = Blue
displayName = #LOC_Restock_variant-surface_blue
themeName = White
primaryColor = #426573
secondaryColor = #999999
GAMEOBJECTS
{
line_yellow = false
line_black = false
line_metal = false
line_sofi = false
line_white = false
line_blue = true
}
}
}

@ -26,16 +26,18 @@
stretchAxis = x
stretchTextures = _MainTex _BumpMap
}
!MODULE[ModulePartVariants] {}
MODULE
{
name = ModulePartVariants
useMultipleDragCubes = false
baseVariant = Classic
baseVariant = Gray
VARIANT
{
name = Classic
displayName = #LOC_Restock_variant-mounting_classic
themeName = White
name = Gray
displayName = #LOC_Restock_variant-strut_classic_metal
themeName = Metal
primaryColor = #6f6e6d
secondaryColor = #999999
GAMEOBJECTS
@ -44,13 +46,19 @@
strut_target_body_classic = true
strut_main_body_compact = false
strut_target_body_compact = false
strut_main_body_classic_white = false
strut_target_body_classic_white = false
strut_main_body_compact_white = false
strut_target_body_compact_white = false
strut_metal = true
strut_white = false
}
}
VARIANT
{
name = Compact
displayName = #LOC_Restock_variant-mounting_compact
themeName = White
displayName = #LOC_Restock_variant-strut_compact_metal
themeName = Metal
primaryColor = #6f6e6d
secondaryColor = #999999
GAMEOBJECTS
@ -59,6 +67,54 @@
strut_target_body_classic = false
strut_main_body_compact = true
strut_target_body_compact = true
strut_main_body_classic_white = false
strut_target_body_classic_white = false
strut_main_body_compact_white = false
strut_target_body_compact_white = false
strut_metal = true
strut_white = false
}
}
VARIANT
{
name = White
displayName = #LOC_Restock_variant-strut_classic_white
themeName = White
primaryColor = #ffffff
secondaryColor = #999999
GAMEOBJECTS
{
strut_main_body_classic = false
strut_target_body_classic = false
strut_main_body_compact = false
strut_target_body_compact = false
strut_main_body_classic_white = true
strut_target_body_classic_white = true
strut_main_body_compact_white = false
strut_target_body_compact_white = false
strut_metal = false
strut_white = true
}
}
VARIANT
{
name = White_Compact
displayName = #LOC_Restock_variant-strut_compact_white
themeName = White
primaryColor = #ffffff
secondaryColor = #999999
GAMEOBJECTS
{
strut_main_body_classic = false
strut_target_body_classic = false
strut_main_body_compact = false
strut_target_body_compact = false
strut_main_body_classic_white = false
strut_target_body_classic_white = false
strut_main_body_compact_white = true
strut_target_body_compact_white = true
strut_metal = false
strut_white = true
}
}
}

@ -1,5 +1,6 @@
v1.2.0
------
- KSP 1.10
- New stock part replacements
- Resources
-FTE-1 Drain Valve (Andrew Cassidy): now has metal and warning stripe variants
@ -11,6 +12,9 @@ v1.2.0
- Mk2 Command Pod (Andrew Cassidy): Now has dark and white variants.
- Coupling
- Inflatable Airlock (Andrew Cassidy): now has built in decoupler and optional ring to connect seamlessly with KV-series pods. Has a new IVA.
- Bugfixes and tweaks
- New White and White (compact) variants for EAS-4 Strut Connector
- New White and Blue variants for the FTX-2 External Fuel Duct
v1.1.2
------

@ -5,42 +5,40 @@ namespace Restock
{
/* Extends the stock CModuleLinkedMesh used on struts and pipes to make pipe textures repeat instead of stretch when
a pipe is extended beyond its default length */
public class ModuleRestockLinkedMesh : CModuleLinkedMesh
{
// the direction along the texture that the pipe points. set to "x" or "y"
[KSPField]
public string stretchAxis = "x";
[KSPField] public string stretchAxis = "x";
// space-seperated list of textures to be effected by the length, preferably all of the ones on the material
// Unity has no good way to get all the texture names attached to a material so it has to be set manually, unfortunately
[KSPField]
public string stretchTextures = "_MainTex";
[KSPField] public string stretchTextures = "_MainTex";
// reference to the material we will be modifying
private Material[] pipeMaterials;
// array of property IDs corresponding to the textures
private int[] pipeMaterialIDs;
// index of the texture scale vector, 0 for x, 1 for y
private int pipeStretchIndex;
// initial scale of the pipe object, may not be 1
private float baseStretch;
// scale vector for the material
private Vector2 texScale = Vector2.one;
// offset vector for the material
private Vector2 texOffset = Vector2.zero;
public override void OnStart(StartState state)
{
base.OnStart(state);
// get all materials on the line object, including disabled ones
var renderers = line.GetComponentsInChildren<MeshRenderer>(true);
pipeMaterials = new Material[renderers.Length];
@ -48,7 +46,7 @@ namespace Restock
{
pipeMaterials[i] = renderers[i].material;
}
// split texture list and convert to property IDs for easy access
var texNames = stretchTextures.Split(' ');
pipeMaterialIDs = new int[texNames.Length];
@ -56,11 +54,11 @@ namespace Restock
{
pipeMaterialIDs[i] = Shader.PropertyToID(texNames[i]);
}
// default to 'x' if an invalid value is used
pipeStretchIndex = stretchAxis != "y" ? 0 : 1;
baseStretch = part.scaleFactor;
GameEvents.onEditorVariantApplied.Add(OnVariantApplied);
}
@ -91,23 +89,24 @@ namespace Restock
{
if (appliedPart == part) UpdateStretch();
}
// updates the texture stretch to match the pipe object's local scale
private void UpdateStretch()
{
var stretch = line.localScale.z / baseStretch;
texScale[pipeStretchIndex] = stretch;
texOffset[pipeStretchIndex] = (1 - stretch) / 2;
for (var i = 0; i < pipeMaterials.Length; i++)
foreach (var material in pipeMaterials)
{
var material = pipeMaterials[i];
for (var j = 0; j < pipeMaterialIDs.Length; j++)
foreach (var id in pipeMaterialIDs)
{
var id = pipeMaterialIDs[j];
material.SetTextureScale(id, texScale);
material.SetTextureOffset(id, texOffset);
if (material.HasProperty(id))
{
material.SetTextureScale(id, texScale);
material.SetTextureOffset(id, texOffset);
}
}
}
}

Loading…
Cancel
Save