User Tools

Site Tools


dragengine:modules:dragonscript:behavior_daytimesky

This is an old revision of the document!


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.

Instance Counts

This behavior can be used only once on an element.

Element Class Properties

Element class properties have the prefix customColor. .

controllerDayTime

Set name of day time controller.

  • Full name: customColor.controllerDayTime
  • Type: string
  • Default Value: daytime
  • Example (*.deeclass)
    <string name='customColor.controllerDayTime'>daytime</string>

dayTime

Set day time as hour of day in the range from 0 to 24.

  • Full name: customColor.dayTime
  • Type: float
  • Default Value: 10
  • Restriction: At least 0 and at most 24
  • Example (*.deeclass)
    <float name='customColor.dayTime'>10.75</float>

Events

This behavior has no events.

Behavior Tree Actions

This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace dayTimeSky with dayTimeSky(id).

dayTimeSky.set

Set one or more day time sky parameters.

ParameterValueDescription
timefloatSet 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>

dayTimeSky.check

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).

ParameterValueDescription
time.lessfloatDay time is less than hour of day
time.greaterfloatDay 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>

Behavior Tree Conditions

This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace dayTimeSky with dayTimeSky(id).

dayTimeSky.check

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.

ParameterValueDescription
dayTimeSky.time.lessfloatDay time is less than hour of day
dayTimeSky.time.greaterfloatDay 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>

Required Behaviors

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable).

API Documentation

ECBehaviorDayTimeSky.

Since DragonScript Module Version 1.0

Use Cases

  • Adjust sky instance parameters using day time as sky controller input.

Element Class Example

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

Behavior Factory

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>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_daytimesky.1746222037.txt.gz · Last modified: 2025/05/02 21:40 by dragonlord