Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiWorm0 committed Jun 6, 2024
2 parents 71a841a + f4d543a commit 1e86a48
Show file tree
Hide file tree
Showing 39 changed files with 732 additions and 71 deletions.
Binary file modified LevelImposter/Assets/Assets
Binary file not shown.
5 changes: 4 additions & 1 deletion LevelImposter/Assets/Assets.manifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ManifestFileVersion: 0
CRC: 2386985233
CRC: 2742641410
AssetBundleManifest:
AssetBundleInfos:
Info_0:
Name: shop
Dependencies: {}
Info_1:
Name: loadingbar
Dependencies: {}
Binary file added LevelImposter/Assets/loadingbar
Binary file not shown.
77 changes: 77 additions & 0 deletions LevelImposter/Assets/loadingbar.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
ManifestFileVersion: 0
CRC: 3049509670
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: 2e5e38824854ae56f754be848fb8fa52
TypeTreeHash:
serializedVersion: 2
Hash: 7c653b85788f9e6027325f678c0f4f02
HashAppended: 0
ClassTypes:
- Class: 1
Script: {instanceID: 0}
- Class: 4
Script: {instanceID: 0}
- Class: 21
Script: {instanceID: 0}
- Class: 23
Script: {instanceID: 0}
- Class: 28
Script: {instanceID: 0}
- Class: 48
Script: {instanceID: 0}
- Class: 114
Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: e27d931aa83cda344a1633cd123a82c9, type: 3}
- Class: 115
Script: {instanceID: 0}
- Class: 128
Script: {instanceID: 0}
- Class: 212
Script: {instanceID: 0}
- Class: 213
Script: {instanceID: 0}
- Class: 224
Script: {instanceID: 0}
- Class: 331
Script: {instanceID: 0}
SerializeReferenceClassIdentifiers:
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.FaceInfo_Legacy
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.FontAssetCreationSettings
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.KerningTable
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.TMP_Character
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.TMP_FontFeatureTable
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.TMP_FontWeightPair
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.TMP_GlyphAdjustmentRecord
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.TMP_GlyphPairAdjustmentRecord
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.TMP_GlyphValueRecord
- AssemblyName: Unity.TextMeshPro
ClassName: TMPro.VertexGradient
- AssemblyName: UnityEngine.CoreModule
ClassName: UnityEngine.Events.PersistentCallGroup
- AssemblyName: UnityEngine.TextCoreModule
ClassName: UnityEngine.TextCore.FaceInfo
- AssemblyName: UnityEngine.TextCoreModule
ClassName: UnityEngine.TextCore.Glyph
- AssemblyName: UnityEngine.TextCoreModule
ClassName: UnityEngine.TextCore.GlyphMetrics
- AssemblyName: UnityEngine.TextCoreModule
ClassName: UnityEngine.TextCore.GlyphRect
- AssemblyName: UnityEngine.UI
ClassName: UnityEngine.UI.MaskableGraphic/CullStateChangedEvent
Assets:
- Assets/Prefabs/LoadingBar.prefab
Dependencies: []
Binary file modified LevelImposter/Assets/shop
Binary file not shown.
4 changes: 2 additions & 2 deletions LevelImposter/Assets/shop.manifest
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
ManifestFileVersion: 0
CRC: 3599790525
CRC: 4005544444
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: e2dbbc72aa56e5fcbee1c2078a7f2c27
Hash: 95736c394c97a65fc511c7395fb99918
TypeTreeHash:
serializedVersion: 2
Hash: afd525e58be886efe4d69cac465cee90
Expand Down
9 changes: 9 additions & 0 deletions LevelImposter/Builders/BuildRouter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,20 @@ public class BuildRouter
new TriggerAreaBuilder(),
new TriggerConsoleBuilder(),
new TriggerStartBuilder(),
new TriggerDeathBuilder(),
new TriggerShakeBuilder(),

new TriggerBuilder(),
new CustomTextBuilder(),
new ColorBuilder()
};

/// <summary>
/// Patch me to add your own custom builders.
/// Builders should implement <c>IElemBuilder</c>.
/// </summary>
public BuildRouter() { }

/// <summary>
/// Passes <c>LIElement</c> data through the build
/// stack to construct a GameObject.
Expand Down
68 changes: 68 additions & 0 deletions LevelImposter/Builders/Generic/CustomTextBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using LevelImposter.Core;
using System.Collections.Generic;
using UnityEngine;

