Skip to content

Instantly share code, notes, and snippets.

View vanhouc's full-sized avatar

Cameron VanHouzen vanhouc

View GitHub Profile
@vanhouc
vanhouc / utils.ts
Last active August 29, 2015 14:28
Find pathable tiles
findPathableAround(target: RoomPosition): RoomPosition[]
findPathableAround(target: { pos: RoomPosition }): RoomPosition[]
findPathableAround(target: any, ignoreCreeps: boolean = false): RoomPosition[] {
var pos: RoomPosition = target.pos ? target.pos : target;
var room = Game.rooms[pos.roomName];
var pathableTiles: RoomPosition[] = [];
var area = room.lookAtArea(pos.y - 1, pos.x - 1, pos.y + 1, pos.x + 1);
for (var x in area) {
for (var y in area[x]) {
var results: LookAtResult[] = y;
@vanhouc
vanhouc / somePosThing.js
Last active August 29, 2015 14:28
RoomPos equality
saveRoomPos(target) {
var pos = target.pos ? target.pos : target
if (!Memory.positions) Memory.positions = [];
Memory.positions.push({x: pos.x, y: pos.y, roomName: pos.roomName});
}
isInMemory(target) {
if (!Memory.positions) return false;
return _.find(Memory.positions, function(pos) new RoomPosition(pos.x, pos.y, pos.roomName).isEqualTo(target)) != null;
}
@vanhouc
vanhouc / gulpfile.js
Last active November 26, 2022 19:48
screeps typescript stuff
var gulp = require('gulp');
var ts = require('gulp-typescript');
var https = require('https');
var fs = require('fs');
var secrets = require('./secrets.js')
gulp.task('compile', function () {
var tsResult = gulp.src(['src/**/*.ts', 'typings/**/*.d.ts'])
.pipe(ts({
noImplicitAny: true,
@vanhouc
vanhouc / TransactionViewModel.cs
Created February 13, 2014 01:36
Prototype of what the TransactionViewModel should look like
using Quagga.DbDomain
namespace Quagga.POS
{
class TransactionViewModel: INotifyPropertyChanged
{
private IDbItemCommands _dbItems;
private IDbTransactionCommands _dbTrans;
public TransactionViewModel(IDbItemCommands dbItems, IDbTransactionCommands dbTrans)
{
@vanhouc
vanhouc / XMLService.cs
Last active August 29, 2015 13:55
Some clever XML reading
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Linq;
namespace SystemCheckerPlus
{
class XMLService
{
/*QuizBuilder create_database query
By: Cameron VanHouzen
Date: 1/29/14
The MIT License (MIT)
Copyright (c) <2014> <Cameron VanHouzen>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights