public void Unsubscribe(ITakesInput thing, string layer) { if (layerMap.ContainsKey(layer) && layerMap[layer] == thing) { layerMap.Remove(layer); thing.Claims.Disconnect(nameof(InputClaims.PostClaimUpdate), this, nameof(OnChildPostUpdate)); } else { GD.PrintErr("Tried to unsubscribe someone else's layer"); // GD.Print(new System.Diagnostics.StackTrace()); GD.PrintErr(layer); } }
public PickingMixin(ITakesInput recipient = null, bool permeable = true, string mouseOnHandler = null, string mouseOffHandler = null) { InputRecipient = recipient; Permeable = permeable; if (!(InputRecipient is null)) { if (!(mouseOnHandler is null)) { Connect(nameof(MousedOn), (Godot.Object)InputRecipient, mouseOnHandler); } if (!(mouseOffHandler is null)) { Connect(nameof(MousedOff), (Godot.Object)InputRecipient, mouseOffHandler); } } }
public void Subscribe(ITakesInput newChild, string layer) { if (!layerPriorities.Contains(layer)) { GD.PrintErr("layer <", layer, "> does not exist."); } else if (layerMap.ContainsKey(layer)) { GD.PrintErr("layer <", layer, "> is occupied."); } else { layerMap[layer] = newChild; newChild.Claims.Connect(nameof(InputClaims.PostClaimUpdate), this, nameof(OnChildPostUpdate), new Godot.Collections.Array { layer }); } }