-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from Alexejhero/evil-fumo-item
Evil fumo item + lowpoly fumo tooltip
- Loading branch information
Showing
28 changed files
with
2,120 additions
and
173 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using Nautilus.Extensions; | ||
using UnityEngine; | ||
|
||
namespace SCHIZO.Items.FumoItem; | ||
|
||
partial class EvilFumoItemTool | ||
{ | ||
public Knife stolenKnife; | ||
private static float _knifeScale = 0.9f; | ||
|
||
protected override void ApplyAltEffect(bool active) | ||
{ | ||
LOGGER.LogWarning(active); | ||
if (active) | ||
{ | ||
float dmg = damageOnPoke; | ||
if (stealKnife && TryFindKnife(out Knife knife) | ||
&& Inventory.main.InternalDropItem(knife.pickupable)) | ||
{ | ||
stolenKnife = knife; | ||
YoinkKnife(); | ||
dmg *= 4; | ||
} | ||
usingPlayer.liveMixin.TakeDamage(dmg); | ||
damageOnPoke *= 1.25f; // negative reward function | ||
} | ||
else | ||
{ | ||
if (!ReturnKnife()) | ||
LOGGER.LogError("Could not return stolen knife"); | ||
} | ||
} | ||
|
||
private bool TryFindKnife(out Knife knife) | ||
{ | ||
knife = default; | ||
|
||
QuickSlots slots = Inventory.main.quickSlots; | ||
for (int i = 0; i < 5; i++) | ||
{ | ||
InventoryItem item = slots.GetSlotItem(i); | ||
if (item is null || !item.item) | ||
continue; | ||
knife = item.item.GetComponent<Knife>(); | ||
if (!knife) continue; | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
private void YoinkKnife() | ||
{ | ||
UWE.Utils.SetCollidersEnabled(stolenKnife.gameObject, false); | ||
UWE.Utils.SetIsKinematic(stolenKnife.GetComponent<Rigidbody>(), true); | ||
UWE.Utils.SetEnabled(stolenKnife.GetComponent<LargeWorldEntity>(), false); | ||
stolenKnife.transform.SetParent(knifeSocket.Exists() ?? transform, true); | ||
stolenKnife.transform.localScale *= _knifeScale; | ||
} | ||
|
||
protected override void Update() | ||
{ | ||
base.Update(); | ||
if (stolenKnife) | ||
RepositionKnife(stolenKnife.transform); | ||
} | ||
|
||
// i don't know what's rotating things *several frames* after they're unparented but i wish it a very pleasant go commit refactor (in copilot) | ||
private static void RepositionKnife(Transform knife) | ||
{ | ||
knife.localRotation = Quaternion.identity; | ||
knife.localPosition = Vector3.zero; | ||
} | ||
|
||
private bool ReturnKnife() | ||
{ | ||
if (!stolenKnife) return true; | ||
DropKnife(); | ||
|
||
if (!Inventory.main.Pickup(stolenKnife.pickupable)) return false; | ||
return true; | ||
} | ||
|
||
private void DropKnife() | ||
{ | ||
stolenKnife.transform.localScale /= _knifeScale; | ||
stolenKnife.transform.SetParent(null, true); | ||
GameObject colliderTarget = stolenKnife.gameObject; | ||
FPModel fpModel = stolenKnife.GetComponent<FPModel>(); | ||
if (fpModel) colliderTarget = fpModel.propModel; | ||
UWE.Utils.SetCollidersEnabled(colliderTarget, true); | ||
UWE.Utils.SetIsKinematic(stolenKnife.GetComponent<Rigidbody>(), false); | ||
if (stolenKnife.GetComponent<LargeWorldEntity>().Exists() is { } lwe) | ||
LargeWorldStreamer.main!?.cellManager.RegisterEntity(lwe); | ||
} | ||
} |
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,23 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!114 &11400000 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 0} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: a6ccb8c039e34e44ebdee40c7d89e4a4, type: 3} | ||
m_Name: Evil Fumo Spawns | ||
m_EditorClassIdentifier: | ||
spawns: | ||
- game: 2 | ||
locations: | ||
- position: {x: -326.8, y: 15, z: 265.4} | ||
rotation: {x: 0, y: 115, z: 0} | ||
item: | ||
isCustom: 1 | ||
techType: 2007 | ||
itemData: {fileID: 11400000, guid: 7783c6be943946e49b6d4a4982e601d6, type: 2} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
Oops, something went wrong.