def try_grow_puddle(self): if self._puddle_size == PuddleSize.LargePuddle: return if self._puddle_size == PuddleSize.MediumPuddle: puddle = create_puddle(PuddleSize.LargePuddle, puddle_liquid=self._puddle_liquid) else: puddle = create_puddle(PuddleSize.MediumPuddle, puddle_liquid=self._puddle_liquid) if puddle.place_puddle(self, 1, ids_to_ignore=[self.id]): if self._evaporate_alarm_handle is not None: alarms.cancel_alarm(self._evaporate_alarm_handle) self.fade_and_destroy() return puddle
def try_create_puddle(self, *args): count = 0 removals = [] for puddle in self._puddle_refs: dist = routing_utils.estimate_distance(self.owner, puddle) if dist > self.max_distance: removals.append(puddle) else: count += puddle.size_count puddle.start_evaporation() for puddle in removals: self._puddle_refs.remove(puddle) if count >= self.max_num_puddles: return False for puddle in tuple(self._puddle_refs): if puddle.in_use: return False new_puddle = puddle.try_grow_puddle() if new_puddle is not None: self._puddle_refs.discard(puddle) self._puddle_refs.add(new_puddle) return True puddle = create_puddle(PuddleSize.SmallPuddle, puddle_liquid=self.puddle_liquid) if puddle.place_puddle(self.owner, self.max_distance): self._puddle_refs.add(puddle) return True return False
def try_create_puddle(self, *args): count = 0 removals = [] for puddle in self._puddle_refs: dist = routing_utils.estimate_distance(self.owner, puddle) if dist > self.max_distance: removals.append(puddle) else: count += puddle.size_count puddle.start_evaporation() for puddle in removals: self._puddle_refs.remove(puddle) if count >= self.max_num_puddles: return False for puddle in self._puddle_refs: if puddle.in_use: return False new_puddle = puddle.try_grow_puddle() while new_puddle is not None: self._puddle_refs.remove(puddle) self._puddle_refs.add(new_puddle) return True puddle = create_puddle(PuddleSize.SmallPuddle, puddle_liquid=self.puddle_liquid) if puddle.place_puddle(self.owner, self.max_distance): self._puddle_refs.add(puddle) return True return False
def create_puddle_from_factory(self, puddle_factory): value = sims4.random.weighted_random_item([ (puddle_factory.none, PuddleSize.NoPuddle), (puddle_factory.small, PuddleSize.SmallPuddle), (puddle_factory.medium, PuddleSize.MediumPuddle), (puddle_factory.large, PuddleSize.LargePuddle) ]) return create_puddle(value, puddle_factory.liquid)
def try_grow_puddle(self): if self.puddle_size == PuddleSize.LargePuddle: return resolver = SingleObjectResolver(self) chance = self.puddle_grow_chance.get_multiplier(resolver) if random.random() > chance: return else: if self.puddle_size == PuddleSize.MediumPuddle: puddle = create_puddle(PuddleSize.LargePuddle, puddle_liquid=self.puddle_liquid) else: puddle = create_puddle(PuddleSize.MediumPuddle, puddle_liquid=self.puddle_liquid) if puddle.place_puddle(self, 1, ids_to_ignore=[self.id]): if self._evaporate_callback_handle is not None: self.commodity_tracker.remove_listener(self._evaporate_callback_handle) self.destroy(self, cause='Puddle is growing.', fade_duration=ClientObjectMixin.FADE_DURATION) return puddle
def create_puddle(game_object_target, puddle_liquid, puddle_size, max_distance=8): puddle = create_puddle(puddle_size, puddle_liquid) if puddle: TurboObjectUtil.Puddle.place_puddle(puddle, game_object_target, max_distance=max_distance) return False
def puddle_create(count: int = 1, size: PuddleSize = PuddleSize.MediumPuddle, liquid=PuddleLiquid.WATER, obj: OptionalTargetParam = None, _connection=None): obj = get_optional_target(obj, _connection) if obj is None: return False for _ in range(count): puddle = create_puddle(size, liquid) if puddle is None: return False puddle.place_puddle(obj, max_distance=8) return True
def create_puddle_from_factory(self, puddle_factory): value = sims4.random.weighted_random_item([(puddle_factory.none, PuddleSize.NoPuddle), (puddle_factory.small, PuddleSize.SmallPuddle), (puddle_factory.medium, PuddleSize.MediumPuddle), (puddle_factory.large, PuddleSize.LargePuddle)]) return create_puddle(value, puddle_factory.liquid)