Skip to content

Commit

Permalink
feat(RegionEntityProvider): allow TreeFacet to be optional [experimen…
Browse files Browse the repository at this point in the history
…tal]
  • Loading branch information
keturn committed Oct 7, 2021
1 parent 0058a6f commit 4ec5c18
Showing 1 changed file with 9 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
/*
* Copyright 2016 MovingBlocks
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.dynamicCities.region;

Expand Down Expand Up @@ -57,18 +44,22 @@ public void process(Region region, EntityBuffer buffer) {
if (checkCorners(worldRegion, elevationFacet)) {
RoughnessFacet roughnessFacet = region.getFacet(RoughnessFacet.class);
ResourceFacet resourceFacet = region.getFacet(ResourceFacet.class);
TreeFacet treeFacet = region.getFacet(TreeFacet.class);
SiteFacet siteFacet = region.getFacet(SiteFacet.class);
SettlementFacet settlementFacet = region.getFacet(SettlementFacet.class);

EntityStore entityStore = new EntityStore();

RoughnessFacetComponent roughnessFacetComponent = new RoughnessFacetComponent(roughnessFacet);
ResourceFacetComponent resourceFacetComponent = new ResourceFacetComponent(resourceFacet);
TreeFacetComponent treeFacetComponent = new TreeFacetComponent(treeFacet);
entityStore.addComponent(roughnessFacetComponent);
entityStore.addComponent(resourceFacetComponent);
entityStore.addComponent(treeFacetComponent);

// FIXME: is TreeFacet optional?
TreeFacet treeFacet = region.getFacet(TreeFacet.class);
if (treeFacet != null) {
TreeFacetComponent treeFacetComponent = new TreeFacetComponent(treeFacet);
entityStore.addComponent(treeFacetComponent);
}

LocationComponent locationComponent = new LocationComponent(worldRegion.center(new Vector3f()));
entityStore.addComponent(locationComponent);
Expand Down

0 comments on commit 4ec5c18

Please sign in to comment.