Skip to content
Snippets Groups Projects
Commit c70f8ae2 authored by Arkerthan's avatar Arkerthan
Browse files

add currentLimbs()

parent f533fd68
No related branches found
No related tags found
1 merge request!5303rework limb removal/attachment system (ready for review/merge)
App.Desc.limbChange = function() { App.Desc.limbChange = function() {
return { return {
currentState: currentState, currentState: currentState,
currentLimbs: currentLimbs,
amputate: amputate, amputate: amputate,
prosthetic: prosthetic, prosthetic: prosthetic,
selector: selector, selector: selector,
...@@ -40,6 +41,37 @@ App.Desc.limbChange = function() { ...@@ -40,6 +41,37 @@ App.Desc.limbChange = function() {
return a; return a;
} }
/**
* Generates an object usable with the standard limb check functions.
* @param {App.Entity.SlaveState} slave
* @returns {{}}
*/
function currentLimbs(slave) {
let s = {arm: {left: {type: 1}, right: {type: 1}}, leg: {left: {type: 1}, right: {type: 1}}, PLimb: 0};
if (hasLeftArm(slave)) {
s.arm.left.type = getLeftArmID(slave);
} else {
s.arm.left = null;
}
if (hasRightArm(slave)) {
s.arm.right.type = getRightArmID(slave);
} else {
s.arm.right = null;
}
if (hasLeftLeg(slave)) {
s.leg.left.type = getLeftLegID(slave);
} else {
s.leg.left = null;
}
if (hasRightLeg(slave)) {
s.leg.right.type = getRightLegID(slave)
} else {
s.leg.right = null;
}
s.PLimb = slave.PLimb;
return s;
}
/** /**
* @param {App.Entity.SlaveState} slave * @param {App.Entity.SlaveState} slave
* @param {[number]} oldState * @param {[number]} oldState
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment