mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fixes for Immediately Disabled Details (#1058)
## Bug fixes - Fixed details not having collision if they were immediately deactivated after being created (for instance, via `activationCondition`) - Fixed light sensors disabling themselves on activation if their detail was immediately deactivated after being created
This commit is contained in:
commit
d215fc4cef
@ -25,5 +25,8 @@ public static class GroupsBuilder
|
||||
go.GetAddComponent<SectorCullGroup>()._sector = sector;
|
||||
go.GetAddComponent<SectorCollisionGroup>()._sector = sector;
|
||||
go.GetAddComponent<SectorLightsCullGroup>()._sector = sector;
|
||||
|
||||
// SectorCollisionGroup is unique among the sector groups because it only attaches its event listener on Start() instead of Awake(), so if the detail gets immediately deactivated then it never gets attached. To avoid this, we'll attach the event listener manually (even if it means getting attached twice).
|
||||
sector.OnSectorOccupantsUpdated += go.GetComponent<SectorCollisionGroup>().OnSectorOccupantsUpdated;
|
||||
}
|
||||
}
|
||||
@ -356,7 +356,10 @@ namespace NewHorizons.Builder.Props
|
||||
singleLightSensor._sector.OnSectorOccupantsUpdated -= singleLightSensor.OnSectorOccupantsUpdated;
|
||||
}
|
||||
singleLightSensor._sector = sector;
|
||||
singleLightSensor._sector.OnSectorOccupantsUpdated += singleLightSensor.OnSectorOccupantsUpdated;
|
||||
if (singleLightSensor._sector != null)
|
||||
{
|
||||
singleLightSensor._sector.OnSectorOccupantsUpdated += singleLightSensor.OnSectorOccupantsUpdated;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.Patches.EchoesOfTheEyePatches
|
||||
{
|
||||
[HarmonyPatch(typeof(SingleLightSensor))]
|
||||
public static class SingleLightSensorPatches
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(SingleLightSensor.Start))]
|
||||
public static void Start(SingleLightSensor __instance)
|
||||
{
|
||||
// SingleLightSensor assumes that the sector will be empty when it starts and disables itself, but this may not be true if it starts disabled and is activated later, or spawned via the API
|
||||
if (__instance._sector && __instance._sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
{
|
||||
__instance.OnSectorOccupantsUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user