namespace LevelImposter.Builders
{
/// <summary>
/// Replaces String in the Translation Controller with Custom Text
/// </summary>
public class CustomTextBuilder : IElemBuilder
{
private readonly Dictionary<string, StringNames> _customTextDB = new Dictionary<string, StringNames>
{
{ "MedHello", StringNames.MedHello },
{ "SamplesPress", StringNames.SamplesPress },
{ "SamplesSelect", StringNames.SamplesSelect },
{ "MedETA", StringNames.MedETA },
{ "BadResult", StringNames.BadResult },
{ "SamplesThanks", StringNames.SamplesThanks },
{ "SamplesComplete", StringNames.SamplesComplete },
{ "More", StringNames.More },
{ "SamplesAdding", StringNames.SamplesAdding },
{ "TakeBreak", StringNames.TakeBreak },
{ "GrabCoffee", StringNames.GrabCoffee },
{ "DontNeedWait", StringNames.DontNeedWait },
{ "DoSomethingElse", StringNames.DoSomethingElse },
{ "ReactorNominal", StringNames.ReactorNominal },
{ "ReactorHoldToStop", StringNames.ReactorHoldToStop },
{ "ReactorWaiting", StringNames.ReactorWaiting },
};

public void Build(LIElement elem, GameObject obj)
{
// Get Custom Text
var customText = elem.properties.customText;
if (customText == null || customText.Count <= 0)
return;

// ShipStatus
var shipStatus = LIShipStatus.Instance;
if (shipStatus == null)
throw new MissingShipException();

// Replace Custom Text
foreach (var (textID, text) in customText)
{
// Skip Empty Text
if (string.IsNullOrEmpty(textID) || string.IsNullOrEmpty(text))
continue;

// Find String Name
bool hasTextID = _customTextDB.TryGetValue(textID, out StringNames stringName);
if (!hasTextID)
{
LILogger.Warn($"Unknown custom text '{textID}'");
continue;
}

// Replace Text
shipStatus.Renames.Add(stringName, text);
LILogger.Info($"Custom Text '{stringName}' >>> '{text}'");
}

}

public void PostBuild() { }
}
}
2 changes: 1 addition & 1 deletion LevelImposter/Builders/Sab/SabConsoleBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void Build(LIElement elem, GameObject obj)
Console console = obj.AddComponent<Console>();
console.ConsoleId = 0;
console.Image = spriteRenderer;
console.onlyFromBelow = elem.properties.onlyFromBelow == null ? true : (bool)elem.properties.onlyFromBelow;
console.onlyFromBelow = elem.properties.onlyFromBelow ?? true;
console.usableDistance = elem.properties.range ?? 1.0f;
console.Room = systemType;
console.TaskTypes = prefabConsole.TaskTypes;
Expand Down
25 changes: 25 additions & 0 deletions LevelImposter/Builders/Trigger/TriggerDeathBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using LevelImposter.Core;
using UnityEngine;

namespace LevelImposter.Builders
{
public class TriggerDeathBuilder : IElemBuilder
{
public void Build(LIElement elem, GameObject obj)
{
if (elem.type != "util-triggerdeath")
return;

// Colliders
Collider2D[] colliders = obj.GetComponentsInChildren<Collider2D>();
foreach (Collider2D collider in colliders)
collider.isTrigger = true;

// Trigger Area
LIDeathArea deathArea = obj.AddComponent<LIDeathArea>();
deathArea.SetCreateDeadBody(elem.properties.createDeadBody ?? true);
}

public void PostBuild() { }
}
}
28 changes: 28 additions & 0 deletions LevelImposter/Builders/Trigger/TriggerShakeBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using LevelImposter.Core;
using UnityEngine;

namespace LevelImposter.Builders
{
public class TriggerShakeBuilder : IElemBuilder
{
public void Build(LIElement elem, GameObject obj)
{
if (elem.type != "util-triggershake")
return;

// Colliders
Collider2D[] colliders = obj.GetComponentsInChildren<Collider2D>();
foreach (Collider2D collider in colliders)
collider.isTrigger = true;

// Trigger Area
LIShakeArea shakeArea = obj.AddComponent<LIShakeArea>();
shakeArea.SetParameters(
elem.properties.shakeAmount ?? 0.03f,
elem.properties.shakePeriod ?? 400.0f
);
}

public void PostBuild() { }
}
}
22 changes: 14 additions & 8 deletions LevelImposter/Core/Components/GIFAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public GIFAnimator(IntPtr intPtr) : base(intPtr)

private bool _defaultLoopGIF = false;
private bool _isAnimating = false;
private int _frame = 0;
private GIFFile? _gifData = null;
private SpriteRenderer? _spriteRenderer;
private Coroutine? _animationCoroutine = null;
Expand Down Expand Up @@ -99,7 +100,8 @@ public void Stop(bool reversed = false)

if (_spriteRenderer != null && _gifData != null)
{
_spriteRenderer.sprite = _gifData.GetFrameSprite(reversed ? _gifData.Frames.Count - 1 : 0);
_frame = reversed ? _gifData.Frames.Count - 1 : 0;
_spriteRenderer.sprite = _gifData.GetFrameSprite(_frame);
_spriteRenderer.enabled = true;
}
}
Expand All @@ -117,23 +119,27 @@ private IEnumerator CoAnimate(bool repeat, bool reverse)
yield break;
_isAnimating = true;
_spriteRenderer.enabled = true;
int t = 0;
while (_isAnimating)
{
// Wait for main thread
while (!LagLimiter.ShouldContinue(60))
yield return null;

// Render sprite
int frame = reverse ? _gifData.Frames.Count - t - 1 : t;
_spriteRenderer.sprite = _gifData.GetFrameSprite(frame);
_spriteRenderer.sprite = _gifData.GetFrameSprite(_frame);

// Wait for next frame
yield return new WaitForSeconds(_gifData.Frames[frame].Delay);
yield return new WaitForSeconds(_gifData.Frames[_frame].Delay);

// Update time
t = (t + 1) % _gifData.Frames.Count;
if (t == 0 && !repeat)
// Update frame index
_frame = reverse ? _frame - 1 : _frame + 1;

// Keep frame in bounds
bool isOutOfBounds = _frame < 0 || _frame >= _gifData.Frames.Count;
_frame = (_frame + _gifData.Frames.Count) % _gifData.Frames.Count;

// Stop if out of bounds
if (isOutOfBounds && !repeat)
Stop(!reverse);
}
}
Expand Down
Loading

0 comments on commit 1e86a48

Please sign in to comment.