-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
1,170 additions
and
72 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
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
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,55 @@ | ||
using HarmonyLib; | ||
using LevelImposter.DB; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
|
||
namespace LevelImposter.Core | ||
{ | ||
class AmbientSoundBuilder : Builder | ||
{ | ||
public void Build(LIElement elem, GameObject obj) | ||
{ | ||
if (elem.type != "util-sound1") | ||
return; | ||
|
||
// Colliders | ||
Collider2D[] colliders = obj.GetComponents<Collider2D>(); | ||
foreach (Collider2D collider in colliders) | ||
{ | ||
collider.isTrigger = true; | ||
} | ||
|
||
// AudioClip | ||
if (elem.properties.sounds == null) | ||
{ | ||
LILogger.Warn("Ambient sound missing audio listing"); | ||
return; | ||
} | ||
|
||
if (elem.properties.sounds.Length <= 0) | ||
{ | ||
LILogger.Warn("Ambient sound missing audio elements"); | ||
return; | ||
} | ||
|
||
LISound soundData = elem.properties.sounds[0]; | ||
if (soundData.data == null) | ||
{ | ||
LILogger.Warn("Ambient sound missing audio data [" + soundData.id + "]"); | ||
return; | ||
} | ||
AudioClip clip = MapUtils.ConvertToAudio(elem.name, soundData.data); | ||
|
||
// Sound Player | ||
AmbientSoundPlayer ambientPlayer = obj.AddComponent<AmbientSoundPlayer>(); | ||
ambientPlayer.HitAreas = colliders; | ||
ambientPlayer.AmbientSound = clip; | ||
ambientPlayer.MaxVolume = soundData.volume; | ||
} | ||
|
||
public void PostBuild() {} | ||
} | ||
} |
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
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
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
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
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,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using UnityEngine; | ||
using LevelImposter.DB; | ||
|
||
namespace LevelImposter.Core | ||
{ | ||
public class NoShadowBuilder : Builder | ||
{ | ||
private Material noShadowMat = null; | ||
private Material defaultMat = null; | ||
|
||
public void Build(LIElement elem, GameObject obj) | ||
{ | ||
if (!(elem.type.StartsWith("dec-") || elem.type == "util-blank")) | ||
return; | ||
|
||
if (noShadowMat == null) | ||
{ | ||
noShadowMat = AssetDB.dec["dec-rock5"].SpriteRenderer.material; | ||
defaultMat = AssetDB.dec["dec-rock4"].SpriteRenderer.material; | ||
} | ||
|
||
SpriteRenderer spriteRenderer = obj.GetComponent<SpriteRenderer>(); | ||
if (spriteRenderer) | ||
{ | ||
if (elem.properties.noShadows == true) | ||
{ | ||
spriteRenderer.material = noShadowMat; | ||
|
||
if (elem.properties.noShadowsBehaviour == true) | ||
{ | ||
NoShadowBehaviour behaviour = obj.AddComponent<NoShadowBehaviour>(); | ||
behaviour.rend = spriteRenderer; | ||
|
||
Collider2D[] shadows = obj.GetComponentsInChildren<Collider2D>(); | ||
for (int i = 0; i < shadows.Length; i++) | ||
{ | ||
if (shadows[i].gameObject != obj) | ||
{ | ||
behaviour.hitOverride = shadows[i]; | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
spriteRenderer.material = defaultMat; | ||
} | ||
} | ||
} | ||
|
||
public void PostBuild() { } | ||
} | ||
} |
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
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
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,50 @@ | ||
using HarmonyLib; | ||
using LevelImposter.DB; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using UnityEngine; | ||
|
||
namespace LevelImposter.Core | ||
{ | ||
class StarfieldBuilder : Builder | ||
{ | ||
public void Build(LIElement elem, GameObject obj) | ||
{ | ||
if (elem.type != "util-starfield") | ||
return; | ||
|
||
// Sprite | ||
GameObject prefab = GameObject.Instantiate(obj, LIShipStatus.Instance.transform); | ||
LIStar prefabStar = prefab.AddComponent<LIStar>(); | ||
SpriteRenderer prefabRenderer = obj.GetComponent<SpriteRenderer>(); | ||
if (prefabRenderer != null) | ||
{ | ||
prefabRenderer.material = AssetDB.dec["dec-rock4"].SpriteRenderer.material; | ||
} | ||
else | ||
{ | ||
LILogger.Warn("Star Fields do not work without a cooresponding sprite"); | ||
return; | ||
} | ||
|
||
// Stars | ||
int count = 20; | ||
if (elem.properties.starfieldCount != null) | ||
count = (int)elem.properties.starfieldCount; | ||
for (int i = 0; i < count; i++) | ||
{ | ||
GameObject starObj = GameObject.Instantiate(prefab, obj.transform); | ||
starObj.name = "Star " + i; | ||
LIStar starComp = starObj.GetComponent<LIStar>(); | ||
starComp.Init(elem); | ||
} | ||
|
||
// Disable Obj | ||
obj.GetComponent<SpriteRenderer>().enabled = false; | ||
GameObject.Destroy(prefab); | ||
} | ||
|
||
public void PostBuild() { } | ||
} | ||
} |
Oops, something went wrong.