Files
Jiaqi (0x7c13) Liu ba018bb752 Isolate optional VFX lifetimes and private asset builds
Centralize optional prefab loading, persistent attachments, active-effect cleanup and cache invalidation. Runtime toggles hide active effects and restore surviving attachments. Block private VFX and legacy Toon assets in public builds, with an explicit local private-build override.

Release portal attachments on destruction, reject dead parents and prune orphaned persistent attachments.
2026-11-12 00:12:19 +08:00

61 lines
1.9 KiB
C#

// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2025, Jiaqi (0x7c13) Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Game.Effect
{
using System;
using Data;
using Engine.Core.Implementation;
using Engine.Extensions;
using Vector3 = UnityEngine.Vector3;
public sealed class PortalEffect : GameEntityScript, IEffect
{
#if PAL3
private const string PORTAL_BASE_TEXTURE_NAME = "trans.dds";
#elif PAL3A
private const string PORTAL_BASE_TEXTURE_NAME = "trans.tga";
#endif
private const float PORTAL_DEFAULT_SIZE = 1.3f;
private const float PORTAL_ANIMATION_ROTATION_SPEED = 5f;
private const int PORTAL_RAY_EFFECT_ID = 0;
private RotatingSpriteEffect _baseEffect;
private IDisposable _rayEffect;
protected override void OnDisableGameEntity()
{
Dispose();
}
public void Init(GameResourceProvider resourceProvider, uint _)
{
_baseEffect = GameEntity.AddComponent<RotatingSpriteEffect>();
_baseEffect.Init(resourceProvider,
PORTAL_BASE_TEXTURE_NAME,
new Vector3(PORTAL_DEFAULT_SIZE, PORTAL_DEFAULT_SIZE, PORTAL_DEFAULT_SIZE),
PORTAL_ANIMATION_ROTATION_SPEED);
_rayEffect = resourceProvider.OptionalVfx.Attach(PORTAL_RAY_EFFECT_ID, GameEntity);
}
private void OnDestroy() => Dispose();
public void Dispose()
{
if (_baseEffect != null)
{
_baseEffect.Dispose();
_baseEffect.Destroy();
_baseEffect = null;
}
_rayEffect?.Dispose();
_rayEffect = null;
}
}
}