Skip to content

Lightweight Maybe<T> for wurst primitives, using tuples for underlying storage

Notifications You must be signed in to change notification settings

Cokemonkey11/WurstMaybePrimitives

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maybe (aka Option) types for wurst, using tuples for storage.

Features:

  • support for vec2, vec3, and angle (as well as the expected primitives)
  • map/flat_map between supported types
  • constructors that infer presence based on nullity

Example:

import Abilities
import ClosureTimers
import GameTimer

import WurstMaybePrimitives


constant DUMMY = createUnit(players[0], 'hfoo', ZERO2, angle(0.))

/**
    Asynchronous.  Adds an effect on the provided unit, in its facing direction.
    If the unit is `null`, then a global dummy is instead utilised, and the
    angle is chosen randomly. If the provided effect is null, holy bolt is used.
*/
function expressiveEffect(unit onWho, string fx)
    let u = maybe_unit(onWho).or_else(DUMMY)
    let ang = maybe_unit(onWho)
        .map(u -> u.getFacingAngle())
        .get_or_else(() -> angle(getElapsedGameTime()))
    let path = maybe_string(fx).get_or(Abilities.holyBoltMissile)

    doPeriodicallyCounted(ANIMATION_PERIOD, 30) _cb ->
        flashEffect(path, u.getPos().polarOffset(64., ang))

Contributing - how to render:

./render.sh

About

Lightweight Maybe<T> for wurst primitives, using tuples for underlying storage

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published