public ModifyObject(EditroidUndoRedoQueue q, Screen screen, ObjectInstance obj, int newValue, ObjectModification change) : base(q, screen, obj) { this.change = change; this.newValue = newValue; oldValue = GetValue(); }
public ModifyObject(EditroidUndoRedoQueue q, Screen screen, ObjectInstance obj, Point newLocation) : base(q, screen, obj) { this.change = ObjectModification.Location; // The ROM packs object locations into a single byte. this.newValue = 0xFF & ((newLocation.X & 0x0F) | (newLocation.Y << 4)); oldValue = GetValue(); }
public static IObservable <(IObjectSpace objectSpace, object[] objects)> WhenModifiedObjects(this IObjectSpace objectSpace, ObjectModification objectModification = ObjectModification.All, params Type[] objectTypes) =>
public static IEnumerable <T> ModifiedObjects <T>(this IObjectSpace objectSpace, ObjectModification objectModification) { return(objectSpace.ModifiedObjects.Cast <object>().Select(o => o).OfType <T>().Where(_ => { if (objectModification == ObjectModification.Deleted) { return objectSpace.IsDeletedObject(_); } if (objectModification == ObjectModification.New) { return objectSpace.IsNewObject(_); } if (objectModification == ObjectModification.Updated) { return objectSpace.IsUpdated(_); } if (objectModification == ObjectModification.NewOrDeleted) { return objectSpace.IsNewObject(_) || objectSpace.IsDeletedObject(_); } if (objectModification == ObjectModification.NewOrUpdated) { return objectSpace.IsNewObject(_) || objectSpace.IsUpdated(_); } if (objectModification == ObjectModification.DeletedOrUpdated) { return objectSpace.IsUpdated(_) || objectSpace.IsDeletedObject(_); } return true; })); }
public static IObservable <T> WhenModifiedObjects <T>(this IObjectSpace objectSpace, bool emitAfterCommit = false, ObjectModification objectModification = ObjectModification.All) { return(objectSpace.WhenCommiting().SelectMany(_ => { var modifiedObjects = objectSpace.ModifiedObjects <T>(objectModification).ToArray(); return emitAfterCommit ? objectSpace.WhenCommited().FirstAsync().SelectMany(pattern => modifiedObjects) : modifiedObjects.ToObservable(); })); }
public static IObservable <(IObjectSpace objectSpace, object[] objects)> WhenModifiedObjects(this IObjectSpace objectSpace, bool emitAfterCommit, ObjectModification objectModification = ObjectModification.All, params Type[] objectTypes) => objectSpace.WhenCommiting(objectModification, emitAfterCommit, objectTypes);
public static IObservable <(IObjectSpace objectSpace, object[] objects)> WhenModifiedObjects <T>(this IObjectSpace objectSpace, bool emitAfterCommit = false, ObjectModification objectModification = ObjectModification.All) { return(objectSpace.WhenModifiedObjects(objectModification, emitAfterCommit, typeof(T)));
public static IObservable <(IObjectSpace objectSpace, object[] objects)> WhenModifiedObjects(this IObjectSpace objectSpace, ObjectModification objectModification, bool emitAfterCommit, params Type[] objectTypes) { if (!objectTypes.Any()) { objectTypes = objectTypes.Add(typeof(object)); } return(objectSpace.WhenCommiting().SelectMany(_ => { var modifiedObjects = objectSpace.ModifiedObjects(objectModification).Where(o => objectTypes.Any(type => type.IsInstanceOfType(o))).ToArray(); if (modifiedObjects.Any()) { return emitAfterCommit ? objectSpace.WhenCommited().FirstAsync().Select(pattern => (pattern.objectSpace, modifiedObjects)) : (objectSpace, modifiedObjects).ReturnObservable(); } return Observable.Empty <(IObjectSpace objectSpace, object[] objects)>(); })); }
public static IObservable <(IObjectSpace objectSpace, object[] objects)> WhenModifiedObjects(this IObjectSpace objectSpace, ObjectModification objectModification = ObjectModification.All, params Type[] objectTypes) { return(objectSpace.WhenModifiedObjects(objectModification, false, objectTypes)); }
public ModifyObject(EditroidUndoRedoQueue q, Screen screen, ObjectInstance obj, bool newValue, ObjectModification change) : this(q, screen, obj, newValue ? -1 : 0, change) { }