def placeStarterGarden(self, avatar):
     items = []
     if avatar.getGardenStarted():
         return
     avId = avatar.getDoId()
     houseIndex = self.toons.index(avId)
     plots = GardenGlobals.estatePlots[houseIndex]
     boxes = GardenGlobals.estateBoxes[houseIndex]
     for i in xrange(len(boxes)):
         items.append([2, i, 0, 0, 0])
         box = DistributedGardenBoxAI(self.air)
         box.setPlot(i)
         box.setOwnerIndex(houseIndex)
         box.setTypeIndex(boxes[i][3])
         box.setPosition(boxes[i][0], boxes[i][1], 20)
         box.setHeading(boxes[i][2])
         box.generateWithRequired(self.zoneId)
     for i in xrange(len(plots)):
         items.append([1, i, 0, 0, 0])
         plot = DistributedGardenPlotAI(self.air)
         plot.setPlot(i)
         plot.setOwnerIndex(houseIndex)
         if plots[i][3] != GardenGlobals.FLOWER_TYPE:
             plot.setPosition(plots[i][0], plots[i][1], 20)
             plot.setHeading(plots[i][2])
         plot.generateWithRequired(self.zoneId)
     self.items[houseIndex] = items
     self.updateItems()
     avatar.b_setGardenStarted(1)
    def generate(self):
        DistributedObjectAI.generate(self)

        # Gone fishin'
        self.pond = DistributedFishingPondAI(simbase.air)
        self.pond.setArea(ToontownGlobals.MyEstate)
        self.pond.generateWithRequired(self.zoneId)

        for i in range(FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
            target = DistributedFishingTargetAI(self.air)
            target.setPondDoId(self.pond.getDoId())
            target.generateWithRequired(self.zoneId)
            self.targets.append(target)

        for i in xrange(6):
            avItems = self.items[i]
            for item in avItems:
                type, hardPoint, waterLevel, growthLevel, optional = item
                if type == 2: # broken for now, rip
                    boxes = GardenGlobals.estateBoxes[i]
                    box = DistributedGardenBoxAI(self.air)
                    box.setPlot(i)
                    box.setOwnerIndex(i)
                    box.setTypeIndex(boxes[hardPoint][3])
                    box.setPosition(boxes[hardPoint][0], boxes[hardPoint][1], 20)
                    box.setHeading(boxes[hardPoint][2])
                    box.generateWithRequired(self.zoneId)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        # Let's place some popsicles
        self.createTreasurePlanner()
Example #3
0
    def create(self, estateMgr):
        self.estateMgr = estateMgr
        if self.avId not in estateMgr.toons:
            estateMgr.notify.warning('Garden associated to unknown avatar %d, deleting...' % self.avId)
            return False
        houseIndex = estateMgr.toons.index(self.avId)
        houseType = estateMgr.houses[houseIndex].houseType
        if self.WANT_FLOWERS:
            boxIndex = 0
            boxes = []
            boxDefs = GardenGlobals.estateBoxes[houseType]
            for x, y, h, boxType in boxDefs:
                box = DistributedGardenBoxAI(self)
                box.setTypeIndex(boxType)
                box.setPos(x, y, 0)
                box.setH(h)
                box.setOwnerIndex(houseIndex)
                box.generateWithRequired(estateMgr.zoneId)
                self.objects.add(box)
                boxes.append(box)
                boxIndex += 1

            self._boxes = boxes
        plots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        flowerIndex = 0
        for plot, (x, y, h, type) in enumerate(plots):
            if type == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                data = self.data['trees'][treeIndex]
                planted, waterLevel, lastCheck, growthLevel, lastHarvested = data
                if planted != -1:
                    obj = self.plantTree(treeIndex, planted, waterLevel=waterLevel, lastCheck=lastCheck, growthLevel=growthLevel, lastHarvested=lastHarvested, generate=False)
                    self.trees.add(obj)
                else:
                    obj = self.placePlot(treeIndex)
                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)
                treeIndex += 1
            elif type == GardenGlobals.FLOWER_TYPE and self.WANT_FLOWERS:
                data = self.data['flowers'][flowerIndex]
                planted, waterLevel, lastCheck, growthLevel, variety = data
                if planted != -1:
                    obj = self.plantFlower(flowerIndex, planted, variety, waterLevel=waterLevel, lastCheck=lastCheck, growthLevel=growthLevel, generate=False)
                else:
                    obj = self.placePlot(flowerIndex)
                    obj.flowerIndex = flowerIndex
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)
                index = (0, 1, 2, 2, 2, 3, 3, 3, 4, 4)[flowerIndex]
                idx = (0, 0, 0, 1, 2, 0, 1, 2, 0, 1)[flowerIndex]
                obj.sendUpdate('setBoxDoId', [boxes[index].doId, idx])
                flowerIndex += 1
            elif type == GardenGlobals.STATUARY_TYPE and self.WANT_STATUARY:
                data = self.data['statuary']
                if data == 0:
                    obj = self.placePlot(-1)
                else:
                    obj = self.placeStatuary(data, generate=False)
                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(plot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estateMgr.zoneId)

        for tree in self.trees:
            tree.calcDependencies()

        self.reconsiderAvatarOrganicBonus()
        return True
