0.2.0-dev Download ZIP
98 lines ·5.3 KB Raw
| 1 | using EvilEngine.Formats; |
| 2 | |
| 3 | namespace EvilEngine.Host.Actions; |
| 4 | |
| 5 | public static class EngineActions |
| 6 | { |
| 7 | public const string Namespace = "evil"; |
| 8 | |
| 9 | public const double LookYawSpeed = 210; |
| 10 | public const double LookPitchSpeed = 225; |
| 11 | public const double MouseDegreesPerCount = 0.022; |
| 12 | |
| 13 | public static readonly ContentId Move = Id("move"); |
| 14 | public static readonly ContentId Look = Id("look"); |
| 15 | public static readonly ContentId Jump = Id("jump"); |
| 16 | public static readonly ContentId Crouch = Id("crouch"); |
| 17 | public static readonly ContentId Walk = Id("walk"); |
| 18 | public static readonly ContentId Sprint = Id("sprint"); |
| 19 | public static readonly ContentId Noclip = Id("noclip"); |
| 20 | public static readonly ContentId Use = Id("use"); |
| 21 | public static readonly ContentId Attack = Id("attack"); |
| 22 | public static readonly ContentId Attack2 = Id("attack2"); |
| 23 | public static readonly ContentId Reload = Id("reload"); |
| 24 | public static readonly ContentId Flashlight = Id("flashlight"); |
| 25 | public static readonly ContentId AltModifier = Id("alt_modifier"); |
| 26 | public static readonly ContentId PreviousWeapon = Id("previous_weapon"); |
| 27 | public static readonly ContentId NextWeapon = Id("next_weapon"); |
| 28 | public static readonly ContentId LastWeapon = Id("last_weapon"); |
| 29 | public static readonly ContentId Undo = Id("undo"); |
| 30 | public static readonly ContentId SpawnMenu = Id("spawn_menu"); |
| 31 | public static readonly ContentId ContextMenu = Id("context_menu"); |
| 32 | public static readonly ContentId Chat = Id("chat"); |
| 33 | public static readonly ContentId TeamChat = Id("team_chat"); |
| 34 | public static readonly ContentId Voice = Id("voice"); |
| 35 | public static readonly ContentId Scoreboard = Id("scoreboard"); |
| 36 | public static readonly ContentId PauseMenu = Id("pause_menu"); |
| 37 | public static readonly ContentId Console = Id("console"); |
| 38 | public static readonly ContentId ThirdPerson = Id("third_person"); |
| 39 | public static readonly ContentId ViewMode = Id("view_mode"); |
| 40 | public static readonly ContentId ShoulderSwap = Id("shoulder_swap"); |
| 41 | |
| 42 | public static readonly IReadOnlyList<ContentId> Slots = |
| 43 | [.. Enumerable.Range(1, 10).Select(slot => Id($"slot{slot % 10}"))]; |
| 44 | |
| 45 | private static readonly IReadOnlyList<InputAction> Actions = |
| 46 | [ |
| 47 | InputAction.Vector(Move, "Move", "Movement", |
| 48 | "key:w/up", "key:s/down", "key:a/left", "key:d/right", "pad:left_stick"), |
| 49 | InputAction.Vector(Look, "Look", "Movement", |
| 50 | "mouse:motion", "key:up/up", "key:down/down", "key:left/left", "key:right/right", "pad:right_stick"), |
| 51 | InputAction.Button(Jump, "Jump", "Movement", "key:space", "pad:a"), |
| 52 | InputAction.Button(Crouch, "Crouch", "Movement", "key:ctrl", "pad:left_stick_click"), |
| 53 | InputAction.Button(Walk, "Walk", "Movement"), |
| 54 | InputAction.Button(Sprint, "Sprint", "Movement", "key:shift", "pad:right_stick_click"), |
| 55 | InputAction.Button(Noclip, "Noclip", "Movement", "key:v", "pad:dpad_down"), |
| 56 | InputAction.Button(Use, "Use", "Actions", "key:e", "pad:x"), |
| 57 | InputAction.Button(Attack, "Attack", "Actions", "mouse:left", "key:enter", "pad:right_trigger"), |
| 58 | InputAction.Button(Attack2, "Secondary attack", "Actions", "mouse:right", "pad:left_trigger"), |
| 59 | InputAction.Button(Reload, "Reload", "Actions", "key:r", "pad:b"), |
| 60 | InputAction.Button(Flashlight, "Flashlight", "Actions", "key:f", "pad:y"), |
| 61 | InputAction.Button(AltModifier, "Alternate mode", "Actions", "key:alt"), |
| 62 | .. Enumerable.Range(1, 10).Select(slot => |
| 63 | InputAction.Button(Slots[slot - 1], $"Weapon slot {slot % 10}", "Weapons", $"key:{slot % 10}")), |
| 64 | InputAction.Button(PreviousWeapon, "Previous weapon", "Weapons", "mouse:wheel_up", "pad:left_shoulder"), |
| 65 | InputAction.Button(NextWeapon, "Next weapon", "Weapons", "mouse:wheel_down", "pad:right_shoulder"), |
| 66 | InputAction.Button(LastWeapon, "Last weapon", "Weapons", "mouse:back"), |
| 67 | InputAction.Button(Undo, "Undo", "Building", "key:z", "pad:dpad_up"), |
| 68 | InputAction.Button(SpawnMenu, "Spawn menu", "Building", "key:q", "pad:dpad_left"), |
| 69 | InputAction.Button(ContextMenu, "Context menu", "Building", "key:c"), |
| 70 | InputAction.Button(Chat, "Chat", "Communication", "key:y"), |
| 71 | InputAction.Button(TeamChat, "Team chat", "Communication", "key:u"), |
| 72 | InputAction.Button(Voice, "Voice", "Communication", "key:x", "mouse:forward", "pad:dpad_right"), |
| 73 | InputAction.Button(Scoreboard, "Scoreboard", "Communication", "key:tab", "pad:back"), |
| 74 | InputAction.Button(ThirdPerson, "Third person", "View", "key:p"), |
| 75 | InputAction.Button(ViewMode, "Next view mode", "View", "key:f6"), |
| 76 | InputAction.Button(ShoulderSwap, "Swap shoulders", "View", "mouse:middle"), |
| 77 | InputAction.Button(PauseMenu, "Pause menu", "Interface", "key:escape", "pad:start"), |
| 78 | InputAction.Button(Console, "Console", "Interface", "key:backquote", "key:f10") |
| 79 | ]; |
| 80 | |
| 81 | public static ActionRegistry Registry() |
| 82 | { |
| 83 | var registry = new ActionRegistry(); |
| 84 | Declare(registry); |
| 85 | return registry; |
| 86 | } |
| 87 | |
| 88 | public static void Declare(ActionRegistry registry) |
| 89 | { |
| 90 | foreach (var action in Actions) |
| 91 | registry.Declare(action); |
| 92 | } |
| 93 | |
| 94 | private static ContentId Id(string name) |
| 95 | { |
| 96 | return ContentId.Create(Namespace, name); |
| 97 | } |
| 98 | } |