Aetheria/Assets/Scripts/ServerShared/Behaviors/Reflector.cs

48 lines
1.2 KiB
C#
Raw Normal View History

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable]
2026-06-14 21:48:43 +01:00
public class ReflectorConfig : RuntimeBehaviorConfig
{
2026-06-14 22:39:44 +01:00
[Inspectable]
public PerformanceStat CrossSection = new PerformanceStat();
2026-06-14 22:39:44 +01:00
// [InspectableAnimationCurve]
// public float4[] VisibilityCurve;
2026-06-13 04:56:50 +01:00
public override Behavior CreateInstance(EquippedItem item)
{
return new Reflector(this, item);
}
2026-06-13 04:56:50 +01:00
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Reflector(this, item);
}
}
public class Reflector : Behavior
{
2026-06-14 21:48:43 +01:00
private ReflectorConfig _data;
2026-06-14 21:48:43 +01:00
public Reflector(ReflectorConfig data, EquippedItem item) : base(data, item)
{
_data = data;
}
2026-06-14 21:48:43 +01:00
public Reflector(ReflectorConfig data, ConsumableItemEffect item) : base(data, item)
{
_data = data;
}
public override bool Execute(float dt)
{
Entity.VisibilitySources[this] = Evaluate(_data.CrossSection) * Entity.Zone.GetLight(Entity.Position.xz);
2026-06-13 04:56:50 +01:00
return true;
}
}