private void FixedUpdate_On(HooksCore.RoR2.CharacterBody.FixedUpdate.Orig orig, CharacterBody self) { try { orig(self); } catch (Exception e) { Log.Error($"Caught exception in CharacterBody.FixedUpdate orig, {e}"); } var data = self.GetOrCreateDField(BodyData.handle); foreach (var def in TempOverlaysCatalog.EnumerateEntries()) { if (def.entry !.index is not Index ind) { continue; } ref var curOverlay = ref data[ind]; if (def.ShouldHaveOverlay(self)) { if (curOverlay is null) { curOverlay = self.AddComponent <TemporaryOverlay>(); def.CreateOverlay(curOverlay, self); curOverlay.AddToCharacerModel(self.modelLocator.modelTransform.GetComponent <CharacterModel>()); } } else { if (curOverlay is not null) { curOverlay.RemoveFromCharacterModel(); curOverlay.Destroy(); curOverlay = null; } } }