More weapon events and abilities
This commit is contained in:
@@ -14,6 +14,11 @@ using Movementtests.systems;
|
||||
public partial class InventoryUi : Control, IDisposable
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
public record struct EventElements(
|
||||
AbilitySelection AbilitySelection,
|
||||
AutoSet<ForgeAbilityBehavior>.Binding Binding,
|
||||
IAutoSet<ForgeAbilityBehavior> Inventory);
|
||||
|
||||
#region Dependencies
|
||||
[Dependency]
|
||||
@@ -27,53 +32,67 @@ public partial class InventoryUi : Control, IDisposable
|
||||
public required AbilitySelection WhileFlying { get; set; }
|
||||
[Node]
|
||||
public required AbilitySelection StoppedFlying { get; set; }
|
||||
|
||||
[Node]
|
||||
public required AbilitySelection StartedPlanted { get; set; }
|
||||
[Node]
|
||||
public required AbilitySelection WhilePlanted { get; set; }
|
||||
[Node]
|
||||
public required AbilitySelection StoppedPlanted { get; set; }
|
||||
#endregion Nodes
|
||||
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding StartedFlyingBinding { get; set; }
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding FlyingTickBinding { get; set; }
|
||||
public AutoSet<ForgeAbilityBehavior>.Binding StoppedFlyingBinding { get; set; }
|
||||
public required AutoSet<ForgeAbilityBehavior>.Binding StartedFlyingBinding { get; set; }
|
||||
public required AutoSet<ForgeAbilityBehavior>.Binding FlyingTickBinding { get; set; }
|
||||
public required AutoSet<ForgeAbilityBehavior>.Binding StoppedFlyingBinding { get; set; }
|
||||
|
||||
public required AutoSet<ForgeAbilityBehavior>.Binding StartedPlantedBinding { get; set; }
|
||||
public required AutoSet<ForgeAbilityBehavior>.Binding PlantedTickBinding { get; set; }
|
||||
public required AutoSet<ForgeAbilityBehavior>.Binding StoppedPlantedBinding { get; set; }
|
||||
|
||||
public Dictionary<WeaponSystem.WeaponEvent, EventElements> EventElementsMap { get; private set; } = [];
|
||||
|
||||
public void OnReady()
|
||||
{
|
||||
StartedFlying.AbilityAdded += AddAbilityForEvent;
|
||||
WhileFlying.AbilityAdded += AddAbilityForEvent;
|
||||
StoppedFlying.AbilityAdded += AddAbilityForEvent;
|
||||
|
||||
StartedFlying.AbilityRemoved += RemoveAbilityForEvent;
|
||||
WhileFlying.AbilityRemoved += RemoveAbilityForEvent;
|
||||
StoppedFlying.AbilityRemoved += RemoveAbilityForEvent;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
StartedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StartedFlying]);
|
||||
WhileFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.FlyingTick]);
|
||||
StoppedFlying.Initialize(InventoryManager.WeaponEventsInventory[WeaponSystem.WeaponEvent.StoppedFlying]);
|
||||
EventElementsMap = new Dictionary<WeaponSystem.WeaponEvent, EventElements>
|
||||
{
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, new EventElements(StartedFlying, StartedFlyingBinding, InventoryManager.StartedFlyingAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, new EventElements(StoppedFlying, StoppedFlyingBinding, InventoryManager.StoppedFlyingAbilities)},
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, new EventElements(WhileFlying, FlyingTickBinding, InventoryManager.FlyingTickAbilities) },
|
||||
|
||||
{ WeaponSystem.WeaponEvent.StartedPlanted, new EventElements(StartedPlanted, StartedPlantedBinding, InventoryManager.StartedPlantedAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.StoppedPlanted, new EventElements(StoppedPlanted, StoppedPlantedBinding, InventoryManager.StoppedPlantedAbilities) },
|
||||
{ WeaponSystem.WeaponEvent.PlantedTick, new EventElements(WhilePlanted, PlantedTickBinding, InventoryManager.PlantedTickAbilities) },
|
||||
};
|
||||
|
||||
StartedFlyingBinding = InventoryManager.StartedFlyingAbilities.Bind();
|
||||
StartedFlyingBinding
|
||||
.OnAdd(behavior => OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent.StartedFlying, behavior))
|
||||
.OnRemove(behavior => OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent.StartedFlying, behavior))
|
||||
.OnClear(() => OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent.StartedFlying));
|
||||
FlyingTickBinding = InventoryManager.FlyingTickAbilities.Bind();
|
||||
FlyingTickBinding
|
||||
.OnAdd(behavior => OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent.FlyingTick, behavior))
|
||||
.OnRemove(behavior => OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent.FlyingTick, behavior))
|
||||
.OnClear(() => OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent.FlyingTick));
|
||||
StoppedFlyingBinding = InventoryManager.StoppedFlyingAbilities.Bind();
|
||||
StoppedFlyingBinding
|
||||
.OnAdd(behavior => OnWeaponEventInventoryAdded(WeaponSystem.WeaponEvent.StoppedFlying, behavior))
|
||||
.OnRemove(behavior => OnWeaponEventInventoryRemoved(WeaponSystem.WeaponEvent.StoppedFlying, behavior))
|
||||
.OnClear(() => OnWeaponEventInventoryCleared(WeaponSystem.WeaponEvent.StoppedFlying));
|
||||
foreach (var (forEvent, element) in EventElementsMap)
|
||||
{
|
||||
element.AbilitySelection.AbilityAdded += AddAbilityForEvent;
|
||||
element.AbilitySelection.AbilityRemoved += RemoveAbilityForEvent;
|
||||
|
||||
var elem = EventElementsMap[forEvent];
|
||||
elem.AbilitySelection.Initialize(InventoryManager.WeaponEventsInventory[forEvent]);
|
||||
elem.Binding = element.Inventory.Bind();
|
||||
elem.Binding
|
||||
.OnAdd(behavior => OnWeaponEventInventoryAdded(forEvent, behavior))
|
||||
.OnRemove(behavior => OnWeaponEventInventoryRemoved(forEvent, behavior))
|
||||
.OnClear(() => OnWeaponEventInventoryCleared(forEvent));
|
||||
}
|
||||
|
||||
foreach (var forEvent in EventElementsMap.Keys)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public new void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
StartedFlying.Dispose();
|
||||
WhileFlying.Dispose();
|
||||
StoppedFlying.Dispose();
|
||||
foreach (var element in EventElementsMap.Values)
|
||||
element.Binding.Dispose();
|
||||
|
||||
base.Dispose();
|
||||
}
|
||||
@@ -108,13 +127,6 @@ public partial class InventoryUi : Control, IDisposable
|
||||
|
||||
public AbilitySelection GetAbilitySelection(WeaponSystem.WeaponEvent forEvent)
|
||||
{
|
||||
var abilitiesSelectionsMap = new Dictionary<WeaponSystem.WeaponEvent, AbilitySelection>
|
||||
{
|
||||
{ WeaponSystem.WeaponEvent.StartedFlying, StartedFlying },
|
||||
{ WeaponSystem.WeaponEvent.StoppedFlying, StoppedFlying },
|
||||
{ WeaponSystem.WeaponEvent.FlyingTick, WhileFlying },
|
||||
};
|
||||
|
||||
return abilitiesSelectionsMap[forEvent];
|
||||
return EventElementsMap[forEvent].AbilitySelection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,24 +72,47 @@ layout_mode = 2
|
||||
text = "Weapon abilities"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection" unique_id=75337901]
|
||||
[node name="FlyingHBoxContainer" type="HBoxContainer" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection" unique_id=75337901]
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_ijoei")
|
||||
search_depth = 10
|
||||
|
||||
[node name="StartedFlying" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/HBoxContainer" unique_id=1373426933 instance=ExtResource("3_ijoei")]
|
||||
[node name="StartedFlying" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/FlyingHBoxContainer" unique_id=1373426933 instance=ExtResource("3_ijoei")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
Title = "Started flying"
|
||||
|
||||
[node name="WhileFlying" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/HBoxContainer" unique_id=1771285257 instance=ExtResource("3_ijoei")]
|
||||
[node name="WhileFlying" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/FlyingHBoxContainer" unique_id=1771285257 instance=ExtResource("3_ijoei")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
ForEvent = 2
|
||||
Title = "While flying"
|
||||
|
||||
[node name="StoppedFlying" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/HBoxContainer" unique_id=324047638 instance=ExtResource("3_ijoei")]
|
||||
[node name="StoppedFlying" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/FlyingHBoxContainer" unique_id=324047638 instance=ExtResource("3_ijoei")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
ForEvent = 1
|
||||
Title = "Stopped flying"
|
||||
|
||||
[node name="PlantedHBoxContainer" type="HBoxContainer" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection" unique_id=1198840955]
|
||||
layout_mode = 2
|
||||
script = ExtResource("2_ijoei")
|
||||
search_depth = 10
|
||||
|
||||
[node name="StartedPlanted" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/PlantedHBoxContainer" unique_id=1231817717 instance=ExtResource("3_ijoei")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
ForEvent = 3
|
||||
Title = "On weapon planted"
|
||||
|
||||
[node name="WhilePlanted" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/PlantedHBoxContainer" unique_id=1222663623 instance=ExtResource("3_ijoei")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
ForEvent = 5
|
||||
Title = "While planted"
|
||||
|
||||
[node name="StoppedPlanted" parent="Inventory/MenuPanelContainer/MarginContainer/BoxContainer/PlayerSectionMargin/PlayerSection/PlantedHBoxContainer" unique_id=2136675723 instance=ExtResource("3_ijoei")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
ForEvent = 4
|
||||
Title = "On weapon unplanted"
|
||||
|
||||
Reference in New Issue
Block a user