public bool ResolveIntent(PlayerIntent <GameplayIntent> intent) { if (intent.Action != GameplayIntent.PrimaryAction || HoveredItem == -1) { return(false); } Callbacks[HoveredItem](); return(true); }
public override void _Process(float delta) { base._Process(delta); string[] actions = { "select_prisoner", "open_context_menu", "select_multiple_prisoners" }; GameplayIntent[] intents = { GameplayIntent.PrimaryAction, GameplayIntent.SecondaryAction, GameplayIntent.MultipleSelect }; for (int i = 0; i < 3; ++i) { if (Input.IsActionJustPressed(actions[i])) { PlayerIntent <GameplayIntent> intent = new PlayerIntent <GameplayIntent>( intents[i], PlayerIntent <GameplayIntent> .ActionType.Pressed, new Dictionary <GameplayIntent, bool> { { GameplayIntent.PrimaryAction, Input.IsActionPressed("select_prisoner") }, { GameplayIntent.SecondaryAction, Input.IsActionPressed("open_context_menu") }, { GameplayIntent.MultipleSelect, Input.IsActionPressed("select_multiple_prisoners") } } ); if (IntentList.ResolveIntent(intent)) { break; } if (Input.IsActionJustPressed("select_prisoner")) { if (Input.IsActionPressed("select_multiple_prisoners")) { SelectAdditionalPrisoners(HoveredPrisoners); } else { if (HoveredPrisoners.Count != 0) { SelectSinglePrisoner(HoveredPrisoners[0]); } else { DeselectAllprisoners(); } } ContextMenu.Visible = false; } if (Input.IsActionJustPressed("open_context_menu")) { ContextMenu.Visible = true; ContextMenuPosition.Position = LevelRoot.GetGlobalMousePosition(); ContextMenu.SetItems(new List <ContextMenu.Item> { new ContextMenu.Item("Guard Area", () => { GD.Print("Guarding Area..."); }), new ContextMenu.Item("Hide Contraband", () => { GD.Print("Hiding Contraband..."); }), new ContextMenu.Item("Dig Tunnel", () => { GD.Print("Digging Tunnel..."); }) }); } } } }
public bool ResolveIntent(PlayerIntent <T> intent) { return(false); }