-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHasBlueprint.swift
More file actions
37 lines (33 loc) · 842 Bytes
/
HasBlueprint.swift
File metadata and controls
37 lines (33 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// HasBlueprint.swift
// Jikoku
//
// Created by Raphaël Calabro on 07/09/2017.
// Copyright © 2017 Raphaël Calabro. All rights reserved.
//
import Foundation
protocol HasBlueprint : HasBlueprints {
var blueprint: SpriteBlueprint { get }
var spriteDefinition: Int? { get set }
}
protocol HasBlueprints {
var blueprints: [SpriteBlueprint] { get }
var spriteDefinitions: [Int] { get set }
}
extension HasBlueprint {
var blueprints: [SpriteBlueprint] {
return [blueprint]
}
var definitionIndex: Int? {
get {
return !spriteDefinitions.isEmpty ? spriteDefinitions[0] : nil
}
set {
if let newValue = newValue {
spriteDefinitions = [newValue]
} else {
spriteDefinitions = []
}
}
}
}