Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
try to reduce cpu impact of content alerts
don't attach to prefabs
fix multiple alert circles
remove one last ecclib component
script icons
  • Loading branch information
Govorunb committed Jul 5, 2024
1 parent 44ef438 commit 4c2b460
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 70 deletions.
23 changes: 16 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,28 @@ resharper_web_config_module_not_resolved_highlighting = warning
resharper_web_config_type_not_resolved_highlighting = warning
resharper_web_config_wrong_module_highlighting = warning

dotnet_diagnostic.RCS1123.severity = none # parentheses in expressions (covered by default dotnet analyzers)
dotnet_diagnostic.RCS1213.severity = none # unused methods (^)
dotnet_diagnostic.RCS1163.severity = none # unused parameter (^)
dotnet_diagnostic.RCS1139.severity = none # missing <summary> on xmldoc (<see cref> is used in places as a way to easily link to random methods)
dotnet_diagnostic.IDE0005.severity = warning # unused using directive
# parentheses in expressions (covered by default dotnet analyzers)
dotnet_diagnostic.RCS1123.severity = none
# unused methods (^)
dotnet_diagnostic.RCS1213.severity = none
# unused parameter (^)
dotnet_diagnostic.RCS1163.severity = none
# missing <summary> on xmldoc (<see cref> is used in places as a way to easily link to random methods)
dotnet_diagnostic.RCS1139.severity = none
# unused using directive
dotnet_diagnostic.IDE0005.severity = warning

[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,fx,fxh,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,shader,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}]
indent_style = space
indent_size = 4
tab_width = 4

[/Unity/**/*.cs]
dotnet_diagnostic.RCS1251.severity = none # braces on empty classes
# braces on empty classes
dotnet_diagnostic.RCS1251.severity = none

[/Unity/Packages/**/*.cs]
[/Unity/{Packages,Assets/Plugins/FMOD}/**/*.cs]
# JustMyCode:tm:
generated_code = true
dotnet_diagnostic.IDE0005.severity = none
dotnet_diagnostic.IDE1006.severity = none
5 changes: 2 additions & 3 deletions Immersion/Globals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ public static PronounSet PlayerPronouns
return _playerPronouns.Value;

if (!PronounSet.TryParse(PlayerPrefs.GetString(PronounsKey, ""), out PronounSet pronouns))
_playerPronouns = DefaultPronouns;
PlayerPronouns = pronouns;
return _playerPronouns.Value;
pronouns = DefaultPronouns;
return PlayerPronouns = pronouns;
}
set
{
Expand Down
13 changes: 13 additions & 0 deletions SCHIZO/Creatures/Components/SwimInSchoolFieldSetter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace SCHIZO.Creatures.Components;

partial class SwimInSchoolFieldSetter
{
private void Start()
{
SwimInSchool swim = behaviour as SwimInSchool;
if (!swim) return;
swim.kBreakDistance = breakDistance;
swim.percentFindLeaderRespond = percentFindLeaderRespond;
swim.chanceLoseLeader = chanceLoseLeader;
}
}
4 changes: 3 additions & 1 deletion SCHIZO/Helpers/GameObjectEnumerableHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Nautilus.Extensions;
using UnityEngine;

namespace SCHIZO.Helpers;
Expand All @@ -13,7 +14,8 @@ public static IEnumerable<GameObject> AllOfTechType(TechType techType)
.Select(tag => tag.gameObject)
.Concat(UnityEngine.Resources.FindObjectsOfTypeAll<PrefabIdentifier>()
.Where(id => CraftData.GetTechType(id.gameObject, out _) == techType)
.Select(id => id.gameObject));
.Select(id => id.gameObject))
.Where(go => !go.IsPrefab());

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static IEnumerable<TComponent> SelectComponent<TComponent>(this IEnumerable<GameObject> gameObjects) where TComponent : Component
Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Resources/AssetBundles/Assets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace SCHIZO.Resources;

public static class Assets
{
private const int _rnd = -1269642852;
private const int _rnd = -1520284776;

private static readonly UnityEngine.AssetBundle _a = ResourceManager.GetAssetBundle("assets");

Expand Down
Binary file modified SCHIZO/Resources/AssetBundles/assets
Binary file not shown.
41 changes: 20 additions & 21 deletions SCHIZO/Tweaks/Content/ContentAlertManager.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using SCHIZO.Helpers;
using UnityEngine;
using UWE;

namespace SCHIZO.Tweaks.Content;

Expand All @@ -19,14 +17,14 @@ private void Awake()
Instance = this;
}

