Skip to content

Commit

Permalink
a few changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexejhero committed Nov 1, 2023
1 parent 45785bc commit ae955d8
Show file tree
Hide file tree
Showing 50 changed files with 486 additions and 99 deletions.
8 changes: 2 additions & 6 deletions SCHIZO/Creatures/UnityCreaturePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public UnityCreaturePrefab(ModItem item) : base(item)

protected new CreatureData UnityData => (CreatureData) base.UnityData;

public override void Register()
protected override void SetItemProperties()
{
base.Register();
base.SetItemProperties();

CreatureDataUtils.SetBehaviorType(ModItem, UnityData.BehaviourType);

Expand All @@ -32,10 +32,6 @@ public override void Register()
PDAHandler.AddCustomScannerEntry(ModItem, UnityData.PDAEncyclopediaInfo.scanTime, encyclopediaKey: PrefabInfo.ClassID);
}

#if BELOWZERO
CraftDataHandler.SetSoundType(ModItem, TechData.SoundType.Fish);
#endif

if (UnityData.isPickupable)
{
CraftDataHandler.SetQuickSlotType(ModItem, QuickSlotType.Selectable);
Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/HullPlates/HullPlatePrefab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private IEnumerator GetPrefab(IOut<GameObject> gameObject)
GameObject instance = GameObject.Instantiate(task.GetResult());
TextureHider hider = instance.AddComponent<TextureHider>();
MeshRenderer mesh = instance.FindChild("Icon").GetComponent<MeshRenderer>();
mesh.material.mainTexture = !_hullPlate.deprecated ? _hullPlate.texture : _loader.deprecatedTexture;
mesh.material.mainTexture = _hullPlate.texture !?? _loader.missingTexture;
mesh.enabled = false;
hider.rend = mesh;
instance.name = _hullPlate.classId;
Expand Down
3 changes: 3 additions & 0 deletions SCHIZO/Items/Data/ItemData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ partial class ItemData
public KnownTechInfo KnownTechInfo => RetargetHelpers.Pick(knownTechInfoSN, knownTechInfoBZ);
public bool UnlockAtStart => RetargetHelpers.Pick(unlockAtStartSN, unlockAtStartBZ);
public TechType RequiredForUnlock => RetargetHelpers.Pick(requiredForUnlockSN, requiredForUnlockBZ).GetTechType();
#if BELOWZERO
public TechData.SoundType SoundType => (TechData.SoundType) soundTypeBZ;
#endif

protected override void Register()
{
Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Items/Gymbag/Gymbag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override void ModifyClone(GameObject prefab)
Object.Instantiate(UnityData.prefab, renderers[0].transform.parent);
}

protected override void PostRegister()
protected override void SetItemProperties()
{
ItemActionHandler.RegisterMiddleClickAction(Info.TechType, item => GymbagManager.Instance.OnOpen(item), "open storage", "English");
}
Expand Down
73 changes: 0 additions & 73 deletions SCHIZO/Items/ModItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,79 +33,6 @@ public ModItem(ItemData data)
PrefabInfo.WithSizeInInventory(new Vector2int(data.itemSize.x, data.itemSize.y));
}

public void LoadStep2()
{
if (ItemData.isCraftable && ItemData.CraftTreeType != CraftTree.Type.None)
{
CraftTreeHandler.AddCraftingNode(ItemData.CraftTreeType, this, ItemData.CraftTreePath);
CraftDataHandler.SetCraftingTime(this, ItemData.craftingTime);
}

if (ItemData.isBuildable)
{
CraftDataHandler.AddBuildable(this);
}

#if BELOWZERO
if (!ItemData.canBeRecycledBZ)
{
Recyclotron.bannedTech.Add(ItemData.ModItem);
}
#endif

if (ItemData.Recipe)
{
CraftDataHandler.SetRecipeData(this, ItemData.Recipe.Convert());
}

if (ItemData.TechGroup != TechGroup.Uncategorized)
{
CraftDataHandler.AddToGroup(ItemData.TechGroup, ItemData.TechCategory, this);
}

if (ItemData.PDAEncyclopediaInfo)
{
PDAEncyclopediaInfo i = ItemData.PDAEncyclopediaInfo;

PDAHandler.AddEncyclopediaEntry(PrefabInfo.ClassID, i.encyPath, i.title, i.description.text, i.texture, i.unlockSprite,
i.isImportantUnlock ? PDAHandler.UnlockImportant : PDAHandler.UnlockBasic);

if (i.scanSounds) ScanSoundHandler.Register(this, i.scanSounds);
}

if (ItemData.KnownTechInfo)
{
KnownTechInfo i = ItemData.KnownTechInfo;

KnownTechHandler.SetAnalysisTechEntry(new KnownTech.AnalysisTech
{
techType = this,
unlockTechTypes = new List<TechType>(0),
unlockMessage = i.UnlockMessage,
unlockSound = i.UnlockSound,
unlockPopup = i.unlockSprite
});
}

if (ItemData.UnlockAtStart)
{
KnownTechHandler.UnlockOnStart(this);
}
else if (ItemData.RequiredForUnlock != TechType.None)
{
KnownTechHandler.SetAnalysisTechEntry(new KnownTech.AnalysisTech
{
techType = ItemData.RequiredForUnlock,
unlockTechTypes = new List<TechType> {this},
});
}

if (ItemData.itemSounds)
{
ItemData.itemSounds.Register(this);
}
}

