Aetheria/Assets/Scripts/ServerShared/Behaviors/Switch.cs
Reinier Vens 7cfc5cd04f Drag and Drop + Zoooooooom
Refactored inventory drag & drop to use new global drag & drop management
Enabled Drag & Drop from inventory panel to action bar
Enabled gear and consumable item binding
Fixed stat modifier behavior to allow it to be toggled
Fixed Switch behavior to make it bindable
Added lambda multiplier to aether drive so that stat mod can target it
2021-04-21 01:49:07 +01:00

52 lines
No EOL
1.2 KiB
C#

/* 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 System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
public class SwitchData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)
{
return new Switch(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Switch(this, item);
}
}
public class Switch : Behavior, IActivatedBehavior
{
private SwitchData _data;
public bool Activated { get; set; }
public Switch(SwitchData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public Switch(SwitchData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;
}
public override bool Execute(float dt)
{
return Activated;
}
public void Activate()
{
Activated = true;
}
public void Deactivate()
{
Activated = false;
}
}