Skip to content

Commit

Permalink
Keyboard: Disable footsteps/gun. Gates: add mul/div
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebual committed Jun 13, 2021
1 parent a7d4164 commit 0eb8516
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions code/LockedPositionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public override void Simulate()
EyeRot = Input.Rotation;

if ( GroundBody == null ) {
Pawn.Inventory.SetActiveSlot(-1, true);
var trace = TraceBBox( Position, Position + Velocity * Time.Delta - new Vector3( 0, 0, 5 ) );
if ( trace.Hit && trace.Body != null ) {
GroundBody = trace.Body;
Expand Down
7 changes: 7 additions & 0 deletions code/Player.wire.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ public void OnFrame()
}
}
}
public override void OnAnimEventFootstep( Vector3 pos, int foot, float volume )
{
if ( GetActiveController().GetType() == typeof( LockedPositionController ) ) {
return;
}
base.OnAnimEventFootstep( pos, foot, volume );
}
}
22 changes: 21 additions & 1 deletion code/entities/WireGateEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class WireGateEntity : Prop, WireInputEntity, WireOutputEntity, I

public static IEnumerable<string> GetGates()
{
return new string[] { "Constant", "Add", "Subtract", "Negate", "Not", "And", "Or" };
return new string[] { "Constant", "Add", "Subtract", "Multiply", "Divide", "Negate", "Not", "And", "Or" };
}
public void WireInitialize()
{
Expand Down Expand Up @@ -50,6 +50,26 @@ public void WireInitialize()
this.WireTriggerOutput( "Out", outValue );
}, new string[] { "A", "B", "C", "D", "E", "F", "G", "H" } );
}
else if ( GateType == "Multiply" ) {
BulkRegisterInputHandlers( ( float value ) => {
var connectedInputs = inputs.Values.Where((input) => input.connectedOutput != null);
float outValue = 1;
foreach(var input in connectedInputs) {
outValue *= Convert.ToSingle(input.value);
}
this.WireTriggerOutput( "Out", outValue );
}, new string[] { "A", "B", "C", "D", "E", "F", "G", "H" } );
}
else if ( GateType == "Divide" ) {
BulkRegisterInputHandlers( ( float value ) => {
var b = Convert.ToSingle( inputs["B"].value );
if (b == 0) {
this.WireTriggerOutput( "Out", 0 );
} else {
this.WireTriggerOutput( "Out", Convert.ToSingle( inputs["A"].value ) / b );
}
}, new string[] { "A", "B" } );
}
else if ( GateType == "Negate" ) {
this.RegisterInputHandler( "A", ( float value ) => {
this.WireTriggerOutput( "Out", -value );
Expand Down

0 comments on commit 0eb8516

Please sign in to comment.