-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
medbay bed is now responsive see issue #6.
- Loading branch information
Showing
8 changed files
with
371 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
|
||
"frameGrid" : { | ||
"size" : [8, 10], | ||
"dimensions" : [4, 4], | ||
"names" : [ | ||
[ "off", "turnOn.1", "turnOn.2", null ], | ||
[ "max.1", "max.2", "max.3", "max.4" ], | ||
[ "med.1", "med.2", "med.3", "med.4" ], | ||
[ "low.1", "low.2", "low.3", "low.4" ] | ||
|
||
] | ||
}, | ||
"aliases" : { | ||
"default" : "off", | ||
"turnOff.1" : "turnOn.2", | ||
"turnOff.2" : "turnOn.1" | ||
} | ||
} |
Loading
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
|
||
"frameGrid" : { | ||
"size" : [30, 10], | ||
"dimensions" : [6, 1], | ||
"names" : [ | ||
[ "off", "on.1", "on.2", "on.3", "on.4", "on.5"] | ||
] | ||
}, | ||
"aliases" : { | ||
"default" : "off", | ||
"on.6" : "on.4", | ||
"on.7" : "on.3", | ||
"on.8" : "on.2" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 178 additions & 0 deletions
178
SMEE/objects/generic/sr1medbaybed/sr1medbaybed.animation
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,178 @@ | ||
{ | ||
"animatedParts" : { | ||
"stateTypes" : { | ||
"responsiveState" : { | ||
"default" : "off", | ||
"states" : { | ||
"off" : { | ||
"frames" : 1, | ||
"cycle" : 0.15 | ||
}, | ||
|
||
"max" : { | ||
"frames" : 4, | ||
"cycle" : 1.0, | ||
"mode" : "loop" | ||
}, | ||
|
||
"med" : { | ||
"frames" : 4, | ||
"cycle" : 1.0, | ||
"mode" : "loop" | ||
}, | ||
|
||
"low" : { | ||
"frames" : 4, | ||
"cycle" : 1.0, | ||
"mode" : "loop" | ||
}, | ||
|
||
"turnOn" : { | ||
"frames" : 2, | ||
"cycle" : 0.5 | ||
}, | ||
|
||
"turnOff" : { | ||
"frames" : 2, | ||
"cycle" : 0.5 | ||
} | ||
} | ||
}, | ||
"scanState" : { | ||
"default" : "off", | ||
"states" : { | ||
"off" : { | ||
"frames" : 1, | ||
"cycle" : 0.15 | ||
}, | ||
|
||
"on" : { | ||
"frames" : 8, | ||
"cycle" : 2.5, | ||
"mode" : "loop" | ||
} | ||
} | ||
} | ||
|
||
}, | ||
|
||
"parts" : { | ||
"sr1medbaybed" : { | ||
"properties" : { | ||
"offset" : [0, 0], | ||
"centered" : false, | ||
"zLevel" : 0, | ||
"back" : true | ||
}, | ||
|
||
"partStates" : { | ||
"responsiveState" : { | ||
"off" : { | ||
"properties" : { | ||
"image" : "<partImage>" | ||
} | ||
}, | ||
|
||
"max" : { | ||
"properties" : { | ||
"image" : "<partImage>" | ||
} | ||
}, | ||
"med" : { | ||
"properties" : { | ||
"image" : "<partImage>" | ||
} | ||
}, | ||
|
||
"low" : { | ||
"properties" : { | ||
"image" : "<partImage>" | ||
} | ||
}, | ||
|
||
"turnOn" : { | ||
"properties" : { | ||
"image" : "<partImage>" | ||
} | ||
}, | ||
|
||
"turnOff" : { | ||
"properties" : { | ||
"image" : "<partImage>" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"healthstatus" : { | ||
"properties" : { | ||
"offset" : [5.4, 1.2], | ||
"centered" : false, | ||
"zLevel" : 1 | ||
}, | ||
|
||
"partStates" : { | ||
"responsiveState" : { | ||
"off" : { | ||
"properties" : { | ||
"image" : "<partImage>:off" | ||
} | ||
}, | ||
|
||
"max" : { | ||
"properties" : { | ||
"image" : "<partImage>:max.<frame>" | ||
} | ||
}, | ||
"med" : { | ||
"properties" : { | ||
"image" : "<partImage>:med.<frame>" | ||
} | ||
}, | ||
|
||
"low" : { | ||
"properties" : { | ||
"image" : "<partImage>:low.<frame>" | ||
} | ||
}, | ||
|
||
"turnOn" : { | ||
"properties" : { | ||
"image" : "<partImage>:turnOn.<frame>" | ||
} | ||
}, | ||
|
||
"turnOff" : { | ||
"properties" : { | ||
"image" : "<partImage>:turnOff.<frame>" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"scanoverlay" : { | ||
"properties" : { | ||
"offset" : [0, 0], // TODO adjust | ||
"centered" : false, | ||
"zLevel" : 2 | ||
}, | ||
|
||
"partStates" : { | ||
"scanState" : { | ||
"off" : { | ||
"properties" : { | ||
"image" : "<partImage>:off" | ||
} | ||
}, | ||
|
||
"on" : { | ||
"properties" : { | ||
"image" : "<partImage>:max.<frame>" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,106 @@ | ||
function init(virtual) | ||
entity.setInteractive(true) | ||
|
||
if not virtual then | ||
responsiveObject.init() | ||
responsiveObject.start() | ||
|
||
self.occupiedBy = nil | ||
end | ||
end | ||
|
||
|
||
function onInteraction(args) | ||
-- scan animation | ||
-- world.logInfo("loungableID: ".. tostring(entity.id()) .. " name: " .. world.entityName(entity.id()) ) | ||
-- TODO loungableOccupied does not work right now wait for a new patch | ||
-- if world.loungableOccupied(entity.id()) then | ||
-- entity.setAnimationStage("scanState", "on") | ||
--else | ||
-- entity.setAnimationStage("scanState", "off") | ||
--end | ||
|
||
local flipDirection = entity.configParameter("sitFlipDirection") | ||
local position = entity.configParameter("sitPosition") | ||
local orientation = entity.configParameter("sitOrientation") | ||
|
||
return { "SitDown", { | ||
sitFlipDirection = flipDirection, | ||
sitPosition = position, | ||
sitOrientation = orientation | ||
}} | ||
end | ||
|
||
function switchHealthState() | ||
|
||
if self.occupiedBy == nil then | ||
return | ||
end | ||
|
||
local h = world.entityHealth(self.occupiedBy) | ||
local p = h[1] / h[2] | ||
|
||
if p > 0.66 then | ||
entity.setAnimationState("responsiveState","max") | ||
elseif p >= 0.33 and p <= 0.66 then | ||
entity.setAnimationState("responsiveState","med") | ||
else | ||
entity.setAnimationState("responsiveState","low") | ||
end | ||
end | ||
|
||
|
||
function main() | ||
|
||
-- first count down timer | ||
if self.timer > 0 then | ||
self.timer = self.timer - 1 | ||
elseif self.timer == 0 then | ||
-- check if timer 0 and an animation switch is needed | ||
self.timer = -1 | ||
|
||
-- transitions | ||
if entity.animationState("responsiveState") == self.anims.transActive.name then | ||
switchHealthState() | ||
elseif entity.animationState("responsiveState") == self.anims.transIdle.name then | ||
responsiveObject.nextAnimation("idle") | ||
else | ||
if responsiveObject.isIdle() and #self.anims.idle > 1 then | ||
responsiveObject.nextAnimation("idle") | ||
elseif #self.anims.active > 1 then | ||
switchHealthState() | ||
end | ||
end | ||
|
||
end | ||
|
||
-- detect player | ||
local entityIds = world.playerQuery( | ||
entity.position(), | ||
self.detectRadius, | ||
{ | ||
inSightOf = entity.id(), | ||
order = "nearest" | ||
} | ||
) | ||
|
||
if responsiveObject.isIdle() then | ||
if #entityIds > 0 then | ||
self.occupiedBy = entityIds[1] | ||
responsiveObject.switchToActive() | ||
end | ||
elseif not responsiveObject.isIdle() then | ||
if #entityIds == 0 then | ||
self.occupiedBy = nil | ||
responsiveObject.switchToIdle() | ||
else | ||
switchHealthState() | ||
end | ||
end | ||
end | ||
|
||
|
||
function die() | ||
responsiveObject.die() | ||
self.occupiedBy = nil | ||
end |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.