public GameDebugTree(IGame game, IRenderLayer layer, InspectorPanel inspector) { _game = game; _inspector = inspector; _addedObjects = new AGSConcurrentHashSet <string>(100, false); _layer = layer; }
private int _inUpdate; //For preventing re-entrancy public AGSInput(IGameEvents events, IShouldBlockInput shouldBlockInput, IAGSCursor cursor, IAGSHitTest hitTest, IEvent <API.MouseButtonEventArgs> mouseDown, IEvent <API.MouseButtonEventArgs> mouseUp, IEvent <MousePositionEventArgs> mouseMove, IEvent <KeyboardEventArgs> keyDown, IEvent <KeyboardEventArgs> keyUp, ICoordinates coordinates) { _cursor = cursor; _events = events; _hitTest = hitTest; _actions = new ConcurrentQueue <Func <Task> >(); _coordinates = coordinates; _shouldBlockInput = shouldBlockInput; _keysDown = new AGSConcurrentHashSet <API.Key>(); MouseDown = mouseDown; MouseUp = mouseUp; MouseMove = mouseMove; KeyDown = keyDown; KeyUp = keyUp; if (AGSGameWindow.GameWindow != null) { init(AGSGameWindow.GameWindow); } else { AGSGameWindow.OnInit = () => init(AGSGameWindow.GameWindow); } }
public GameDebugTree(AGSEditor editor, IRenderLayer layer, InspectorPanel inspector) { _editor = editor; _inspector = inspector; _entitiesToNodes = new ConcurrentDictionary <string, ITreeStringNode>(); _addedObjects = new AGSConcurrentHashSet <string>(100, false); _roomSubscribers = new List <RoomSubscriber>(20); _layer = layer; }
public AGSInput(GameWindow game, AGS.API.Size virtualResolution, IGameState state, IAGSRoomTransitions roomTransitions, IGameWindowSize windowSize) { _windowSize = windowSize; this._roomTransitions = roomTransitions; this._virtualWidth = virtualResolution.Width; this._virtualHeight = virtualResolution.Height; this._state = state; this._keysDown = new AGSConcurrentHashSet<Key>(); this._game = game; this._originalOSCursor = _game.Cursor; MouseDown = new AGSEvent<AGS.API.MouseButtonEventArgs>(); MouseUp = new AGSEvent<AGS.API.MouseButtonEventArgs>(); MouseMove = new AGSEvent<MousePositionEventArgs>(); KeyDown = new AGSEvent<KeyboardEventArgs>(); KeyUp = new AGSEvent<KeyboardEventArgs>(); game.MouseDown += async (sender, e) => { if (isInputBlocked()) return; var button = convert(e.Button); if (button == AGS.API.MouseButton.Left) LeftMouseButtonDown = true; else if (button == AGS.API.MouseButton.Right) RightMouseButtonDown = true; await MouseDown.InvokeAsync(sender, new AGS.API.MouseButtonEventArgs(button, convertX(e.X), convertY(e.Y))); }; game.MouseUp += async (sender, e) => { if (isInputBlocked()) return; var button = convert(e.Button); if (button == AGS.API.MouseButton.Left) LeftMouseButtonDown = false; else if (button == AGS.API.MouseButton.Right) RightMouseButtonDown = false; await MouseUp.InvokeAsync(sender, new AGS.API.MouseButtonEventArgs(button, convertX(e.X), convertY(e.Y))); }; game.MouseMove += async (sender, e) => { if (isInputBlocked()) return; await MouseMove.InvokeAsync(sender, new MousePositionEventArgs(convertX(e.X), convertY(e.Y))); }; game.KeyDown += async (sender, e) => { Key key = convert(e.Key); _keysDown.Add(key); if (isInputBlocked()) return; await KeyDown.InvokeAsync(sender, new KeyboardEventArgs(key)); }; game.KeyUp += async (sender, e) => { Key key = convert(e.Key); _keysDown.Remove(key); if (isInputBlocked()) return; await KeyUp.InvokeAsync(sender, new KeyboardEventArgs(key)); }; }
public KeyboardMovement(IInput input, IFocusedUI focusedUi) { _focusedUi = focusedUi; Enabled = true; _up = new AGSConcurrentHashSet <Key> (); _down = new AGSConcurrentHashSet <Key> (); _left = new AGSConcurrentHashSet <Key> (); _right = new AGSConcurrentHashSet <Key> (); _keysDown = new AGSConcurrentHashSet <Key> (); input.KeyDown.SubscribeToAsync(onKeyDown); input.KeyUp.SubscribeToAsync(onKeyUp); }
public KeyboardMovement(ICharacter character, IInput input, KeyboardMovementMode mode) { _character = character; Enabled = true; Mode = mode; _up = new AGSConcurrentHashSet<Key> (); _down = new AGSConcurrentHashSet<Key> (); _left = new AGSConcurrentHashSet<Key> (); _right = new AGSConcurrentHashSet<Key> (); _keysDown = new AGSConcurrentHashSet<Key> (); input.KeyDown.SubscribeToAsync(onKeyDown); input.KeyUp.SubscribeToAsync(onKeyUp); }
public KeyboardMovement(ICharacter character, IInput input, IFocusedUI focusedUi, KeyboardMovementMode mode) { _character = character; _focusedUi = focusedUi; Enabled = true; Mode = mode; _up = new AGSConcurrentHashSet <Key> (); _down = new AGSConcurrentHashSet <Key> (); _left = new AGSConcurrentHashSet <Key> (); _right = new AGSConcurrentHashSet <Key> (); _keysDown = new AGSConcurrentHashSet <Key> (); input.KeyDown.SubscribeToAsync(onKeyDown); input.KeyUp.SubscribeToAsync(onKeyUp); }
private ISound playSound(float volume, float pitch, float panning, IConcurrentHashSet <string> tags, bool looping = false) { //Debug.WriteLine("Playing Sound: " + ID); int source = getSource(); ALSound sound = new ALSound(source, Duration, volume, pitch, looping, panning, tags, _errors, _backend); _playingSounds.Add(sound); OnSoundStarted.Invoke(sound); sound.Play(_buffer.Value); sound.Completed.ContinueWith(_ => { _system.ReleaseSource(source); _playingSounds.Remove(sound); OnSoundCompleted.Invoke(sound); }); return(sound); }
public ALSound(int source, float duration, float volume, float pitch, bool isLooping, float panning, IConcurrentHashSet <string> tags, IAudioErrors errors, IAudioBackend backend) { //Using delegates to avoid heap allocations modifierChangeCallback = onModifierChanged; SoundModifiers = new AGSBindingList <ISoundModifier>(3); SoundModifiers.OnListChanged.Subscribe(onModifiersChanged); Tags = tags; _tcs = new TaskCompletionSource <object> (null); _backend = backend; _source = source; _volume = volume; Duration = duration; _pitch = pitch; _panning = panning; IsLooping = isLooping; _errors = errors; }
private int _inUpdate; //For preventing re-entrancy public AGSInput(IGameState state, IGameEvents events, IShouldBlockInput shouldBlockInput, IGameWindowSize windowSize) { _events = events; _actions = new ConcurrentQueue <Func <Task> >(); _windowSize = windowSize; this._shouldBlockInput = shouldBlockInput; API.MousePosition.GetWindowWidth = () => _windowSize.GetWidth(_game); API.MousePosition.GetWindowHeight = () => _windowSize.GetHeight(_game); this._state = state; this._keysDown = new AGSConcurrentHashSet <API.Key>(); MouseDown = new AGSEvent <AGS.API.MouseButtonEventArgs>(); MouseUp = new AGSEvent <AGS.API.MouseButtonEventArgs>(); MouseMove = new AGSEvent <MousePositionEventArgs>(); KeyDown = new AGSEvent <KeyboardEventArgs>(); KeyUp = new AGSEvent <KeyboardEventArgs>(); if (AGSGameWindow.GameWindow != null) { Init(AGSGameWindow.GameWindow); } }
public AGSEvent() { _id = Guid.NewGuid(); _invocationList = new AGSConcurrentHashSet <Callback>(fireListChangedEvent: false); }
public EventCallbacksSingleList() { _list = new AGSConcurrentHashSet <Callback>(fireListChangedEvent: false); }
public EventCallbacksSingleList(int capacity) { _list = new AGSConcurrentHashSet <Callback>(capacity, fireListChangedEvent: false); }
public AGSInput(GameWindow game, AGS.API.Size virtualResolution, IGameState state, IShouldBlockInput shouldBlockInput, IGameWindowSize windowSize) { _windowSize = windowSize; this._shouldBlockInput = shouldBlockInput; this._virtualWidth = virtualResolution.Width; this._virtualHeight = virtualResolution.Height; this._state = state; this._keysDown = new AGSConcurrentHashSet <Key>(); this._game = game; this._originalOSCursor = _game.Cursor; MouseDown = new AGSEvent <AGS.API.MouseButtonEventArgs>(); MouseUp = new AGSEvent <AGS.API.MouseButtonEventArgs>(); MouseMove = new AGSEvent <MousePositionEventArgs>(); KeyDown = new AGSEvent <KeyboardEventArgs>(); KeyUp = new AGSEvent <KeyboardEventArgs>(); game.MouseDown += async(sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); if (button == AGS.API.MouseButton.Left) { LeftMouseButtonDown = true; } else if (button == AGS.API.MouseButton.Right) { RightMouseButtonDown = true; } await MouseDown.InvokeAsync(sender, new AGS.API.MouseButtonEventArgs(button, convertX(e.X), convertY(e.Y))); }; game.MouseUp += async(sender, e) => { if (isInputBlocked()) { return; } var button = convert(e.Button); if (button == AGS.API.MouseButton.Left) { LeftMouseButtonDown = false; } else if (button == AGS.API.MouseButton.Right) { RightMouseButtonDown = false; } await MouseUp.InvokeAsync(sender, new AGS.API.MouseButtonEventArgs(button, convertX(e.X), convertY(e.Y))); }; game.MouseMove += async(sender, e) => { if (isInputBlocked()) { return; } await MouseMove.InvokeAsync(sender, new MousePositionEventArgs(convertX(e.X), convertY(e.Y))); }; game.KeyDown += async(sender, e) => { Key key = convert(e.Key); _keysDown.Add(key); if (isInputBlocked()) { return; } await KeyDown.InvokeAsync(sender, new KeyboardEventArgs(key)); }; game.KeyUp += async(sender, e) => { Key key = convert(e.Key); _keysDown.Remove(key); if (isInputBlocked()) { return; } await KeyUp.InvokeAsync(sender, new KeyboardEventArgs(key)); }; }
public AGSTreeNode(TItem node = null, IConcurrentHashSet <TItem> children = null) { OnParentChanged = new AGSEvent <AGSEventArgs>(); _children = children ?? new AGSConcurrentHashSet <TItem>(); Node = node; }