Skip to content

Commit

Permalink
:classic: 🦆 Alex changing a bunch of stuff for no reason
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Dec 12, 2023
1 parent 5753da2 commit 8b32915
Show file tree
Hide file tree
Showing 28 changed files with 243 additions and 260 deletions.
1 change: 0 additions & 1 deletion SCHIZO/ConsoleCommands/RegisterConsoleCommandsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using System.Reflection;
using JetBrains.Annotations;
using Nautilus.Commands;
using Nautilus.Handlers;

namespace SCHIZO.ConsoleCommands;
Expand Down
12 changes: 6 additions & 6 deletions SCHIZO/Creatures/Ermfish/ErmStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ public static void Disconnect(ErmStack node, bool plugSide = true)
public bool Connect(ErmStack node, bool nodeIsPlug) => nodeIsPlug ? Connect(node, this) : Connect(this, node);
public void Disconnect(bool plugSide = true) => Disconnect(this, plugSide);

public bool ShouldAttach(Carryable _, CarryCreature socket)
public bool ShouldAttach(Carryable _, CarryCreature attachSocket)
{
ErmStack socketStack = socket.GetComponent<ErmStack>();
ErmStack socketStack = attachSocket.GetComponent<ErmStack>();
if (!socketStack) return true;

return socketStack.head != head && socketStack.tail != tail
&& !socketStack.nextPlug;
}

public void OnConnected(Carryable plug, CarryCreature socket)
public void OnConnected(Carryable connectedPlug, CarryCreature connectedSocket)
{
// only called on the plug side - so we update the socket from the plug
ErmStack socketStack = socket.GetComponent<ErmStack>();
ErmStack socketStack = connectedSocket.GetComponent<ErmStack>();
if (!socketStack) return;

socketStack.nextPlug = this;
Expand All @@ -162,10 +162,10 @@ public void OnConnected(Carryable plug, CarryCreature socket)
socketStack.WalkToHead().ForEach(s => s.tail = tail);
}

