def __init__(self): try: log('MyBob.__init__', self.engineObj) self.count = 0 self.SetActorTickEnabled(True) except: logTB()
def Tick(self, dt): self.Update(dt) cur = self.arm.GetRelativeRotation() cur.roll += 1 self.arm.SetRelativeRotation(cur) if time.time() > self.created+5: log('DESTROYING', self) self.Destroy()
def BeginPlay(self): self.SuperBeginPlay() log('HackyWorldHookActor.BeginPlay')
def DoSomething(self, i): try: log('Do something!', self, i) self.SetActorRotation(FRotator(RR(0,360), RR(0,360), RR(0,360))) except: logTB()
def OnSelectionChanged(self, *args, **kwargs): log('ON SELCH', self, args, kwargs)
def HandleBeginPlay(self): log('MyGameState.HandleBeginPlay')
def Init(self): log('MyGameInstance.Init') # I think either InitializePlayInEditor or InitializeStandalone are called *before* this one
def OnHomerDead(self, sentry, reason): log('AAAAAAAAAAAAAAAAAA homer has died', sentry, reason)
def OverrideGameModeClass(self, *args): log('MyGameInstance.OverrideGameModeClass')
def __init__(self, engineObj): self.engineObj = engineObj log('MyGameInstance.__init__')
def StartGameInstance(self): log('MyGameInstance.StartGameInstance') # I think this is called in a packaged game, while StartPlayInEditorGameInstance is called in PIE (and it should just call StartGameInstance)
def Shutdown(self): log('MyGameInstance.Shutdown')
def OnStart(self): log('MyGameInstance.OnStart') # "Called when the game instance is started either normally or through PIE." - called after Init
def SomeAPI(self): log('MyBob.SomeAPI ya\'ll!!!')
def Init(): '''called from ue4 when this module is loaded on startup (or, in dev, when the c++ game module is recompiled''' log('main.Init called')
def B2(): for a in uepy.UGameplayStatics.GetAllActorsOfClass(uepy.GetWorld(), MyBob): a = uepy.ABobActor.Cast(a) log('A:', a) #, a.engineObj) a.SomeAPI()
def OnPreBeginPIE(): log('main.OnPreBeginPIE called') global myactors myactors = reload(myactors)
def Construct(self, vboxRoot): log('editor_spawner.SpawnerTab.Construct:', vboxRoot) vboxRoot = umg.UVerticalBox.Cast(vboxRoot) margin = uepy.FMargin(5, 5, 5, 5) # Row: combo box of class names + refresh button hb = umg.UHorizontalBox.Cast( umg.CreateWidget(vboxRoot, umg.UHorizontalBox, 'hb')) slot = umg.UVerticalBoxSlot.Cast(vboxRoot.AddChild(hb)) slot.SetPadding(margin) self.comboBox = umg.UComboBoxString.Cast( umg.CreateWidget(hb, umg.UComboBoxString, 'comboBox')) self.comboBox.SetFontSize(11) umg.UHorizontalBoxSlot.Cast(hb.AddChild( self.comboBox)).SetPadding(margin) self.RepopulateClassList() self.comboBox.BindOnSelectionChanged(self.OnSelectionChanged) spawnButton = umg.UButton.Cast( umg.CreateWidget(hb, umg.UButton, 'spawnButton')) umg.UHorizontalBoxSlot.Cast( hb.AddChild(spawnButton)).SetPadding(margin) label = umg.UTextBlock.Cast( umg.CreateWidget(spawnButton, umg.UTextBlock, 'textblock')) label.SetText('Spawn') label.SetFontSize(11) spawnButton.SetContent(label) spawnButton.BindOnClicked(self.OnSpawnClicked) refreshButton = umg.UButton.Cast( umg.CreateWidget(hb, umg.UButton, 'refreshButton')) umg.UHorizontalBoxSlot.Cast( hb.AddChild(refreshButton)).SetPadding(margin) label = umg.UTextBlock.Cast( umg.CreateWidget(refreshButton, umg.UTextBlock, 'textblock')) label.SetText('Refresh') label.SetFontSize(11) refreshButton.SetContent(label) refreshButton.BindOnClicked(self.OnRefreshClicked) if 0: # Row: checkbox (delete old instances) + text hb = umg.UHorizontalBox.Cast( umg.CreateWidget(vboxRoot, umg.UHorizontalBox, 'hb2')) slot = umg.UVerticalBoxSlot.Cast(vboxRoot.AddChild(hb)) slot.SetPadding(margin) self.locationCheckbox = umg.UCheckBox.Cast( umg.CreateWidget(hb, umg.UCheckBox, 'checkbox')) umg.UHorizontalBoxSlot.Cast(hb.AddChild( self.locationCheckbox)).SetPadding(margin) self.locationCheckbox.SetIsChecked(True) self.hackCheck = self.locationCheckbox.BindOnCheckStateChanged( self.OnCheckStateChanged) label = umg.UTextBlock.Cast( umg.CreateWidget(hb, umg.UTextBlock, 'label')) slot = umg.UHorizontalBoxSlot.Cast(hb.AddChild(label)) slot.SetVerticalAlignment(uepy.enums.EVerticalAlignment.Center) slot.SetPadding(margin) label.SetText('Delete old instances before spawning') else: # msg telling them to use sourcewatcher hb = umg.UHorizontalBox.Cast( umg.CreateWidget(vboxRoot, umg.UHorizontalBox, 'hb2')) slot = umg.UVerticalBoxSlot.Cast(vboxRoot.AddChild(hb)) label.SetFontSize(11) slot.SetPadding(margin) label = umg.UTextBlock.Cast( umg.CreateWidget(hb, umg.UTextBlock, 'label')) label.SetFontSize(11) slot = umg.UHorizontalBoxSlot.Cast(hb.AddChild(label)) slot.SetVerticalAlignment(uepy.enums.EVerticalAlignment.Center) slot.SetPadding(margin) label.SetText( 'Instead of using this spawner, ask dave about using sourcewatcher!' )
log('HackyWorldHookActor.BeginPlay') def Tick(self, dt): self.watcher.Check() def Boom(): for a in uepy.UGameplayStatics.GetAllActorsOfClass(uepy.GetWorld(), MySO): p = uepy.PyInst(a) p.angle = p.angleTarget = 0 class ABobActor_PGLUE(uepy.AActor_PGLUE): def SomeAPI(self): self.engineObj.SomeAPI() uepy.CPROPS(ABobActor_PGLUE ,'bpProp', 'cProp') bases = [b for b in ABobActor_PGLUE.__bases__ if b != object] log('BOB PGLUE:', type(ABobActor_PGLUE) is uepy.PyGlueMetaclass, bases) class MyBob(ABobActor_PGLUE): def __init__(self): try: log('MyBob.__init__', self.engineObj) self.count = 0 self.SetActorTickEnabled(True) except: logTB() def Tick(self, dt): self.count += 1 #if not self.count % 100: # log('TICKING', self.count, self.bpProp, self.cProp)
def OnCheckStateChanged(self, *args, **kwargs): log('ON CHECK', self, args, kwargs)
def __init__(self, engineObj): self.engineObj = engineObj log('MyGameState.__init__')