def plantTree(self,
                  treeIndex,
                  value,
                  plot=None,
                  waterLevel=-1,
                  lastCheck=0,
                  growthLevel=0,
                  lastHarvested=0,
                  ownerIndex=-1,
                  plotId=-1,
                  pos=None,
                  generate=True):
        if not self.air:
            return

        if plot:
            if plot not in self.objects:
                return

            plot.requestDelete()
            self.objects.remove(plot)

        tree = DistributedGagTreeAI(self)

        tree.setTypeIndex(value)
        tree.setWaterLevel(waterLevel)
        tree.setGrowthLevel(growthLevel)
        if ownerIndex != -1:
            tree.setOwnerIndex(ownerIndex)

        if plotId != -1:
            tree.setPlot(plotId)

        if pos is not None:
            pos, h = pos
            tree.setPos(pos)
            tree.setH(h)

        tree.treeIndex = treeIndex
        tree.calculate(lastHarvested, lastCheck)
        self.trees.add(tree)

        if generate:
            tree.generateWithRequired(self.estateMgr.zoneId)

        return tree
Ejemplo n.º 2
0
    def create(self, estateMgr):
        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning(
                "Garden associated to unknown avatar %d, deleting..." %
                self.avId)
            print estateMgr.toons
            return False

        houseIndex = estateMgr.toons.index(self.avId)

        if self.WANT_FLOWERS:
            boxDefs = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(estateMgr.air)

                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)

                self.objects.append(box)

        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        for x, y, h, type in plots:
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                planted, waterLevel, nextLevelDecrease, growthLevel, nextGrowth = self.treesData[
                    treeIndex]
                if planted:
                    treeIndex += 1
                    tree = DistributedGagTreeAI(estateMgr.air)
                    tree.setPos(x, y, 0)
                    tree.setH(h)
                    tree.setOwnerIndex(houseIndex)
                    tree.setWaterLevel(waterLevel)
                    tree.setGrowthLevel(growthLevel)
                    tree.calculate(nextGrowth, nextLevelDecrease)
                    tree.generateWithRequired(estateMgr.zoneId)

                    self.trees.append(tree)
 def plantTree(self, treeIndex, value, plot=None, waterLevel=-1,
               lastCheck=0, growthLevel=0, lastHarvested=0,
               ownerIndex=-1, plotId=-1, pos=None, generate=True):
     if not self.air:
         return           
             
     if plot:
         if plot not in self.objects:
             return
             
         plot.requestDelete()
         self.objects.remove(plot)
         
     tree = DistributedGagTreeAI(self)
                 
     tree.setTypeIndex(value)
     tree.setWaterLevel(waterLevel)
     tree.setGrowthLevel(growthLevel)
     if ownerIndex != -1:
         tree.setOwnerIndex(ownerIndex)
         
     if plotId != -1:
         tree.setPlot(plotId)
         
     if pos is not None:
         pos, h = pos
         tree.setPos(pos)
         tree.setH(h)
         
     tree.treeIndex = treeIndex
     tree.calculate(lastHarvested, lastCheck)
     self.trees.add(tree)
     
     if generate:
         tree.generateWithRequired(self.estateMgr.zoneId)
         
     return tree
    def create(self, estateMgr):
        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning("Garden associated to unknown avatar %d, deleting..." % self.avId)
            print estateMgr.toons
            return False
        
        houseIndex = estateMgr.toons.index(self.avId)

        if self.WANT_FLOWERS:
            boxDefs = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(estateMgr.air)
            
                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)
            
                self.objects.append(box)
                
        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        for x, y, h, type in plots:
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                planted, waterLevel, nextLevelDecrease, growthLevel, nextGrowth = self.treesData[treeIndex]
                if planted:
                    treeIndex += 1
                    tree = DistributedGagTreeAI(estateMgr.air)
                    tree.setPos(x, y, 0)
                    tree.setH(h)
                    tree.setOwnerIndex(houseIndex)
                    tree.setWaterLevel(waterLevel)
                    tree.setGrowthLevel(growthLevel)
                    tree.calculate(nextGrowth, nextLevelDecrease)
                    tree.generateWithRequired(estateMgr.zoneId)
                
                    self.trees.append(tree)