Skip to content

Commit

Permalink
mountain grass
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSupremo committed Feb 14, 2018
1 parent cde95a2 commit c2fc083
Show file tree
Hide file tree
Showing 17 changed files with 328 additions and 139 deletions.
31 changes: 31 additions & 0 deletions components/mountain_grass/mountain_grass_component.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- local log = radiant.log.create_logger('MountainGrass')
local MountainGrass = class()
local Point3 = _radiant.csg.Point3
local Cube3 = _radiant.csg.Cube3
local Region3 = _radiant.csg.Region3

function MountainGrass:post_activate()
local json = radiant.entities.get_json(self)
self.radius = json.radius or 8
self.block_type = json.block_type or "grass"
self.priority = json.priority or 10 --less = higher priority

self.timer = stonehearth.calendar:set_timer('replacing rocks with grass', self.priority, function()
local location = radiant.entities.get_world_grid_location(self._entity)
if location and location.y > 50 then
local block_type = radiant.terrain.get_block_types()[self.block_type]
local cube = Cube3(
location + Point3(-self.radius,-1,-self.radius),
location + Point3( self.radius, 0, self.radius)
)
local grass_region = radiant.terrain.intersect_cube(cube)
for cube in grass_region:each_cube() do
radiant.terrain.add_cube(Cube3(cube.min,cube.max,block_type))
end
end
self.timer = nil
self._entity:remove_component('swamp_goblins:mountain_grass')
end)
end

return MountainGrass
34 changes: 23 additions & 11 deletions data/biome/swamp_generation.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"step_count": 2
},
"foothills": {
"step_size": 5,
"step_size": 3,
"step_count": 1
},
"mountains": {
Expand Down Expand Up @@ -105,15 +105,15 @@
"octaves": 4,
"persistence_ratio": 0.2,
"amplitude": 2.5,
"layer_thickness": 1,
"layer_thickness": 2,
"layer_count": 2,
"unit_length": 8
},
"height_function": {
"octaves": 4,
"persistence_ratio": 0.1,
"amplitude": 2.5,
"layer_thickness": 1,
"layer_thickness": 2,
"unit_length": 10
}
},
Expand All @@ -132,6 +132,10 @@
"landscape": {
"has_grass": true,
"placement_table" : {
"swamp_goblins:terrain:mountain_grass" : {
"placement_type" : "single",
"parameters" : { "ground_radius" : 1, "exclusion_radius" : 6 }
},
"swamp_goblins:trees:cypress:small" : {
"placement_type" : "single",
"parameters" : { "ground_radius" : 2, "exclusion_radius" : 3 }
Expand Down Expand Up @@ -174,6 +178,14 @@
"grid_multiple": 4,
"item_density": 0.18,
"exclusion_radius": 1
},
"mountains": {
"placement_type": "dense",
"parameters": {
"grid_multiple": 3,
"item_density": 0.18,
"exclusion_radius": 1
}
}
},
"swamp_goblins:plants:giant_flower": {
Expand Down Expand Up @@ -258,9 +270,7 @@
},
"mountains": {
"1": {
"swamp_goblins:trees:bogger": 1,
"swamp_goblins:trees:cypress": 1,
"swamp_goblins:trees:swirl": 1
"swamp_goblins:trees:cypress": 1
}
}
},
Expand Down Expand Up @@ -291,7 +301,7 @@
},
"mountains": {
"1": {
"mean": -100,
"mean": 0,
"std_dev": 0,
"density": 0
}
Expand Down Expand Up @@ -346,7 +356,9 @@
},
"mountains": {
"1": {
"swamp_goblins:plants:fern": 2,
"swamp_goblins:terrain:mountain_grass": 2,
"swamp_goblins:trees:cypress:small":1,
"swamp_goblins:plants:fern": 1,
"swamp_goblins:plants:mushroom": 1
}
}
Expand All @@ -371,8 +383,8 @@
},
"mountains": {
"1": {
"probability": 0.1,
"density": 0.4
"probability": 0.75,
"density": 0.3
}
}
}
Expand Down Expand Up @@ -400,7 +412,7 @@
},
"mountains": {
"1": {
"probability": 0.1,
"probability": 0.2,
"density": 0.1
}
}
Expand Down
2 changes: 1 addition & 1 deletion data/effects/fog_effect/fog_effect.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
}
}
}
}
}
144 changes: 86 additions & 58 deletions data/horde/particles/firefly/firefly.cubemitter.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,88 @@
{
"name": "firefly",
"duration": 20000,
"particle": {
"lifetime": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [9000, 10000]
}
},
"speed": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [0.4, 0.5]
}
},

"color": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [
[0.4, 0.5, 0.0, 1.0],
[0.0, 0.6, 0.3, 1.0]
]
},
"over_lifetime_a": {
"kind": "CURVE",
"values": [
[0.0, 0.0], [0.02, 1.0], [0.1, 1.0], [0.12, 0.0],
[0.2, 0.0], [0.22, 1.0], [0.3, 1.0], [0.32, 0.0],
[0.4, 0.0], [0.42, 1.0], [0.5, 1.0], [0.52, 0.0],
[0.6, 0.0], [0.62, 1.0], [0.7, 1.0], [0.72, 0.0],
[0.8, 0.0], [0.82, 1.0], [0.9, 1.0], [0.92, 0.0]
]
}
},
"scale": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [0.1, 0.2]
}
},
"velocity": {
}
},
"emission": {
"rate": {
"kind": "CONSTANT",
"values": [3]
},
"origin": {
"surface": "RECTANGLE",
"values": [8, 8]
},
"angle": {
"kind": "RANDOM_BETWEEN",
"values": [0,360]
}
}
"name": "firefly",
"duration": 20000,
"material": "materials/cubemitter.material.json",
"loops": true,
"emission": {
"rate": {
"kind": "CONSTANT",
"values": [3]
},
"angle": {
"kind": "CONSTANT",
"values": [0]
},
"origin": {
"surface": "SPHERE",
"values": [4, 0, 360]
}
},
"particle": {
"lifetime": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [9000, 10000]
}
},
"speed": {
"start": {
"kind": "CONSTANT",
"values": [0]
}
},
"velocity": {
"over_lifetime_x": {
"kind": "RANDOM_BETWEEN",
"values": [-0.3, 0.3]
},
"over_lifetime_y": {
"kind": "RANDOM_BETWEEN",
"values": [-0.3, 0.3]
},
"over_lifetime_z": {
"kind": "RANDOM_BETWEEN",
"values": [-0.3, 0.3]
}
},
"scale": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [0.1, 0.2]
}
},
"color": {
"start": {
"kind": "RANDOM_BETWEEN",
"values": [
[0.4, 0.5, 0, 1],
[0, 0.6, 0.3, 1]
]
},
"over_lifetime_a": {
"kind": "CURVE",
"values": [
[0, 0],
[0.02, 1],
[0.1, 1],
[0.12, 0],
[0.2, 0],
[0.22, 1],
[0.3, 1],
[0.32, 0],
[0.4, 0],
[0.42, 1],
[0.5, 1],
[0.52, 0],
[0.6, 0],
[0.62, 1],
[0.7, 1],
[0.72, 0],
[0.8, 0],
[0.82, 1],
[0.9, 1],
[0.92, 0]
]
}
}
}
}
Loading

0 comments on commit c2fc083

Please sign in to comment.