[0.8.9][NK] Handler, Event, Effect System

johnycilohoklajohnycilohokla REGISTERED Posts: 283 Developer

Effect System

  • EffectsGroups are defined using JSON template file
    (we have decided to go with JSON as it works really well for data driven systems)
  • EffectGroups can use config variables to create more reusable templates
  • EffectGroups should be defined on server side only, they are designed to sync to clients
  • EffectGroups have to be executed on EventExecutorMixin

Event System

  • Events are containers for EffectGroups
  • EventExecutorMixin is used to parse events from txt files

Handler System (Logic Handlers)

  • Handlers drive the logic, control the object, raise events
  • Handlers are dynamic
    • Can be hot swapped
    • Sync to the clients
    • They are not mixed in
  • Handlers can define events the same way objects can (event names have to be unique)
  • Handlers have to be defined when the object is created and will sync to the client
  • To make use of the handler system you will need to mixin HandlerContainerMixin
  • HandlerContainerMixin is depended on the EventExecutorMixin

Creating EffectGroup

local effects = JSON.parseFile(jsonFile)
EffectGroup.new(“name”, effects)

Creating EffectGroup using EffectsManager
EternusEngine.EffectsManager:GetEffectGroup(effectName, jsonFile)

Optionally you can use config variables that will be injected into the template using “@VarName” as the value for the variable you want to define:
{
"type": "EffectGroup",
"name": "ConfigTest",

"effects": [
{
"effectScript": "DebugPrint",
"value": "@VarName",
}
]
}
and defining the EffectGroup now will take a 3rd parameter:
EffectGroup.new(“name”, effects, {VarName = 123})
or
EternusEngine.EffectsManager:GetEffectGroup(effectName, jsonFile,  {VarName = 123})

Creating EffectGroup using EventExecutorMixin

EventExecutorMixin can be used to parse events from txt files
arguments
{
Events
{
OnContact
{
Explode
{
jsonFile = "path_to/effectTemplate.json"
var1 = "var1"
var2 = 2
}
}
}
}

EffectGroup Example

(Game\Core\Data\Effects\Tests\RadiusTest.json)


image
{
"type": "EffectGroup",
"name": "RadiusTest",

"effects": [
{
"effectScript": "HandlerSetLight",
"radius": 10,
"color": {"$": "Vec3D", "x": 1, "y": 1, "z": 1}
"offset": {"$": "Vec3D", "x": 0, "y": 0, "z": 0}
},
{
"effectScript": "RadiusEffect",
"radius": 30,
"callback": [
{
"effectScript": "TargetBuff",
"class": "FireDebuff",
"incorrectTierCap": 2,
"Data": {
"duration": 3
"damage": 5
"ticksPerSecond": 2
"stacks": false
},
"players": true,
"characters": true
},
{
"effectScript": "TargetDamage",
"breakdown": true,
"incorrectTierCap": 2,
"Affects": {
"Rock": 2,
"Ore": 2,
"Metal": 2,
"Wood": 2,
"Vegetation": 2,
"Edible": 2
},
"gameObjectDamage": 100,
"characterDamage": 100
}
]
}
]
}

Events System Example

Events
{
OnSpawn
{
Example
{
jsonFile = "Data/Effects/Example.json"
Test = 123
Test2 = <1,2,3>
Test3
{
Test = 123
Test2 = <1,2,3>
}
}
}
OnContact
{
Explode
{
jsonFile = "Data/Effects/Projectiles/Fireball/OnContact.json"
}
}
}
image

Handler System Example

arguments
{
Handlers
{
Trajectory
{
handlerClass = "HandlerTrajectory"
arguments
{
speed = 40.0
acceleration = <0.0, -15.0, 0.0>
contactProbeLength = 1.3
}
}
Attached
{
handlerClass = "HandlerAttached"
arguments
{
speed = 0.5
offset = <2.0, 0.0, 0.0>
}
}
}
}
image

Full Example (Projectile)

image
My Blog
jc.png
  yt.png  t.png  
Sign In or Register to comment.