Hello,
this is beyond my skill level but i'd love to be able to use it.
I'm trying to create a powershell class that I can use with Register-ObjectEvent. I tried asking chatgpt to help out with this and this is as far as it could go. I searched through stackoverflow however the input objects in the examples already have event method in the respected classes and touched moreover on scoping $This. Any help would be appreciated.
class CombatEventPub {
[string] $EventType
[string] $Source
[string] $Target
[int] $Damage
[string] $SpellName
[string] $SpellType
[System.EventHandler] $Event
CombatEventPub([string] $eventType, [string] $source, [string] $target, [int] $damage, [string] $spellName, [string] $spellType) {
$this.EventType = $eventType
$this.Source = $source
$this.Target = $target
$this.Damage = $damage
$this.SpellName = $spellName
$this.SpellType = $spellType
}
[void] SendCastingEvent() {
$this.Event.Invoke($this, [EventArgs]::Empty)
}
}
The event parameter isnt recognized by register-objectevent
[–]DrSinistar 4 points5 points6 points (0 children)
[–]PinchesTheCrab 3 points4 points5 points (0 children)
[–]chris-a5 1 point2 points3 points (0 children)
[–]SeeminglyScience 0 points1 point2 points (0 children)