Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // EntityOptionSet.swift
- // SoundSketch
- //
- // Created by alexanderbollbach on 3/25/17.
- // Copyright © 2017 alexanderbollbach. All rights reserved.
- //
- import Foundation
- protocol ModeSet {
- var modes: [Mode] { get set }
- init(with options: [Mode])
- }
- class LayerAnimationModes: ModeSet {
- var modes: [Mode]
- public required init(with modes: [Mode]) {
- self.modes = modes
- }
- public func state(forMode mode: String) -> Bool {
- if let mode = getMode(with: mode) {
- return mode.active
- }
- return false
- }
- public func update(with newMode: Mode) {
- if let oldMode = getMode(with: newMode.name) {
- oldMode.active = !newMode.active
- }
- }
- private func getMode(with name: String) -> Mode? {
- for mode in modes {
- if mode.name == name {
- return mode
- }
- }
- return nil
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement