forked from space-wizards/RobustToolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Click Migration + Input Contexts (space-wizards#656)
* Migrated click handling from old `ClickParser` to new `InputSystem`. Resolves space-wizards#631. * Input Context system added. Resolves space-wizards#630. * `PlacementManager` now uses its own input context. * Added addon `Entrypoint.PostInit` function. * Moved EntitySystemManager initialization from after the first state update, to right after the EntitySystem init. * Made the EntitySystems only run Update/FrameUpdate/events after the map has been initialized.
- Loading branch information
Showing
29 changed files
with
860 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,7 @@ | |
|
||
- type: Collidable | ||
DebugColor: "#0000FF" | ||
|
||
- type: Input | ||
context: "human" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
SS14.Client/GameObjects/Components/Input/InputComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using SS14.Client.GameObjects.EntitySystems; | ||
using SS14.Shared.GameObjects; | ||
using SS14.Shared.Input; | ||
using SS14.Shared.Serialization; | ||
|
||
namespace SS14.Client.GameObjects.Components | ||
{ | ||
/// <summary> | ||
/// Defines data fields used in the <see cref="InputSystem"/>. | ||
/// </summary> | ||
class InputComponent : Component | ||
{ | ||
/// <inheritdoc /> | ||
public override string Name => "Input"; | ||
|
||
/// <summary> | ||
/// The context that will be made active for a client that attaches to this entity. | ||
/// </summary> | ||
public string ContextName { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public override void ExposeData(ObjectSerializer serializer) | ||
{ | ||
base.ExposeData(serializer); | ||
|
||
serializer.DataReadWriteFunction("context", InputContextContainer.DefaultContextName, value => ContextName = value, () => ContextName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using SS14.Shared.Input; | ||
|
||
namespace SS14.Client.Input | ||
{ | ||
/// <summary> | ||
/// Contains a helper function for setting up all default engine contexts. | ||
/// </summary> | ||
internal static class EngineContexts | ||
{ | ||
/// <summary> | ||
/// Adds the default set of engine contexts to a context container. | ||
/// </summary> | ||
/// <param name="contexts">Default contexts will be set up inside this container.</param> | ||
public static void SetupContexts(IInputContextContainer contexts) | ||
{ | ||
var common = contexts.GetContext(InputContextContainer.DefaultContextName); | ||
common.AddFunction(EngineKeyFunctions.EscapeMenu); | ||
common.AddFunction(EngineKeyFunctions.FocusChat); | ||
common.AddFunction(EngineKeyFunctions.ShowDebugMonitors); | ||
|
||
var editor = contexts.New("editor", common); | ||
editor.AddFunction(EngineKeyFunctions.EditorLinePlace); | ||
editor.AddFunction(EngineKeyFunctions.EditorGridPlace); | ||
editor.AddFunction(EngineKeyFunctions.EditorPlaceObject); | ||
editor.AddFunction(EngineKeyFunctions.EditorCancelPlace); | ||
editor.AddFunction(EngineKeyFunctions.EditorRotateObject); | ||
|
||
var human = contexts.New("human", common); | ||
human.AddFunction(EngineKeyFunctions.MoveUp); | ||
human.AddFunction(EngineKeyFunctions.MoveDown); | ||
human.AddFunction(EngineKeyFunctions.MoveLeft); | ||
human.AddFunction(EngineKeyFunctions.MoveRight); | ||
human.AddFunction(EngineKeyFunctions.Run); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.