public static implicit operator PrefabInfo(ModItem self) => self.PrefabInfo;

public static implicit operator TechType(ModItem self) => self.PrefabInfo.TechType;
Expand Down
85 changes: 80 additions & 5 deletions SCHIZO/Items/UnityPrefab.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
using System.Diagnostics.CodeAnalysis;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Nautilus.Assets;
using Nautilus.Handlers;
using Nautilus.Utility;
using SCHIZO.Creatures;
using SCHIZO.Helpers;
using SCHIZO.Items.Data;
using SCHIZO.Sounds;
using UnityEngine;
using Object = UnityEngine.Object;

Expand Down Expand Up @@ -70,13 +73,11 @@ protected UnityPrefab(ModItem item) : base(item)

public new virtual void Register()
{
ModItem.LoadStep2();

NautilusPrefabConvertible prefab = GetPrefab();
if (prefab != null) this.SetGameObject(prefab);

base.Register();
PostRegister();
SetItemProperties();
}

protected virtual NautilusPrefabConvertible GetPrefab()
Expand All @@ -96,8 +97,82 @@ protected virtual void ModifyPrefab(GameObject prefab)
MaterialUtils.ApplySNShaders(prefab, 1);
}

protected virtual void PostRegister()
protected virtual void SetItemProperties()
{
if (ModItem.ItemData.isCraftable && ModItem.ItemData.CraftTreeType != CraftTree.Type.None)
{
CraftTreeHandler.AddCraftingNode(ModItem.ItemData.CraftTreeType, ModItem, ModItem.ItemData.CraftTreePath);
CraftDataHandler.SetCraftingTime(ModItem, ModItem.ItemData.craftingTime);
}

if (ModItem.ItemData.isBuildable)
{
CraftDataHandler.AddBuildable(ModItem);
}

#if BELOWZERO
if (!ModItem.ItemData.canBeRecycledBZ)
{
Recyclotron.bannedTech.Add(ModItem.ItemData.ModItem);
}

if (ModItem.ItemData.SoundType != TechData.SoundType.Default)
{
CraftDataHandler.SetSoundType(ModItem, ModItem.ItemData.SoundType);
}
#endif

if (ModItem.ItemData.Recipe)
{
CraftDataHandler.SetRecipeData(ModItem, ModItem.ItemData.Recipe.Convert());
}

if (ModItem.ItemData.TechGroup != TechGroup.Uncategorized)
{
CraftDataHandler.AddToGroup(ModItem.ItemData.TechGroup, ModItem.ItemData.TechCategory, ModItem);
}

if (ModItem.ItemData.PDAEncyclopediaInfo)
{
PDAEncyclopediaInfo i = ModItem.ItemData.PDAEncyclopediaInfo;

PDAHandler.AddEncyclopediaEntry(ModItem.PrefabInfo.ClassID, i.encyPath, i.title, i.description.text, i.texture, i.unlockSprite,
i.isImportantUnlock ? PDAHandler.UnlockImportant : PDAHandler.UnlockBasic);

if (i.scanSounds) ScanSoundHandler.Register(ModItem, i.scanSounds);
}

if (ModItem.ItemData.KnownTechInfo)
{
KnownTechInfo i = ModItem.ItemData.KnownTechInfo;

KnownTechHandler.SetAnalysisTechEntry(new KnownTech.AnalysisTech
{
techType = ModItem,
unlockTechTypes = new List<TechType>(0),
unlockMessage = i.UnlockMessage,
unlockSound = i.UnlockSound,
unlockPopup = i.unlockSprite
});
}

if (ModItem.ItemData.UnlockAtStart)
{
KnownTechHandler.UnlockOnStart(ModItem);
}
else if (ModItem.ItemData.RequiredForUnlock != TechType.None)
{
KnownTechHandler.SetAnalysisTechEntry(new KnownTech.AnalysisTech
{
techType = ModItem.ItemData.RequiredForUnlock,
unlockTechTypes = new List<TechType> {ModItem},
});
}

if (ModItem.ItemData.itemSounds)
{
ModItem.ItemData.itemSounds.Register(ModItem);
}
}

