mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 08:11:54 +08:00
add $SM.setget, refactor Room to better use $SM
game.room.builder >> game.builder.level setget is mainly for use in local copies of states, useful for keeping code cleaner and less redundant while maintaining set/get of states by the $SM ====functions refactored==== Room.unlockForext //remove update calls Room.buy //remove update calls Room.build //remove update calls Room.cooFire //added locals to reduce gets Room.adjustTemp //added locals to reduce gets Room.updateBuilderState //added local to reduce gets Room.craftUnlocked //Room unlock is always going to be true, don't need to check parents to avoid errors anymore Room.buyUnlocked //Room unlock is always going to be true, don't need to check parents to avoid errors anymore
This commit is contained in:
@@ -147,7 +147,7 @@ var StateManager = {
|
||||
//return state, undefined or 0
|
||||
get: function(stateName, requestZero) {
|
||||
var whichState = null;
|
||||
var fullPath = $SM.buildPath(stateName, name);
|
||||
var fullPath = $SM.buildPath(stateName);
|
||||
|
||||
//catch errors if parent of state doesn't exist
|
||||
try{
|
||||
@@ -161,6 +161,13 @@ var StateManager = {
|
||||
else return whichState;
|
||||
},
|
||||
|
||||
//mainly for local copy use, add(M) can fail so we can't shortcut them
|
||||
//since set does not fail, we know state exists and can simply return the object
|
||||
setget: function(stateName, value, noEvent){
|
||||
$SM.set(stateName, value, noEvent);
|
||||
return eval('('+$SM.buildPath(stateName)+')');
|
||||
},
|
||||
|
||||
remove: function(stateName, noEvent) {
|
||||
var whichState = $SM.buildPath(whichState);
|
||||
try{
|
||||
|
||||
Reference in New Issue
Block a user