-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RegisterInputHandler() which takes a delegate; track its type
Fixes #1
- Loading branch information
Showing
8 changed files
with
106 additions
and
74 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
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 |
---|---|---|
@@ -1,19 +1,11 @@ | ||
using Sandbox; | ||
public partial class LightEntity : WireInputEntity | ||
{ | ||
public string[] WireGetInputs() | ||
WirePortData IWireEntity.WirePorts { get; } = new WirePortData(); | ||
public void WireInitialize() | ||
{ | ||
return new string[] { "On" }; | ||
} | ||
void WireInputEntity.HandleWireInput<T>( string inputName, T value ) | ||
{ | ||
if ( inputName == "On" ) { | ||
if ( typeof( T ) == typeof( int ) ) { | ||
Enabled = ((int)(object)value) != 0; | ||
} | ||
if ( typeof( T ) == typeof( float ) ) { | ||
Enabled = (float)(object)value != 0.0f; | ||
} | ||
} | ||
((WireInputEntity)this).RegisterInputHandler( "On", ( bool value ) => { | ||
Enabled = value; | ||
} ); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Sandbox | ||
{ | ||
public class WirePortData | ||
{ | ||
public Dictionary<string, Action<object>> inputHandlers { get; } = new Dictionary<string, Action<object>>(); | ||
public Dictionary<string, WireInput> inputs = new Dictionary<string, WireInput>(); | ||
public Dictionary<string, WireOutput> outputs = new Dictionary<string, WireOutput>(); | ||
|
||
} | ||
|
||
public interface IWireEntity | ||
{ | ||
public WirePortData WirePorts { get; } | ||
} | ||
} |
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