-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
295 additions
and
44 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
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 @@ | ||
import { ObjectUpdater } from "../../utils/ObjectUpdater"; | ||
import { GameCustomPulseConfig } from "../../types/game"; | ||
|
||
export class CustomPulseConfigUpdater extends ObjectUpdater { | ||
protected registerSchemas(): void { | ||
this.addSchema(0, (obj) => obj, () => { | ||
return { | ||
customPulseList: [], | ||
} as GameCustomPulseConfig; | ||
}); | ||
} | ||
} |
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 @@ | ||
import { ObjectUpdater } from "../../utils/ObjectUpdater"; | ||
import { CoyoteGamePlayConfig } from "../../types/gamePlay"; | ||
|
||
export class GamePlayConfigUpdater extends ObjectUpdater { | ||
protected registerSchemas(): void { | ||
this.addSchema(0, (obj) => obj, () => { | ||
return { | ||
gamePlayList: [], | ||
} as CoyoteGamePlayConfig; | ||
}); | ||
} | ||
} |
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 @@ | ||
import { ObjectUpdater } from "../../utils/ObjectUpdater"; | ||
import { CoyoteGamePlayUserConfig } from "../../types/gamePlay"; | ||
|
||
export class GamePlayUserConfigUpdater extends ObjectUpdater { | ||
protected registerSchemas(): void { | ||
this.addSchema(0, (obj) => obj, () => { | ||
return { | ||
configList: {}, | ||
} as CoyoteGamePlayUserConfig; | ||
}); | ||
} | ||
} |
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,18 @@ | ||
import { DGLabPulseService } from "../../services/DGLabPulse"; | ||
import { MainGameConfig } from "../../types/game"; | ||
import { ObjectUpdater } from "../../utils/ObjectUpdater"; | ||
|
||
export class MainGameConfigUpdater extends ObjectUpdater { | ||
protected registerSchemas(): void { | ||
this.addSchema(0, (obj) => obj, () => { | ||
return { | ||
strengthChangeInterval: [15, 30], | ||
enableBChannel: false, | ||
bChannelStrengthMultiplier: 1, | ||
pulseId: DGLabPulseService.instance.getDefaultPulse().id, | ||
pulseMode: 'single', | ||
pulseChangeInterval: 60, | ||
} as MainGameConfig; | ||
}); | ||
} | ||
} |
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,98 @@ | ||
import { simpleArrayDiff } from "./utils"; | ||
|
||
export class MultipleLinkedMap<K, V> { | ||
private _map = new Map<K, V[]>(); | ||
private _reverseMap = new Map<V, K>(); | ||
|
||
public get map() { | ||
return this._map; | ||
} | ||
|
||
public get reverseMap() { | ||
return this._reverseMap; | ||
} | ||
|
||
public get keysCount() { | ||
return this._map.size; | ||
} | ||
|
||
public get valuesCount() { | ||
return this._reverseMap.size; | ||
} | ||
|
||
public keys() { | ||
return this._map.keys(); | ||
} | ||
|
||
public values() { | ||
return this._reverseMap.keys(); | ||
} | ||
|
||
public getFieldValues(key: K): V[] { | ||
return this._map.get(key) || []; | ||
} | ||
|
||
public getFieldKey(value: V): K | undefined { | ||
return this._reverseMap.get(value); | ||
} | ||
|
||
public addFieldValue(key: K, value: V) { | ||
let values = this._map.get(key); | ||
if (!values) { | ||
values = []; | ||
this._map.set(key, values); | ||
} | ||
values.push(value); | ||
this._reverseMap.set(value, key); | ||
} | ||
|
||
public removeFieldValue(key: K, value: V) { | ||
let values = this._map.get(key); | ||
if (values) { | ||
let index = values.indexOf(value); | ||
if (index !== -1) { | ||
values.splice(index, 1); | ||
if (values.length === 0) { | ||
this._map.delete(key); | ||
} | ||
} | ||
} | ||
this._reverseMap.delete(value); | ||
} | ||
|
||
public setFieldValues(key: K, values: V[]) { | ||
let added = values; | ||
let removed: V[] = []; | ||
|
||
let oldValues = this._map.get(key); | ||
if (oldValues) { | ||
let diffResult = simpleArrayDiff(oldValues, values); | ||
added = diffResult.added; | ||
removed = diffResult.removed; | ||
} | ||
|
||
this._map.set(key, values); | ||
|
||
for (let value of removed) { | ||
this._reverseMap.delete(value); | ||
} | ||
for (let value of added) { | ||
this._reverseMap.set(value, key); | ||
} | ||
} | ||
|
||
public removeField(key: K) { | ||
let values = this._map.get(key); | ||
if (values) { | ||
for (let value of values) { | ||
this._reverseMap.delete(value); | ||
} | ||
} | ||
this._map.delete(key); | ||
} | ||
|
||
public clear() { | ||
this._map.clear(); | ||
this._reverseMap.clear(); | ||
} | ||
} |
Oops, something went wrong.