Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from piknotech/threepoints
Implement Three Points
- Loading branch information
Showing
45 changed files
with
1,437 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
gnimag/Modules/Base/Common/Sources/Extensions/Array+Sort.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// Created by David Knothe on 15.03.21. | ||
// Copyright © 2019 - 2021 Piknotech. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Array { | ||
@_transparent | ||
public mutating func sort<A>(by key: (Element) -> A, _ smaller: (A, A) -> Bool) { | ||
sort { smaller(key($0), key($1)) } | ||
} | ||
|
||
@_transparent | ||
public mutating func sort<A: Comparable>(by key: (Element) -> A) { | ||
sort(by: key, <) | ||
} | ||
|
||
@_transparent | ||
public func sorted<A>(by key: (Element) -> A, _ smaller: (A, A) -> Bool) -> [Element] { | ||
var result = self | ||
result.sort(by: key, smaller) | ||
return result | ||
} | ||
|
||
@_transparent | ||
public func sorted<A: Comparable>(by key: (Element) -> A) -> [Element] { | ||
sorted(by: key, <) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
gnimag/Modules/Base/GameKit/Sources/Auxiliary/More/OrphanageDetector.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Created by David Knothe on 13.02.20. | ||
// Copyright © 2019 - 2021 Piknotech. All rights reserved. | ||
// | ||
|
||
/// Use OrphanageDetector to detect whether an object is orphaned, i.e. has not been updated recently. | ||
/// This could happen either when such an object leaves the screen or when it was created erroneously. | ||
public class OrphanageDetector { | ||
/// The number of consecutive frames that have not been marked valid via `markAsValid`. | ||
private var consecutiveNumberOfFramesWithoutUpdate = 0 | ||
|
||
/// When `newFrame` is called more than `maxFramesWithoutUpdate` times without a `markAsValid` in the meantime, this object gets marked as orphaned. | ||
private let maxFramesWithoutUpdate: Int | ||
|
||
public var isOrphaned: Bool { | ||
consecutiveNumberOfFramesWithoutUpdate > maxFramesWithoutUpdate | ||
} | ||
|
||
/// Default initializer. | ||
public init(maxFramesWithoutUpdate: Int) { | ||
self.maxFramesWithoutUpdate = maxFramesWithoutUpdate | ||
} | ||
|
||
/// Call at the beginning of each frame. This increases the `consecutiveNumberOfFramesWithoutUpdate` counter. | ||
public func newFrame() { | ||
consecutiveNumberOfFramesWithoutUpdate += 1 | ||
} | ||
|
||
/// Call when the object has been updated and is valid. This resets the `consecutiveNumberOfFramesWithoutUpdate` counter. | ||
public func markAsValid() { | ||
consecutiveNumberOfFramesWithoutUpdate = 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
12 changes: 0 additions & 12 deletions
12
gnimag/Modules/Games/GameTemplate/Sources/GameTemplate.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
...es/Games/MrFlap/Sources/2 GameModelCollection/Trackers/BarTracker+OrphanageDetector.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.