Example #4
0
    def load(self, estate):
        self.estate = estate
        if self.avId not in estate.activeToons:
            self.notify.warning(
                'Garden associated with unknown avatar %d, deleting...' %
                self.avId)
            return False

        houseIndex = estate.activeToons.index(self.avId)
        if self.WANT_FLOWERS:
            estateBoxIndex = 0
            estateBoxes = []
            estateBoxData = GardenGlobals.estateBoxes[houseIndex]
            for x, y, h, estateBoxType in estateBoxData:
                gardenBox = DistributedGardenBoxAI(self)
                gardenBox.setTypeIndex(estateBoxType)
                gardenBox.setPos(x, y, 0)
                gardenBox.setH(h)
                gardenBox.setOwnerIndex(houseIndex)
                gardenBox.generateWithRequired(estate.zoneId)
                self.objects.add(gardenBox)
                estateBoxes.append(gardenBox)
                estateBoxIndex += 1

            self._estateBoxes = estateBoxes

        estatePlots = GardenGlobals.estatePlots[houseIndex]
        treeIndex = 0
        flowerIndex = 0
        for estatePlot, (x, y, h, estatePlotType) in enumerate(estatePlots):
            if estatePlotType == GardenGlobals.GAG_TREE_TYPE and self.WANT_TREES:
                data = self.data['trees'][treeIndex]
                planted, waterLevel, lastCheck, growthLevel, lastHarvested = data
                if planted != -1:
                    obj = self.plantTree(treeIndex,
                                         planted,
                                         waterLevel=waterLevel,
                                         lastCheck=lastCheck,
                                         growthLevel=growthLevel,
                                         lastHarvested=lastHarvested,
                                         generate=False)
                    self.trees.add(obj)
                else:
                    obj = self.placePlot(treeIndex)

                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(estatePlot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estate.zoneId)
                treeIndex += 1
            elif estatePlotType == GardenGlobals.FLOWER_TYPE and self.WANT_FLOWERS:
                data = self.data['flowers'][flowerIndex]
                planted, waterLevel, lastCheck, growthLevel, variety = data
                if planted != -1:
                    obj = self.plantFlower(flowerIndex,
                                           planted,
                                           variety,
                                           waterLevel=waterLevel,
                                           lastCheck=lastCheck,
                                           growthLevel=growthLevel,
                                           generate=False)
                    zOffset = 1.5
                else:
                    obj = self.placePlot(flowerIndex)
                    obj.setFlowerIndex(flowerIndex)
                    zOffset = 1.2

                obj.setPlot(estatePlot)
                obj.setOwnerIndex(houseIndex)

                # <hack>
                index = (0, 1, 2, 2, 2, 3, 3, 3, 4, 4)[flowerIndex]
                idx = (0, 0, 0, 1, 2, 0, 1, 2, 0, 1)[flowerIndex]
                gardenBox = self._estateBoxes[index]
                xOffset = FLOWER_X_OFFSETS[gardenBox.getTypeIndex()][idx]
                obj.setPos(gardenBox, 0, 0, 0)
                obj.setZ(gardenBox, zOffset)
                obj.setX(gardenBox, xOffset)
                obj.setH(gardenBox, 0)
                # </hack>

                obj.generateWithRequired(estate.zoneId)
                flowerIndex += 1
            elif estatePlotType == GardenGlobals.STATUARY_TYPE and self.WANT_STATUARY:
                data = self.data['statuary']
                if data == 0:
                    obj = self.placePlot(-1)
                else:
                    obj = self.placeStatuary(data, generate=False)

                obj.setPos(x, y, 0)
                obj.setH(h)
                obj.setPlot(estatePlot)
                obj.setOwnerIndex(houseIndex)
                obj.generateWithRequired(estate.zoneId)

        for tree in self.trees:
            tree.calcDependencies()

        self.reconsiderAvatarOrganicBonus()
        return True
