2020-12-22 03:13:43 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
|
2020-04-09 10:33:16 +01:00
|
|
|
using MessagePack;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, MessagePackObject, RuntimeInspectable]
|
2020-05-06 04:56:36 +01:00
|
|
|
public class ReflectorData : BehaviorData
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Inspectable, Key(1), RuntimeInspectable]
|
2020-04-09 10:33:16 +01:00
|
|
|
public PerformanceStat CrossSection = new PerformanceStat();
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
// [InspectableAnimationCurve, Key(1)]
|
2020-04-09 10:33:16 +01:00
|
|
|
// public float4[] VisibilityCurve;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override Behavior CreateInstance(EquippedItem item)
|
|
|
|
|
{
|
|
|
|
|
return new Reflector(this, item);
|
|
|
|
|
}
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override Behavior CreateInstance(ConsumableItemEffect item)
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
2021-04-12 04:20:52 +01:00
|
|
|
return new Reflector(this, item);
|
2020-04-09 10:33:16 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public class Reflector : Behavior
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
|
|
|
|
private ReflectorData _data;
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public Reflector(ReflectorData data, EquippedItem item) : base(data, item)
|
|
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Reflector(ReflectorData data, ConsumableItemEffect item) : base(data, item)
|
2020-04-09 10:33:16 +01:00
|
|
|
{
|
|
|
|
|
_data = data;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override bool Execute(float dt)
|
2020-05-11 01:17:10 +01:00
|
|
|
{
|
2021-04-18 05:13:20 +01:00
|
|
|
Entity.VisibilitySources[this] = Evaluate(_data.CrossSection) * Entity.Zone.GetLight(Entity.Position.xz);
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2020-05-11 01:17:10 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-04-09 10:33:16 +01:00
|
|
|
}
|