protected virtual void SetupComponents(GameObject instance)
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 = -2123123401;
private const int _rnd = 1495253362;

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

Expand Down
Binary file modified SCHIZO/Resources/AssetBundles/assets
Binary file not shown.
3 changes: 2 additions & 1 deletion SCHIZO/SCHIZO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<PackageReference Include="BepInEx.Analyzers" Version="1.0.8" PrivateAssets="all" />
<PackageReference Include="Krafs.Publicizer" Version="2.2.1" PrivateAssets="all" />
<PackageReference Include="PolySharp" Version="1.13.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand All @@ -22,7 +23,7 @@
<Publicize Include="Nautilus:Nautilus.Commands.Parameter.TypeConverters" />
<Publicize Include="Nautilus:Nautilus.Options.ModOptions._options" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(SolutionDir)/Unity/Assets/Scripts/SCHIZO/**/*.cs">
<DependentUpon>%(FileName).cs</DependentUpon>
Expand Down
3 changes: 2 additions & 1 deletion SCHIZO/Sounds/Players/InventoryAmbientSoundPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ partial class InventoryAmbientSoundPlayer
{
private float _timer = -1;

private void Start()
protected override void Awake()
{
base.Awake();
ResetTimer();
}

Expand Down
2 changes: 1 addition & 1 deletion SCHIZO/Sounds/Players/SoundPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace SCHIZO.Sounds.Players;

partial class SoundPlayer
{
protected void Awake()
protected virtual void Awake()
{
string busOrFieldPath = string.IsNullOrEmpty(bus) ? DefaultBus : bus;
if (string.IsNullOrEmpty(busOrFieldPath)) throw new InvalidOperationException($"No bus assigned to {this}");
Expand Down
3 changes: 2 additions & 1 deletion SCHIZO/Sounds/Players/WorldAmbientSoundPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ partial class WorldAmbientSoundPlayer
{
private float _timer = -1;

private void Start()
protected override void Awake()
{
base.Awake();
ResetTimer();
}

Expand Down
1 change: 1 addition & 0 deletions Unity/Assets/Ermfish/Cooked ermfish.asset
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ MonoBehaviour:
techCategoryBZ: 0
pdaEncyclopediaInfoBZ: {fileID: 0}
knownTechInfoBZ: {fileID: 0}
soundTypeBZ: 31
unlockAtStartBZ: 0
requiredForUnlockBZ:
isCustom: 1
Expand Down
12 changes: 12 additions & 0 deletions Unity/Assets/Ermfish/Cooked ermfish.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ MonoBehaviour:
soundCollection: {fileID: 11400000, guid: 2b7bde06469e9fc49911f3cac3ffa231, type: 2}
bus: Nautilus.Utility.AudioUtils+BusPaths:UnderwaterCreatures
emitter: {fileID: 2702267877378328202}
minDelayDefault: {fileID: 0}
maxDelayDefault: {fileID: 0}
MinDelay:
isHardCoded: 0
modOption: {fileID: 11400000, guid: 14beba417ed8e764a8489589984c141a, type: 2}
value: 0
calculateMode: 0
MaxDelay:
isHardCoded: 0
modOption: {fileID: 11400000, guid: 87f6c7eace682d841a58b07957ee144d, type: 2}
value: 0
calculateMode: 0
pickupable: {fileID: 810566840944398461}
constructable: {fileID: 0}
--- !u!114 &2702267877378328202
Expand Down
1 change: 1 addition & 0 deletions Unity/Assets/Ermfish/Cured ermfish.asset
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ MonoBehaviour:
techCategoryBZ: 0
pdaEncyclopediaInfoBZ: {fileID: 0}
knownTechInfoBZ: {fileID: 0}
soundTypeBZ: 31
unlockAtStartBZ: 0
requiredForUnlockBZ:
isCustom: 1
Expand Down
1 change: 1 addition & 0 deletions Unity/Assets/Ermfish/Ermfish regular.asset
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ MonoBehaviour:
pdaEncyclopediaInfoBZ: {fileID: 11400000, guid: 8b76d116f9af8fc499d4c055bf652966,
type: 2}
knownTechInfoBZ: {fileID: 11400000, guid: 89b8b3505e3ad2e48b2f9b7c378e4bbe, type: 2}
soundTypeBZ: 31
unlockAtStartBZ: 1
requiredForUnlockBZ:
isCustom: 0
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions Unity/Assets/Hull Plates/-Deprecated/+300 ELO.meta

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

8 changes: 8 additions & 0 deletions Unity/Assets/Hull Plates/-Deprecated/-199999876 ELO.meta

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

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

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

8 changes: 8 additions & 0 deletions Unity/Assets/Hull Plates/-Deprecated/Big Ship.meta

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

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ae955d8

Please sign in to comment.