forked from SilverStudioGames/WTS
Coroutines
* Implemented asynchronous coroutines for Doll and Outfit generators
This commit is contained in:
parent
dd4b2898e0
commit
c32d926742
File diff suppressed because it is too large
Load Diff
@ -43,30 +43,53 @@ init python:
|
||||
if self in self.char.outfits:
|
||||
self.char.outfits.remove(self)
|
||||
|
||||
def build_image(self):
|
||||
masks = []
|
||||
def make_image(self):
|
||||
asyncio.run(self.build_image())
|
||||
|
||||
async def build_image(self):
|
||||
# Add body, face, cum, clothes, masks
|
||||
|
||||
async def build_clothes(group):
|
||||
sprites = []
|
||||
masks = []
|
||||
|
||||
for i in group:
|
||||
sprites.append([i.get_image(), i.zorder])
|
||||
|
||||
sprites.extend([
|
||||
(i.get_image(), i.zorder),
|
||||
i.get_back(),
|
||||
i.get_front(),
|
||||
i.get_armfix(mannequin=True),
|
||||
])
|
||||
|
||||
if i.mask:
|
||||
masks.append((i.mask, i.zorder-1))
|
||||
|
||||
return (sprites, masks)
|
||||
|
||||
async def build_mannequin(group):
|
||||
return (self.char.body.get_mannequin(group), 0)
|
||||
|
||||
mannequin, (clothes, masks) = await asyncio.gather(
|
||||
build_mannequin(self.group),
|
||||
build_clothes(self.group),
|
||||
)
|
||||
|
||||
sprites = [
|
||||
(self.char.body.get_mannequin(self.group), 0)
|
||||
mannequin,
|
||||
*clothes,
|
||||
]
|
||||
|
||||
for i in self.group:
|
||||
sprites.append([i.get_image(), i.zorder])
|
||||
|
||||
sprites.extend([
|
||||
(i.get_image(), i.zorder),
|
||||
i.get_back(),
|
||||
i.get_front(),
|
||||
i.get_armfix(mannequin=True),
|
||||
])
|
||||
|
||||
if i.mask:
|
||||
masks.append((i.mask, i.zorder-1))
|
||||
# Filter out Nulls
|
||||
sprites = [x for x in sprites if not isinstance(x[0], Null)]
|
||||
|
||||
sprites.sort(key=itemgetter(1))
|
||||
masks.sort(key=itemgetter(1))
|
||||
|
||||
back_sprites = [x for x in sprites if x[1] < 0]
|
||||
sprites = [x for x in sprites if x[1] >= 0]
|
||||
# Filter out sprites with zorder less than zero, there's no need to iterate over them.
|
||||
back_sprites = [x[0] for x in sprites if x[1] < 0]
|
||||
sprites = [x for x in sprites if x[1] > -1]
|
||||
|
||||
# Apply alpha mask
|
||||
for m in masks:
|
||||
@ -84,8 +107,9 @@ init python:
|
||||
sprites.insert(0, (masked, mask_zorder))
|
||||
break
|
||||
|
||||
sprites = back_sprites + sprites
|
||||
return tuple(x[0] for x in sprites)
|
||||
sprites = back_sprites + [x[0] for x in sprites]
|
||||
self.sprite = DollDisplayable(Fixed(*sprites, fit_first=True))
|
||||
return
|
||||
|
||||
def exists(self):
|
||||
return (self in self.char.outfits)
|
||||
|
Loading…
Reference in New Issue
Block a user