Skip to content

Commit

Permalink
misc bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Govorunb committed Jun 12, 2024
1 parent 5264158 commit d83921b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
5 changes: 3 additions & 2 deletions SCHIZO/Creatures/Components/CarryCreature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void ClearTarget()

public bool TryPickup(Carryable getCarried)
{
if (!enabled) return false;
if (!getCarried || getCarried.gameObject == gameObject) return false;
if (target) Drop();
target = getCarried;
Expand All @@ -161,8 +162,8 @@ public bool TryPickup(Carryable getCarried)

private bool TryPickupTarget()
{
if (!target || !target.gameObject || !target.gameObject.activeInHierarchy) return false;
if (!target.CanBePickedUp(this)) return false;
if (!enabled) return false;
if (!target || !target.CanBePickedUp(this)) return false;

if (target.GetComponentInParent<Player>())
{
Expand Down
3 changes: 2 additions & 1 deletion SCHIZO/Creatures/Components/Carryable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void Awake()
}

public bool CanBePickedUp(CarryCreature pickuper) => !isCarried && Time.time - _lastPickedUpTime > 5f
&& (CanAttach?.Multicast().All(f => f(this, pickuper)) ?? true);
&& isActiveAndEnabled
&& (CanAttach?.Multicast().All(f => f(this, pickuper)) ?? true);

private void DisableComponents()
{
Expand Down
12 changes: 10 additions & 2 deletions SCHIZO/Creatures/Ermfish/ErmStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,15 @@ public void StartStacking()
public ErmStack FindTarget()
{
TechType selfTechType = CraftData.GetTechType(gameObject);
bool EcoTargetFilter(IEcoTarget et) => CraftData.GetTechType(et.GetGameObject()) == selfTechType && et.GetGameObject() != gameObject;
bool EcoTargetFilter(IEcoTarget et)
{
GameObject obj = et.GetGameObject();
if (CraftData.GetTechType(obj) != selfTechType) return false;
if (obj == gameObject) return false;

ErmStack otherStack = obj.GetComponent<ErmStack>();
return otherStack && otherStack.isActiveAndEnabled && !otherStack.nextSocket;
}

ErmStack target = FindNearest_EcoTarget() !?? FindNearest_TechType();
return target;
Expand All @@ -94,7 +102,7 @@ ErmStack FindNearest_TechType()
.OfTechType(selfTechType)
.SelectComponentInParent<ErmStack>()
.OrderByDistanceTo(gameObject.transform.position)
.FirstOrDefault(s => !s.nextSocket && s != this);
.FirstOrDefault(s => s.isActiveAndEnabled && !s.nextSocket && s != this);
}
}

Expand Down
8 changes: 5 additions & 3 deletions SCHIZO/Tweaks/Content/ContentAlertManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,17 @@ private static IEnumerator Coro(UniqueIdentifier uid)

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

Instantiate(Instance.alertPrefab, target);
}

public static void DetachContentAlert(Transform target)
{
ContentVisibilityHelper alert = target.GetComponentInChildren<ContentVisibilityHelper>();
if (alert) GameObject.Destroy(alert.gameObject);
foreach (ContentVisibilityHelper alert in target.GetComponentsInChildren<ContentVisibilityHelper>())
{
if (alert) GameObject.Destroy(alert.gameObject);
}
}

public static void Clear()
Expand Down

0 comments on commit d83921b

Please sign in to comment.