Class: RPG::Weather

Inherits:
Object show all
Defined in:
scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb

Overview

Class that display weather

Constant Summary collapse

SunnyTone =

Tone used to simulate the sun weather

Tone.new(90, 50, 0, 40)
INIT_TEXTURE =

Array containing all the texture initializer in the order of the type

%i[init_rain init_rain init_zenith init_sand_storm init_snow init_fog]
UPDATE_METHODS =

Array containing all the weather update methods in the order of the type

%i[update_rain update_rain update_zenith update_sandstorm update_snow update_fog]
SET_TYPE_METHODS =

Methods symbols telling how to set the new type of weather according to the index

[]
SET_TYPE_PSDK_MANAGED =

Boolean telling if the set_type is managed by PSDK or not

[]
MAX_SPRITE =

Number of sprite to generate

61
MAX_TOP =

Top factor of the max= adjustment (max * top / bottom)

3
MAX_BOTTOM =

Bottom factor of the max= adjustment (max * top / bottom)

2

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(viewport = nil) ⇒ Weather

Note:

: type 0 = None, 1 = Rain, 2 = Sun/Zenith, 3 = Darud Sandstorm, 4 = Hail, 5 = Foggy

Create the Weather object

Parameters:

  • viewport (Viewport) (defaults to: nil)


35
36
37
38
39
40
41
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 35

def initialize(viewport = nil)
  @type = 0
  @max = 0
  @ox = 0
  @oy = 0
  init_sprites(viewport)
end

Instance Attribute Details

#maxInteger

Return the max amount of sprites

Returns:

  • (Integer)


25
26
27
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 25

def max
  @max
end

#oxNumeric

Return the origin x

Returns:

  • (Numeric)


28
29
30
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 28

def ox
  @ox
end

#oyNumeric

Return the origin y

Returns:

  • (Numeric)


31
32
33
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 31

def oy
  @oy
end

#typeInteger

Return the weather type

Returns:

  • (Integer)


22
23
24
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 22

def type
  @type
end

Class Method Details

.register_set_type(type, symbol, psdk_managed)

Register a new type= method call

Parameters:

  • type (Integer)

    the type of weather

  • symbol (Symbol)

    if the name of the method to call

  • psdk_managed (Boolean)

    if it's managed by PSDK (some specific code in the type= method)



325
326
327
328
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 325

def register_set_type(type, symbol, psdk_managed)
  SET_TYPE_METHODS[type] = symbol
  SET_TYPE_PSDK_MANAGED[type] = psdk_managed
end

Instance Method Details

#dispose

Dispose the interface



50
51
52
53
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 50

def dispose
  @sprites.each(&:dispose)
  @snow_bitmap&.dispose if SET_TYPE_PSDK_MANAGED[4]
end

#update

Update the sprite display



44
45
46
47
# File 'scripts/00000 Dependencies/00500 Patch_RPG/00300 RPG__Weather.rb', line 44

def update
  return if @type == 0
  send(UPDATE_METHODS[@type])
end