this.AIChibiDecorators = this.AIChibiDecorators || {}; (function() { "use strict"; // DECORATORS ================================================================= var MaxTimeRunning = function(seconds, child) { this.initialize(seconds, child); } MaxTimeRunning.prototype = new AIDecorator; MaxTimeRunning.prototype.Decorator_initialize = MaxTimeRunning.prototype.initialize; MaxTimeRunning.prototype.initialize = function(seconds, child) { this.Decorator_initialize(); this.child = child; this.seconds = seconds; } MaxTimeRunning.prototype.name = 'AIChibiDecorators_MaxTimeRunning'; MaxTimeRunning.prototype.update = function(target, fdelta) { var seconds = this.getNodeVariable(target, 'seconds'); if (seconds === undefined) { seconds = this.seconds; } seconds -= fdelta; if (seconds <= 0) { this.setNodeVariable(target, 'seconds', undefined); return AIFAILURE; } else { this.setNodeVariable(target, 'seconds', seconds); var status = this.child._update(target, fdelta); if (status != AISUCCESS) { this.setNodeVariable(target, 'seconds', undefined); } return status; } } // ============================================================================ // DECORATORS ================================================================= var Inverter = function(seconds, child) { this.initialize(seconds, child); } Inverter.prototype = new AIDecorator; Inverter.prototype.name = 'AIChibiDecorators_Inverter'; Inverter.prototype.update = function(target, fdelta) { var status = this.child._update(target, fdelta); if (status == AISUCCESS) { return AIFAILURE; } else if (status == AIFAILURE) { return AISUCCESS; } else { return status; } } // ============================================================================ window.AIChibiDecorators.MaxTimeRunning = MaxTimeRunning; window.AIChibiDecorators.Inverter = Inverter; }());