public void OnDisconnected(Carryable plug, CarryCreature socket)
public void OnDisconnected(Carryable disconnectedPlug, CarryCreature disconnectedSocket)
{
// only called on the plug side - so we update the socket from the plug
ErmStack socketStack = socket.GetComponent<ErmStack>();
ErmStack socketStack = disconnectedSocket.GetComponent<ErmStack>();
if (!socketStack) return;

socketStack.nextPlug = null;
Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Creatures/Ermshark/ErmsharkAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public override void OnTouch(Collider collider)

GameObject target = GetTarget(collider);

if (global::CreatureData.GetCreatureType(gameObject) == global::CreatureData.GetCreatureType(target)) return;
if (CreatureData.GetCreatureType(gameObject) == CreatureData.GetCreatureType(target)) return;
if (GetComponentsInParent<IOnMeleeAttack>().Any(handler => handler.HandleMeleeAttack(target))) return;

Player player = target.GetComponent<Player>();
Expand Down
1 change: 0 additions & 1 deletion SCHIZO/Creatures/UnityCreaturePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics.CodeAnalysis;
using ECCLibrary;
using Nautilus.Handlers;
using SCHIZO.Helpers;
using SCHIZO.Items;
using UnityEngine;
using UWE;
Expand Down
4 changes: 2 additions & 2 deletions SCHIZO/DataStructures/SavedRandomList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public sealed class SavedRandomList<T> : IEnumerable<T>
{
private record struct IdentifiableItem(string Identifier, T Value);

private class PlayerPrefsManager(string key) : RandomList<IdentifiableItem>.IInitialStateModifier
private class PlayerPrefsManager(string playerPrefsPrefix) : RandomList<IdentifiableItem>.IInitialStateModifier
{
private record struct RegistryKey(string Value);

Expand Down Expand Up @@ -46,7 +46,7 @@ public void Reset()
}
}

private RegistryKey KeyOf(string identifier) => new($"SCHIZO_RandomList_{key}_{identifier}");
private RegistryKey KeyOf(string identifier) => new($"SCHIZO_RandomList_{playerPrefsPrefix}_{identifier}");

private static bool Contains(RegistryKey key) => PlayerPrefs.HasKey(key.Value);

Expand Down
1 change: 0 additions & 1 deletion SCHIZO/Helpers/StaticHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using HarmonyLib;
using TriInspector;

namespace SCHIZO.Helpers;
Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Items/ClonePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ public abstract class ClonePrefab : UnityPrefab
protected readonly TechType clonedTechType;

[SetsRequiredMembers]
protected ClonePrefab(ModItem item, TechType cloned) : base(item)
// ReSharper disable once ConvertToPrimaryConstructor
protected ClonePrefab(ModItem item, TechType cloned) : base(item)
{
clonedTechType = cloned;
}
Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Items/Components/MiddleClickAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void IPrefabInit.PrefabInit(GameObject prefab)

private string Validate(TechType techType)
{
if (target?.GetType() is not { } type)
if (target!?.GetType() is not { } type)
return $"{nameof(target)} is required and was not provided";

MethodInfo methodInfo = type.GetMethod(method);
Expand Down
1 change: 0 additions & 1 deletion SCHIZO/Items/Data/Crafting/Recipe.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.Linq;
using Nautilus.Crafting;

Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Items/Gymbag/Gymbag.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Nautilus.Handlers;
using SCHIZO.Helpers;
using UnityEngine;

namespace SCHIZO.Items.Gymbag;
Expand All @@ -15,6 +14,7 @@ public sealed class Gymbag : ClonePrefab
#endif

[SetsRequiredMembers]
// ReSharper disable once ConvertToPrimaryConstructor
public Gymbag(ModItem modItem) : base(modItem, CLONE_TARGET)
{
}
Expand Down
3 changes: 1 addition & 2 deletions SCHIZO/Items/UnityPrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using SCHIZO.Helpers;
using SCHIZO.Items.Data;
using SCHIZO.Registering;
using SCHIZO.Sounds;
using SCHIZO.Spawns;
using UnityEngine;
using Object = UnityEngine.Object;
Expand All @@ -34,8 +33,8 @@ static UnityPrefab()
protected PrefabInfo PrefabInfo => ModItem.PrefabInfo;

[SetsRequiredMembers]
public UnityPrefab(ModItem item) : base(item)
// ReSharper disable once ConvertToPrimaryConstructor
public UnityPrefab(ModItem item) : base(item)
{
ModItem = item;
}
Expand Down
1 change: 0 additions & 1 deletion SCHIZO/Jukebox/CustomJukeboxDisk.BelowZero.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text;
using FMODUnity;
using Nautilus.Handlers;
using Nautilus.Utility;
using SCHIZO.Sounds;
Expand Down
4 changes: 1 addition & 3 deletions SCHIZO/Loading/BZErmsharkLoadingIcon.BelowZero.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static implicit operator BZAnimation(FrameAnimation anim)
private int originalCols;

private RectTransform rectTransform;
private RectTransform rectParent;

private Vector2 originalSpriteDimensions => new(originalTexture.width / originalCols, originalTexture.height / originalRows);
private Vector2 ourSpriteDimensions => new(texture.width / columns, texture.height / rows);
Expand All @@ -47,10 +46,9 @@ private void Awake()
Destroy(this);
return;
}
/// indices correspond to <see cref="uGUI_SceneLoading.State"/>
// indices correspond to <see cref="uGUI_SceneLoading.State"/>
ourAnimations = [idle, moving, stopping];
rectTransform = loadingScreen.pengling.rectTransform;
rectParent = (RectTransform) rectTransform.parent;

originalAnimations = loadingScreen.animations;
originalTexture = loadingScreen.pengling.mainTexture;
Expand Down
2 changes: 0 additions & 2 deletions SCHIZO/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using BepInEx;
using BepInEx.Logging;
using ECCLibrary;
using FMOD;
using FMODUnity;
using HarmonyLib;
using SCHIZO.ConsoleCommands;
using SCHIZO.Helpers;
Expand Down
1 change: 0 additions & 1 deletion SCHIZO/Twitch/TwitchIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Nautilus.Commands;
using SCHIZO.ConsoleCommands;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
namespace Editor.Scripts.PropertyDrawers.NonTriInspector.Attributes
{
[CustomPropertyDrawer(typeof(PreviewImageAttribute), true)]
public class VFXComponentImagePreview() : PropertyDrawer
public class VFXComponentImagePreview : PropertyDrawer
{
private Texture image;

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// TODO: this is not ideal
// TODO: this is not ideal
image = (Texture) property.objectReferenceValue;
GUIStyle style = new GUIStyle(EditorStyles.label);
GUIStyle style = new(EditorStyles.label);
style.alignment = TextAnchor.UpperCenter;
GUILayout.Box(image, style);
}
Expand Down
3 changes: 1 addition & 2 deletions Unity/Assets/Scripts/SCHIZO/Items/Data/ItemData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using JetBrains.Annotations;
using SCHIZO.Attributes;
using SCHIZO.Interop.Subnautica.Enums;
Expand Down
3 changes: 1 addition & 2 deletions Unity/Assets/Scripts/SCHIZO/Spawns/BiomeSpawnData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using TriInspector;
using UnityEngine;

Expand Down
44 changes: 25 additions & 19 deletions Unity/Assets/Scripts/SCHIZO/Utilities/T2DArray.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
using System.Collections.Generic;
using TriInspector;
using UnityEngine;
using UnityEditor;
using UnityEngine;

#if UNITY_EDITOR
using TriInspector;
#endif

namespace SCHIZO.Utilities
{
[CreateAssetMenu(menuName ="SCHIZO/Utilities/Texture2D Array")]
[CreateAssetMenu(menuName = "SCHIZO/Utilities/Texture2D Array")]
public class T2DArray : ScriptableObject
{
[HideInInspector]
public Texture2DArray array;
[HideInInspector] public Texture2DArray array;

#if UNITY_EDITOR

[Required, ValidateInput(nameof(ValidateTextures))]
public List<Texture> textures;

public TextureWrapMode wrapMode = TextureWrapMode.Clamp;
public FilterMode filterMode = FilterMode.Point;
[Space]
[ShowIf(nameof(array), null)]
public TextureCompressionQuality compressionQuality;
[Space] [ShowIf(nameof(array), null)] public TextureCompressionQuality compressionQuality;

[ShowInInspector, ShowIf(nameof(array), null), ReadOnly]
public TextureFormat compressionFormat;
Expand All @@ -33,7 +34,8 @@ private void OnValidate()
}
}

private bool validtationPass = false;
private bool validationPass = false;

private TriValidationResult ValidateTextures()
{
if (textures.Count > 1) textures.RemoveAll(o => o == null);
Expand All @@ -46,27 +48,30 @@ private TriValidationResult ValidateTextures()

foreach (Texture texture in textures)
{
if (texture.width != w || texture.height != h )
if (texture.width != w || texture.height != h)
{
validtationPass = false;
validationPass = false;
return TriValidationResult.Error("All Textures must have same dimensions!");
}
if(((Texture2D) texture).format != format)

if (((Texture2D) texture).format != format)
{
validtationPass = false;
validationPass = false;
return TriValidationResult.Error("All Textures must have same format!");
}
}
validtationPass = true;

validationPass = true;
compressionFormat = format;
return TriValidationResult.Valid;
}
validtationPass = true;

validationPass = true;
return TriValidationResult.Warning("Please assign at least 2 textures, or use Texture2D if single texture is intended");
}

// for some reason Texture2DArray sub asset does not update when overwriting it, so uuh it's a one time thing i guess
[Button, ShowIf(nameof(array), null), ShowIf(nameof(validtationPass),true)]
[Button, ShowIf(nameof(array), null), ShowIf(nameof(validationPass), true)]
private void GenerateArray()
{
if (textures.Count == 0 || textures[0] == null) return;
Expand All @@ -84,12 +89,13 @@ private Texture2DArray PopulateTexture2DArray()
{
List<Texture> tt = textures;

Texture2DArray t2da = new Texture2DArray(tt[0].width, tt[0].height, tt.Count, compressionFormat, false, true);
Texture2DArray t2da = new(tt[0].width, tt[0].height, tt.Count, compressionFormat, false, true);

for (int i = 0; i < tt.Count; i++)
{
Graphics.CopyTexture(tt[i], 0,0, t2da, i,0);
Graphics.CopyTexture(tt[i], 0, 0, t2da, i, 0);
}

t2da.wrapMode = wrapMode;
t2da.filterMode = filterMode;

Expand Down
Loading

0 comments on commit 8b32915

Please sign in to comment.