public virtual void GenerateLightSwitch() { Doorway target = doorways[0]; Vector2 position = new Vector2(target.x, target.y); if (target.roomOutDirection == Direction.North) { position.y += 1; if (Random.value > .5f || target.x == x) { position.x += target.breadth; } else { position.x -= 1; } } else if (target.roomOutDirection == Direction.South) { if (Random.value > .5f || target.x == x) { position.x += target.breadth; } else { position.x -= 1; } } else if (target.roomOutDirection == Direction.East) { if (Random.value > .5f || target.y == y) { position.y += target.breadth; } else { position.y -= 1; } } else if (target.roomOutDirection == Direction.West) { if (Random.value > .5f || target.y == y) { position.y += target.breadth; } else { position.y -= 1; } } lightSwitch = (LightSwitch)InstantiateFurniture(PrefabRegistry.I.lightSwitch.GetComponent <LightSwitch>(), position); if (lightSwitch) { lightSwitch.GetComponent <DoubleCardinalSprite>().UpdateDirection(DirectionUtil.Reverse(target.roomOutDirection)); } lightSwitch.gameObject.name = GetType().Name + " LightSwitch"; }