protected void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { context.KeyDown -= Context_KeyDown; context.KeyUp -= Context_KeyUp; context.MouseUp -= Context_MouseUp; context.MouseDown -= Context_MouseDown; context.PreUpdateFrame -= Context_PreUpdateFrame; keyStates.Clear(); keysWaitingDown.Clear(); keysWaitingUp.Clear(); } context = null; keyStates = null; keysWaitingDown = null; keysWaitingUp = null; disposed = true; }
internal AptObject(AptContext context) { // this should almost certainly run once, but GUIDs arent **guaranteed** to be unique, // theyre astronomically likely to be unique. do { // get a 32 digit GUID for this object. Guid = System.Guid.NewGuid().ToString("N"); }while (context.objectTable.ContainsKey(Guid)); context.objectTable.Add(Guid, this); children = new List <AptObject>(); components = new HashSet <AptComponent>(); Transform = new Transform(); Context = context; }
public AptInput(AptContext aptContext) { context = aptContext; context.KeyDown += Context_KeyDown; context.KeyUp += Context_KeyUp; context.MouseDown += Context_MouseDown; context.MouseUp += Context_MouseUp; context.PreUpdateFrame += Context_PreUpdateFrame; keyStates = new Dictionary <KeyCode, KeyState>(); foreach (var key in Enum.GetValues(typeof(KeyCode)).Cast <KeyCode>()) { keyStates.Add(key, KeyState.Up); } keysWaitingDown = new OrderedHashSet <KeyCode>(); keysWaitingUp = new OrderedHashSet <KeyCode>(); }