This is an old revision of the document!
Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorDayTimeSky
Behavior element behavior adding day time sky support.
Updates day time controller of a day time supporting sky assigned to ECBehaviorSky. To use add ECBehaviorSky and ECBehaviorDayTimeSky to behavior element then call setDayTime() to adjust the day time to show.
This behavior can be used only once on an element.
Element class properties have the prefix customColor.
.
Set name of day time controller.
customColor.controllerDayTime
daytime
<string name='customColor.controllerDayTime'>daytime</string>
Set day time as hour of day in the range from 0 to 24.
customColor.dayTime
10
0
and at most 24
<float name='customColor.dayTime'>10.75</float>
This behavior has no events.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace dayTimeSky
with dayTimeSky(id)
.
Set one or more day time sky parameters.
Parameter | Value | Description |
---|---|---|
time | float | Set day time as hour of day |
This is an example of using this action:
<action name='dayTimeSky.set'> <parameter name='time'>8.5</parameter> </action>
Check one or more day time sky parameters. Action succeeds if all parameter value matches their respective day time sky parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a day time sky parameter matches (or not).
Parameter | Value | Description |
---|---|---|
time.less | float | Day time is less than hour of day |
time.greater | float | Day time is greater than hour of day |
This is an example of using this action:
<sequence> <action name='dayTimeSky.check'> <parameter name='time.less'>6.5</parameter> </action> <!-- actions here run only if day time is before 6h30 in the morning --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace dayTimeSky
with dayTimeSky(id)
.
Check one or more day time sky parameters. Conditions returns true if all parameter value match their respective day time sky parameter. This condition is typically used to run an action or sequence of actions as long as day time sky conditions are true.
Parameter | Value | Description |
---|---|---|
dayTimeSky.time.less | float | Day time is less than hour of day |
dayTimeSky.time.greater | float | Day time is greater than hour of day |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='dayTimeSky.time.less'>6.5</parameter> <condition>dayTimeSky.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends no state machine events.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element which uses daytime driven sky.
class MyElement extends BehaviorElementClass public var ECBehaviorSky sky public var ECBehaviorDayTimeSky dayTimeSky func new() sky = ECBehaviorSky.new(this) dayTimeSky = ECBehaviorDayTimeSky.new(this, sky) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorSky'/> <behavior type='ECBehaviorDayTimeSky'> <!-- optional: use behavior tree with id instead of empty string --> <string name='behaviorTree'>second</string> <!-- optional: use state machine with id instead of empty string --> <string name='stateMachine'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.controllerDayTime'>daytime</string> </behavior> </elementClass>