File: Torch.py

package info (click to toggle)
cyphesis-cpp 0.5.16-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 5,084 kB
  • ctags: 3,627
  • sloc: cpp: 30,418; python: 4,812; xml: 4,674; sh: 4,118; makefile: 902; ansic: 617
file content (34 lines) | stat: -rw-r--r-- 1,285 bytes parent folder | download
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
#This file is distributed under the terms of the GNU General Public license.
#Copyright (C) 2005 Al Riddoch (See the file COPYING for details).

from atlas import *

from cyphesis.Thing import Thing
from Point3D import Point3D
from BBox import BBox

import server

class Torch(Thing):
    """This is base class for axes, this one just ordinary axe"""
    def ignite_operation(self, op):
        fire_child=None
        for child in self.contains:
            if child.type[0] == 'fire':
                fire_child = child
        if not fire_child:
            return
        to_ = op[0].id
        if not to_:
            return self.error(op,"To is undefined object")
        return Operation("create",Entity(parents=['fire'],status=fire_child.status, location=Location(server.world.get_object(to_),Point3D(0.0,0.0,0.0))),to=to_)
    def burn_operation(self, op):
        fire_status = op[0].status
        to_ = op[0].id
        ret = Message()
        if fire_status < 0.5:
            ret = ret + Operation("nourish", Entity(op[0].id, mass=(0.5 - fire_status)), to=to_)
        fire_loc = Location(self, Point3D(0,0,0.75))
        fire_loc.bbox = BBox(0.05, 0.05, 0.5)
        ret = ret + Operation("move", Entity(to_, location=fire_loc, mode='fixed'), to=to_)
        return ret