public override void Undo(Game g) { ICanHaveCounters ichc = (ICanHaveCounters)Target.Value(g); ichc.RemoveCounter(addedCounter); g.GameObjects.Remove(addedCounter); }
public override void Do(Game g) { ICanHaveCounters ichc = (ICanHaveCounters)Source.Value(g); Counter cnt = ichc.GetAllCounters(g).Where(x => { return(x.MyType == Type); }).FirstOrDefault(); //Default is null for reference types if (cnt != null) { removedCounter = new LazyGameObject <Counter>(cnt); ichc.RemoveCounter(cnt); g.GameObjects.Remove(cnt); } }