Skip to content

Commit

Permalink
Merge pull request #111 from ToniMacaroni/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ToniMacaroni authored Dec 25, 2021
2 parents dd1cc9d + 62aae3c commit e4129ea
Show file tree
Hide file tree
Showing 21 changed files with 371 additions and 677 deletions.
18 changes: 9 additions & 9 deletions SaberFactory/Game/EventPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class EventPlayer : IDisposable

[Inject] private readonly GameEnergyCounter _energyCounter = null;

[InjectOptional] private ObstacleSaberSparkleEffectManager _obstacleSaberSparkleEffectManager;
//[InjectOptional] private ObstacleSaberSparkleEffectManager _obstacleSaberSparkleEffectManager;

[Inject] private readonly PluginConfig _pluginConfig = null;

Expand All @@ -40,8 +40,8 @@ public void Dispose()
_beatmapObjectManager.noteWasCutEvent -= OnNoteCut;
_beatmapObjectManager.noteWasMissedEvent -= OnNoteMiss;

_obstacleSaberSparkleEffectManager.sparkleEffectDidStartEvent -= SaberStartCollide;
_obstacleSaberSparkleEffectManager.sparkleEffectDidEndEvent -= SaberEndCollide;
//_obstacleSaberSparkleEffectManager.sparkleEffectDidStartEvent -= SaberStartCollide;
//_obstacleSaberSparkleEffectManager.sparkleEffectDidEndEvent -= SaberEndCollide;

_energyCounter.gameEnergyDidReach0Event -= InvokeOnLevelFail;

Expand All @@ -68,12 +68,12 @@ public void SetPartEventList(List<PartEvents> partEventsList, SaberType saberTyp
_beatmapObjectManager.noteWasMissedEvent += OnNoteMiss;

// Sabers clashing
if (_obstacleSaberSparkleEffectManager == null)
{
_obstacleSaberSparkleEffectManager = _monoKernel.GetComponentInChildren<ObstacleSaberSparkleEffectManager>();
}
_obstacleSaberSparkleEffectManager.sparkleEffectDidStartEvent += SaberStartCollide;
_obstacleSaberSparkleEffectManager.sparkleEffectDidEndEvent += SaberEndCollide;
//if (_obstacleSaberSparkleEffectManager == null)
//{
// _obstacleSaberSparkleEffectManager = _monoKernel.GetComponentInChildren<ObstacleSaberSparkleEffectManager>();
//}
//_obstacleSaberSparkleEffectManager.sparkleEffectDidStartEvent += SaberStartCollide;
//_obstacleSaberSparkleEffectManager.sparkleEffectDidEndEvent += SaberEndCollide;

// OnLevelFail
_energyCounter.gameEnergyDidReach0Event += InvokeOnLevelFail;
Expand Down
33 changes: 33 additions & 0 deletions SaberFactory/Helpers/MaterialHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,39 @@ public static void SetMainColor(this Material material, Color color)
}
}

public static bool IsMaterialColorable(Material material)
{
if (material is null || !material.HasProperty(MaterialProperties.MainColor))
{
return false;
}

if (material.TryGetFloat(MaterialProperties.CustomColors, out var val))
{
if (val > 0)
{
return true;
}
}
else if (material.TryGetFloat(MaterialProperties.Glow, out val) && val > 0)
{
return true;
}
else if (material.TryGetFloat(MaterialProperties.Bloom, out val) && val > 0)
{
return true;
}

return false;
}

public static MaterialPropertyBlock ColorBlock(Color color)
{
var block = new MaterialPropertyBlock();
block.SetColor(MaterialProperties.MainColor, color);
return block;
}

public static bool HasCustomColorsEnabled(this Material material)
{
return material.TryGetFloat(MaterialProperties.CustomColors, out var customColors) && customColors > 0.5f;
Expand Down
2 changes: 1 addition & 1 deletion SaberFactory/Installers/PluginAppInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override void InstallBindings()
if (Environment.GetCommandLineArgs().Any(x => x.ToLower() == "fpfc"))
{
rtOptions.FPFC = true;
AltTrail.CapFps = true;
SFTrail.CapFps = true;
}

Container.BindInstance(rtOptions).AsSingle();
Expand Down
13 changes: 9 additions & 4 deletions SaberFactory/Instances/MaterialDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public virtual void Revert()
return;
}

DestroyUsedMaterial();
DestroyCurrentMaterial();
Material = new Material(_originalMaterial);
}

public void DestroyUsedMaterial()
public void DestroyCurrentMaterial()
{
Material.TryDestoryImmediate();
}
Expand All @@ -41,10 +41,15 @@ public void DestroyBackupMaterial()
_originalMaterial.TryDestoryImmediate();
}

public void DestroyMaterials()
public void Destroy()
{
DestroyUsedMaterial();
DestroyCurrentMaterial();
DestroyBackupMaterial();
}

public MaterialDescriptor CreateCopy()
{
return new MaterialDescriptor(new Material(Material));
}
}
}
2 changes: 1 addition & 1 deletion SaberFactory/Instances/RendererMaterialDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public RendererMaterialDescriptor(Material material, Renderer renderer, int mate

public void Dispose()
{
DestroyMaterials();
Destroy();
}

public override void Revert()
Expand Down
7 changes: 3 additions & 4 deletions SaberFactory/Instances/SaberInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using SaberFactory.Instances.Trail;
using SaberFactory.Models;
using SiraUtil.Logging;
using SiraUtil.Tools;
using UnityEngine;
using Zenject;

Expand Down Expand Up @@ -126,14 +125,14 @@ public void CreateTrail(bool editor, SaberTrail backupTrail = null)
{
if (backupTrail is { })
{
TrailHandler = new TrailHandlerEx(GameObject, backupTrail);
TrailHandler = new MainTrailHandler(GameObject, backupTrail);
TrailHandler.CreateTrail(_trailConfig, editor);
}

return;
}

TrailHandler = new TrailHandlerEx(GameObject);
TrailHandler = new MainTrailHandler(GameObject);
TrailHandler.SetTrailData(trailData);
TrailHandler.CreateTrail(_trailConfig, editor);

Expand All @@ -143,7 +142,7 @@ public void CreateTrail(bool editor, SaberTrail backupTrail = null)
foreach (var customTrail in secondaryTrails)
{
var handler = new CustomSaberTrailHandler(GameObject, customTrail);
handler.CreateTrail(editor);
handler.CreateTrail(_trailConfig, editor);
_secondaryTrails.Add(handler);
}
}
Expand Down
Loading

0 comments on commit e4129ea

Please sign in to comment.