Skip to content

Commit

Permalink
Add different slide reel prefabs (#879)
Browse files Browse the repository at this point in the history
## Minor features

- New `reelModel` and `reelCondition` parameters in prop `slideShows`
for slide reel mesh and material. (#811)
- Models: 6-slided, 7-slided, 8-slided, and Whole (7-slided but
connected like 8-slided).
- Conditions: Antique (Stranger), Pristine (Dreamworld), Rusted (Burnt)
- `rotate` parameter added to slide info. Rotates the slide reel item
while inside a projector.
  • Loading branch information
MegaPiggy authored Jun 4, 2024
2 parents df7cbae + 3289a9c commit 7a44824
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 18 deletions.
Binary file modified NewHorizons/Assets/newhorizons_private
Binary file not shown.
31 changes: 28 additions & 3 deletions NewHorizons/Assets/newhorizons_private.manifest
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ManifestFileVersion: 0
CRC: 3537427957
CRC: 423323461
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: c4d8f41970054074bb375ac5cbe82855
Hash: 4199cf66477e2054e4ac61871d811161
TypeTreeHash:
serializedVersion: 2
Hash: de71b9c55befb829b1640ea21774b932
Hash: 83784250589f972ee0b86ea39a5a5305
HashAppended: 0
ClassTypes:
- Class: 1
Expand All @@ -17,6 +17,8 @@ ClassTypes:
Script: {instanceID: 0}
- Class: 23
Script: {instanceID: 0}
- Class: 28
Script: {instanceID: 0}
- Class: 33
Script: {instanceID: 0}
- Class: 43
Expand Down Expand Up @@ -75,6 +77,8 @@ ClassTypes:
Script: {fileID: 11500000, guid: 040dd594681f07a4a975890a61d44be5, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 327eb94566c9e284dae5d7b1cfe11ccd, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 8d56b3759dd12424c8425ed62fc02796, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: c317f6a5634f15f4c80f89e306616924, type: 3}
- Class: 114
Expand All @@ -97,10 +101,14 @@ ClassTypes:
Script: {fileID: 11500000, guid: b4b79e57677045045a95bfe4fe447ce5, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 64247dd7b0c5ac640a6d9ae5360a0f5a, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: f645b92850d716a4488617b651223700, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 8ef66a28deb09ab4aaba30bb60b9f19a, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 0863077874402f14dba0ca4ae81752dd, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: bf998978a8a701b4eb09fcd94048f916, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: a9da74c8b134add4ba1d884336a5e075, type: 3}
- Class: 114
Expand Down Expand Up @@ -171,7 +179,24 @@ ClassTypes:
Script: {instanceID: 0}
SerializeReferenceClassIdentifiers: []
Assets:
- Assets/SlideReels/Prefab_DW_Reel_Whole.prefab
- Assets/SlideReels/Prefab_IP_Reel_Rusted_7.prefab
- Assets/SlideReels/Prefab_IP_Reel_Destroyed_6.prefab
- Assets/SlideReels/Effects_IP_SIM_SlideReel.prefab
- Assets/SlideReels/Prefab_DW_Reel_7.prefab
- Assets/SlideReels/Prefab_IP_Reel_Rusted_6.prefab
- Assets/SlideReels/Prefab_IP_Reel_Rusted_8.prefab
- Assets/SlideReels/Prefab_DW_Reel_6.prefab
- Assets/SlideReels/Prefab_IP_Reel_8.prefab
- Assets/SlideReels/Prefab_IP_Reel_6.prefab
- Assets/SlideReels/Prefab_IP_Reel_Destroyed_7.prefab
- Assets/SlideReels/Prefab_IP_Reel_Destroyed_Whole.prefab
- Assets/SlideReels/Prefab_IP_Reel_Destroyed_8.prefab
- Assets/SlideReels/Prefab_IP_Reel_Whole.prefab
- Assets/SlideReels/Prefab_IP_Reel_Rusted_Whole.prefab
- Assets/BrambleCollision.prefab
- Assets/SlideReels/Prefab_DW_Reel_8.prefab
- Assets/Vessel_Body.prefab
- Assets/AmbientLight_QM.png
- Assets/SlideReels/Prefab_IP_Reel_7.prefab
Dependencies: []
155 changes: 140 additions & 15 deletions NewHorizons/Builder/Props/ProjectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,29 @@
using System.IO;
using System.Threading;
using UnityEngine;
using static NewHorizons.Main;

namespace NewHorizons.Builder.Props
{
public static class ProjectionBuilder
{
private static GameObject _slideReelPrefab;
public static GameObject SlideReelWholePrefab { get; private set; }
public static GameObject SlideReelWholePristinePrefab { get; private set; }
public static GameObject SlideReelWholeRustedPrefab { get; private set; }
public static GameObject SlideReelWholeDestroyedPrefab { get; private set; }
public static GameObject SlideReel8Prefab { get; private set; }
public static GameObject SlideReel8PristinePrefab { get; private set; }
public static GameObject SlideReel8RustedPrefab { get; private set; }
public static GameObject SlideReel8DestroyedPrefab { get; private set; }
public static GameObject SlideReel7Prefab { get; private set; }
public static GameObject SlideReel7PristinePrefab { get; private set; }
public static GameObject SlideReel7RustedPrefab { get; private set; }
public static GameObject SlideReel7DestroyedPrefab { get; private set; }
public static GameObject SlideReel6Prefab { get; private set; }
public static GameObject SlideReel6PristinePrefab { get; private set; }
public static GameObject SlideReel6RustedPrefab { get; private set; }
public static GameObject SlideReel6DestroyedPrefab { get; private set; }

private static GameObject _autoPrefab;
private static GameObject _visionTorchDetectorPrefab;
private static GameObject _standingVisionTorchPrefab;
Expand All @@ -29,14 +46,22 @@ internal static void InitPrefabs()

_isInit = true;

if (_slideReelPrefab == null)
{
_slideReelPrefab = SearchUtilities.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath")?.gameObject?.InstantiateInactive()?.Rename("Prefab_IP_Reel")?.DontDestroyOnLoad();
if (_slideReelPrefab == null)
NHLogger.LogWarning($"Tried to make slide reel prefab but couldn't. Do you have the DLC installed?");
else
_slideReelPrefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
}
SlideReelWholePrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Whole");
SlideReelWholePristinePrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_DW_Reel_Whole");
SlideReelWholeRustedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Rusted_Whole");
SlideReelWholeDestroyedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Destroyed_Whole");
SlideReel8Prefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_8");
SlideReel8PristinePrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_DW_Reel_8");
SlideReel8RustedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Rusted_8");
SlideReel8DestroyedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Destroyed_8");
SlideReel7Prefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_7");
SlideReel7PristinePrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_DW_Reel_7");
SlideReel7RustedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Rusted_7");
SlideReel7DestroyedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Destroyed_7");
SlideReel6Prefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_6");
SlideReel6PristinePrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_DW_Reel_6");
SlideReel6RustedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Rusted_6");
SlideReel6DestroyedPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Prefab_IP_Reel_Destroyed_6");

if (_autoPrefab == null)
{
Expand Down Expand Up @@ -92,9 +117,11 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Proj
{
InitPrefabs();

if (_slideReelPrefab == null) return null;
GameObject prefab = GetSlideReelPrefab(info.reelModel, info.reelCondition);

if (prefab == null) return null;

var slideReelObj = GeneralPropBuilder.MakeFromPrefab(_slideReelPrefab, $"Prefab_IP_Reel_{mod.ModHelper.Manifest.Name}", planetGO, sector, info);
var slideReelObj = GeneralPropBuilder.MakeFromPrefab(prefab, $"Prefab_IP_Reel_{GetSlideReelName(info.reelModel, info.reelCondition)}_{mod.ModHelper.Manifest.Name}", planetGO, sector, info);

var slideReel = slideReelObj.GetComponent<SlideReelItem>();
slideReel.SetSector(sector);
Expand Down Expand Up @@ -124,25 +151,27 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Proj
int displaySlidesLoaded = 0;
imageLoader.imageLoadedEvent.AddListener(
(Texture2D tex, int index) =>
{
{
slideCollection.slides[index]._image = ImageUtilities.Invert(tex);

// Track the first 15 to put on the slide reel object
if (index < textures.Length)
{
textures[index] = tex;
if (Interlocked.Increment(ref displaySlidesLoaded) == textures.Length)
if (Interlocked.Increment(ref displaySlidesLoaded) >= textures.Length)
{
// all textures required to build the reel's textures have been loaded
var slidesBack = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Back").GetComponent<MeshRenderer>();
var slidesFront = slideReelObj.transform.Find("Props_IP_SlideReel_7/Slides_Front").GetComponent<MeshRenderer>();
var slidesBack = slideReelObj.GetComponentInChildren<TransformAnimator>().transform.Find("Slides_Back").GetComponent<MeshRenderer>();
var slidesFront = slideReelObj.GetComponentInChildren<TransformAnimator>().transform.Find("Slides_Front").GetComponent<MeshRenderer>();

// Now put together the textures into a 4x4 thing for the materials
var reelTexture = ImageUtilities.MakeReelTexture(textures);
slidesBack.material.mainTexture = reelTexture;
slidesBack.material.SetTexture(EmissionMap, reelTexture);
slidesBack.material.name = reelTexture.name;
slidesFront.material.mainTexture = reelTexture;
slidesFront.material.SetTexture(EmissionMap, reelTexture);
slidesFront.material.name = reelTexture.name;
}
}
}
Expand All @@ -162,6 +191,97 @@ private static GameObject MakeSlideReel(GameObject planetGO, Sector sector, Proj
return slideReelObj;
}

private static GameObject GetSlideReelPrefab(ProjectionInfo.SlideReelType model, ProjectionInfo.SlideReelCondition condition)
{
switch (model)
{
case ProjectionInfo.SlideReelType.SixSlides:
{
switch (condition)
{
case ProjectionInfo.SlideReelCondition.Antique:
default:
return SlideReel6Prefab;
case ProjectionInfo.SlideReelCondition.Pristine:
return SlideReel6PristinePrefab;
case ProjectionInfo.SlideReelCondition.Rusted:
return SlideReel6RustedPrefab;
}
}
case ProjectionInfo.SlideReelType.SevenSlides:
default:
{
switch (condition)
{
case ProjectionInfo.SlideReelCondition.Antique:
default:
return SlideReel7Prefab;
case ProjectionInfo.SlideReelCondition.Pristine:
return SlideReel7PristinePrefab;
case ProjectionInfo.SlideReelCondition.Rusted:
return SlideReel7RustedPrefab;
}
}
case ProjectionInfo.SlideReelType.EightSlides:
{
switch (condition)
{
case ProjectionInfo.SlideReelCondition.Antique:
default:
return SlideReel8Prefab;
case ProjectionInfo.SlideReelCondition.Pristine:
return SlideReel8PristinePrefab;
case ProjectionInfo.SlideReelCondition.Rusted:
return SlideReel8RustedPrefab;
}
}
case ProjectionInfo.SlideReelType.Whole:
{
switch (condition)
{
case ProjectionInfo.SlideReelCondition.Antique:
default:
return SlideReelWholePrefab;
case ProjectionInfo.SlideReelCondition.Pristine:
return SlideReelWholePristinePrefab;
case ProjectionInfo.SlideReelCondition.Rusted:
return SlideReelWholeRustedPrefab;
}
}
}
}

public static string GetSlideReelName(ProjectionInfo.SlideReelType model, ProjectionInfo.SlideReelCondition condition)
{
switch (model)
{
case ProjectionInfo.SlideReelType.SixSlides:
return $"6_{condition}";
case ProjectionInfo.SlideReelType.SevenSlides:
return $"7_{condition}";
case ProjectionInfo.SlideReelType.EightSlides:
return $"8_{condition}";
case ProjectionInfo.SlideReelType.Whole:
default:
return $"{model}_{condition}";
}
}

public static int GetSlideCount(ProjectionInfo.SlideReelType model)
{
switch (model)
{
case ProjectionInfo.SlideReelType.SixSlides:
return 6;
case ProjectionInfo.SlideReelType.SevenSlides:
case ProjectionInfo.SlideReelType.Whole:
return 7;
case ProjectionInfo.SlideReelType.EightSlides:
default:
return 8;
}
}

public static GameObject MakeAutoProjector(GameObject planetGO, Sector sector, ProjectionInfo info, IModBehaviour mod)
{
InitPrefabs();
Expand Down Expand Up @@ -314,6 +434,7 @@ private static ImageUtilities.AsyncImageLoader AddAsyncLoader(GameObject gameObj
{
var slide = new Slide();
var slideInfo = slides[i];
slide._streamingImageID = i; // for SlideRotationModule

if (string.IsNullOrEmpty(slideInfo.imagePath))
{
Expand Down Expand Up @@ -388,6 +509,10 @@ private static void AddModules(SlideInfo slideInfo, ref Slide slide, IModBehavio
};
modules.Add(shipLogEntry);
}
if (slideInfo.rotate)
{
modules.Add(new SlideRotationModule());
}

Slide.WriteModules(modules, ref slide._modulesList, ref slide._modulesData, ref slide.lengths);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ public enum SlideShowType

}

[JsonConverter(typeof(StringEnumConverter))]
public enum SlideReelType
{
[EnumMember(Value = @"sixSlides")] SixSlides = 6,

[EnumMember(Value = @"sevenSlides")] SevenSlides = 7,

[EnumMember(Value = @"eightSlides")] EightSlides = 8,

[EnumMember(Value = @"whole")] Whole = 9,
}

[JsonConverter(typeof(StringEnumConverter))]
public enum SlideReelCondition
{
[EnumMember(Value = @"antique")] Antique = 0,

[EnumMember(Value = @"pristine")] Pristine = 1,

[EnumMember(Value = @"rusted")] Rusted = 2,
}

/// <summary>
/// The ship log facts revealed after finishing this slide reel.
/// </summary>
Expand All @@ -43,6 +65,16 @@ public enum SlideShowType
/// The type of object this is.
/// </summary>
[DefaultValue("slideReel")] public SlideShowType type = SlideShowType.SlideReel;

/// <summary>
/// Exclusive to the slide reel type. Model/mesh of the reel. Each model has a different number of slides on it. Whole has 7 slides but a full ring like 8.
/// </summary>
[DefaultValue("sevenSlides")] public SlideReelType reelModel = SlideReelType.SevenSlides;

/// <summary>
/// Exclusive to the slide reel type. Condition/material of the reel. Antique is the Stranger, Pristine is the Dreamworld, Rusted is a burned reel.
/// </summary>
[DefaultValue("antique")] public SlideReelCondition reelCondition = SlideReelCondition.Antique;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,12 @@ public class SlideInfo
/// Set this to include ship log entry module. Base game default is "".
/// </summary>
public string reveal;

// SlideRotationModule

/// <summary>
/// Exclusive to slide reels. Whether this slide should rotate the reel item while inside a projector.
/// </summary>
[DefaultValue(true)] public bool rotate = true;
}
}
Loading

0 comments on commit 7a44824

Please sign in to comment.