Skip to content

Instantly share code, notes, and snippets.


Scott Lilly ScottLilly

View GitHub Profile
View ConsoleUpdateExtensions.cs
public static class ConsoleUpdateExtensions
internal static readonly Dictionary<IConsole, Dictionary<string, Func>> LineUpdates
= new Dictionary<IConsole, Dictionary<string, Func>>();
public static Dictionary<string, Func> GetUpdates(this IConsole console) => LineUpdates.ContainsKey(console) ? LineUpdates[console] : null;
public static void AddLineUpdate(this IConsole console, string key, Func value)
if (!LineUpdates.ContainsKey(console))
LineUpdates.Add(console, new Dictionary<string, Func>());
ScottLilly / MainWindow.xaml
Created Mar 5, 2021
Lesson 18.5: Update game loading and saving
View MainWindow.xaml
<Window x:Class="WPFUI.MainWindow"
d:DataContext="{d:DesignInstance viewModels:GameSession}"
Title="{Binding GameDetails.Title}" Height="768" Width="1024"
ScottLilly / CharacterCreationViewModel.cs
Last active Feb 22, 2021
Lesson 18.4: Adding Player Attributes to Living Entities
View CharacterCreationViewModel.cs
using System.Collections.ObjectModel;
using System.Linq;
using Engine.Factories;
using Engine.Models;
using Engine.Services;
namespace Engine.ViewModels
public class CharacterCreationViewModel : BaseNotificationClass
ScottLilly / DeleteQueryWithGrammar.cs
Created Oct 14, 2013
Source code for my "How to build a fluent interface in C#" blog post.
View DeleteQueryWithGrammar.cs
using System.Collections.Generic;
using BuildAFluentInterface.Interfaces;
namespace BuildAFluentInterface
public class DeleteQueryWithGrammar : ICanAddCondition, ICanAddWhereValue, ICanAddWhereOrRun
private readonly string _tableName;
private readonly List<WhereCondition> _whereConditions = new List<WhereCondition>();
ScottLilly / InventorySystem.cs
Created Oct 11, 2013
C# code for inventory system that has a limited number of slots, and the ability to stack some items (with a different maximum size stack for different items).
View InventorySystem.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace BusinessObjects.RedditRPGQuestion
public class InventorySystem
private const int MAXIMUM_SPACES_IN_INVENTORY = 10;
ScottLilly / SortedListWithFloorAndCeilingIntegerKey.cs
Created Oct 18, 2013
Specialized SortedList classes to let you search for the entry immediately before, or after, the requested key value.
View SortedListWithFloorAndCeilingIntegerKey.cs
using System;
using System.Collections.Generic;
namespace DotNetToolBox.Collections
public class SortedListWithFloorAndCeilingIntegerKey<TV> : SortedList<Int32, TV>
#region Floor object methods
public int FloorIndexFor(Int32 searchKey)
ScottLilly / Bedroom.cs
Created Nov 4, 2013
Sample of how to start building an RPG, with rooms that have different (and common) actions you can perform in them.
View Bedroom.cs
namespace BusinessObjects.RedditZorkQuestion
public class Bedroom : Room, ICanSleepHere
public Bedroom(string name) : base(name)
public void Sleep(Character character)