Example #5
0
 def placeStarterGarden(self, avatar):
     items = []
     if avatar.getGardenStarted():
         return
     avId = avatar.getDoId()
     houseIndex = self.toons.index(avId)
     plots = GardenGlobals.estatePlots[houseIndex]
     boxes = GardenGlobals.estateBoxes[houseIndex]
     for i in xrange(len(boxes)):
         items.append([2, i, 0, 0, 0])
         box = DistributedGardenBoxAI(self.air)
         box.setPlot(i)
         box.setOwnerIndex(houseIndex)
         box.setTypeIndex(boxes[i][3])
         box.setPosition(boxes[i][0], boxes[i][1], 20)
         box.setHeading(boxes[i][2])
         box.generateWithRequired(self.zoneId)
     for i in xrange(len(plots)):
         items.append([1, i, 0, 0, 0])
         plot = DistributedGardenPlotAI(self.air)
         plot.setPlot(i)
         plot.setOwnerIndex(houseIndex)
         if plots[i][3] != GardenGlobals.FLOWER_TYPE:
             plot.setPosition(plots[i][0], plots[i][1], 20)
             plot.setHeading(plots[i][2])
         plot.generateWithRequired(self.zoneId)
     self.items[houseIndex] = items
     self.updateItems()
     avatar.b_setGardenStarted(1)
Example #6
0
    def generate(self):
        DistributedObjectAI.generate(self)

        # Gone fishin'
        self.pond = DistributedFishingPondAI(simbase.air)
        self.pond.setArea(ToontownGlobals.MyEstate)
        self.pond.generateWithRequired(self.zoneId)

        for i in range(
                FishingTargetGlobals.getNumTargets(ToontownGlobals.MyEstate)):
            target = DistributedFishingTargetAI(self.air)
            target.setPondDoId(self.pond.getDoId())
            target.generateWithRequired(self.zoneId)
            self.targets.append(target)

        for i in xrange(6):
            avItems = self.items[i]
            for item in avItems:
                type, hardPoint, waterLevel, growthLevel, optional = item
                if type == 2:  # broken for now, rip
                    boxes = GardenGlobals.estateBoxes[i]
                    box = DistributedGardenBoxAI(self.air)
                    box.setPlot(i)
                    box.setOwnerIndex(i)
                    box.setTypeIndex(boxes[hardPoint][3])
                    box.setPosition(boxes[hardPoint][0], boxes[hardPoint][1],
                                    20)
                    box.setHeading(boxes[hardPoint][2])
                    box.generateWithRequired(self.zoneId)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(49.1029, -124.805, 0.344704, 90, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(46.5222, -134.739, 0.390713, 75, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(41.31, -144.559, 0.375978, 45, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        spot = DistributedFishingSpotAI(self.air)
        spot.setPondDoId(self.pond.getDoId())
        spot.setPosHpr(46.8254, -113.682, 0.46015, 135, 0, 0)
        spot.generateWithRequired(self.zoneId)
        self.spots.append(spot)

        # Let's place some popsicles
        self.createTreasurePlanner()