private static bool _alerting;
private static bool _alertsEnabled;
internal static bool AlertsEnabled
{
get => _alerting;
get => _alertsEnabled;
set
{
if (_alerting == value) return;
_alerting = value;
if (_alertsEnabled == value) return;
_alertsEnabled = value;
OnAlertsEnabledChanged?.Invoke();
}
}
Expand All @@ -36,7 +34,7 @@ internal static bool AlertsEnabled

public static void AttachToTechType(TechType techType)
{
_attached.Add(techType);
if (!_attached.Add(techType)) return;
foreach (GameObject obj in GameObjectEnumerableHelpers.AllOfTechType(techType))
{
AttachContentAlert(obj.transform);
Expand All @@ -56,34 +54,35 @@ public static void DetachFromTechType(TechType techType)
[HarmonyPostfix]
private static void ClassIdAwake(UniqueIdentifier __instance)
{
if (__instance is PrefabIdentifier)
CoroutineHost.StartCoroutine(Coro(__instance));
if (CraftData.entClassTechTable is null) return;

if (__instance is not PrefabIdentifier { classId.Length: >0 } pid) return;

TechType techType = CraftData.entClassTechTable.GetOrDefault(pid.classId);
if (!_attached.Contains(techType)) return;

AttachContentAlert(pid.transform);
}

private static IEnumerator Coro(UniqueIdentifier uid)
[HarmonyPatch(typeof(TechTag), MethodType.Constructor)]
[HarmonyPostfix]
private static void TechTagAwake(TechTag __instance)
{
while (CraftData.entClassTechTable is null)
yield return null;
yield return new WaitForSeconds(UnityEngine.Random.Range(0.1f, 0.15f));
if (!uid || uid.classId is null) yield break;

TechType techType = CraftData.GetTechType(uid.gameObject, out _);
if (techType == TechType.None) yield break;
if (!_attached.Contains(techType)) yield break;
if (!_attached.Contains(__instance.type)) return;

AttachContentAlert(uid.transform);
AttachContentAlert(__instance.transform);
}

public static void AttachContentAlert(Transform target)
{
if (!target || target.transform.Find($"{Instance.alertPrefab.name} (Clone)")) return;
if (!target || target.transform.Find($"{Instance.alertPrefab.name}(Clone)")) return;

Instantiate(Instance.alertPrefab, target);
}

public static void DetachContentAlert(Transform target)
{
foreach (ContentVisibilityHelper alert in target.GetComponentsInChildren<ContentVisibilityHelper>())
foreach (ContentVisibilityHelper alert in target.GetComponentsInChildren<ContentVisibilityHelper>(true))
{
if (alert) GameObject.Destroy(alert.gameObject);
}
Expand Down
8 changes: 0 additions & 8 deletions Unity/Assets/Scripts/ECCLibrary.meta

This file was deleted.

16 changes: 0 additions & 16 deletions Unity/Assets/Scripts/ECCLibrary/ECCLibrary.asmdef

This file was deleted.

7 changes: 0 additions & 7 deletions Unity/Assets/Scripts/ECCLibrary/ECCLibrary.asmdef.meta

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
using UnityEngine;

// ReSharper disable once CheckNamespace
namespace ECCLibrary.Mono
namespace SCHIZO.Creatures.Components
{
public sealed class SwimInSchoolFieldSetter : MonoBehaviour
/// <summary>
/// Copied from <see href="https://github.com/LeeTwentyThree/ECCLibrary/blob/main/ECCLibrary/ECCLibrary/Mono/SwimInSchoolFieldSetter.cs">ECCLibrary</see>
/// </summary>
public sealed partial class SwimInSchoolFieldSetter : MonoBehaviour
{
[Required, ExposedType("SwimInSchool")]
public MonoBehaviour behaviour;
Expand Down
2 changes: 1 addition & 1 deletion Unity/Assets/Scripts/Subnautica/PDANotification.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Unity/Assets/Scripts/Subnautica/PingInstance.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Unity/Assets/Scripts/Subnautica/PingType.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Unity/Assets/Scripts/Subnautica/SignalPing.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c2b460

Please sign in to comment.