/usr/lib/python3/dist-packages/morse/robots/victim.py is in python3-morse-simulator 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | import logging; logger = logging.getLogger("morse." + __name__)
import morse.core.robot
from morse.core.services import service
class Victim(morse.core.robot.Robot):
""" Class definition for the pseudo-robot that represents
a human victim. Mainly used for the ROSACE rescue scenario.
Sub class of Morse_Object. """
def __init__(self, obj, parent=None):
""" Constructor method.
Receives the reference to the Blender object.
Optionally it gets the name of the object's parent,
but that information is not currently used for a robot. """
# Call the constructor of the parent class
logger.info('%s initialization' % obj.name)
morse.core.robot.Robot.__init__(self, obj, parent)
if self.bge_object['Injured']:
# Set the mesh color to red
obj.color = [1.0, 0.5, 0.5, 1.0]
else:
# Set the mesh color to red
obj.color = [1.0, 1.0, 1.0, 1.0]
# Convert the 'Requirements' property,
# from a string to a list of integers
obj['Requirements'] = [int(x) for x in obj['Requirements'].split(",")]
logger.info('Component initialized')
@service
def heal(self):
""" Change the status of the victim
Change the material to a green color,
and the status to healed.
"""
if self.bge_object['Severity'] > 0:
self.bge_object['Severity'] -= 1
# Set the colors depending on the severity of the injuries
red = 1 - self.bge_object['Severity'] * 0.05
green = 0.5 + red
self.bge_object.color = [red, green, 0.5, 1.0]
# When fully healed, mark as not injured
if self.bge_object['Severity'] == 0:
self.bge_object['Injured'] = False
def default_action(self):
""" Main function of this component. """
pass
|