Skip to content

Commit

Permalink
feat(JOML): cleanup and migrate to joml (#48)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobias Nett <[email protected]>
  • Loading branch information
pollend and skaldarnar authored Jan 2, 2021
1 parent 124fb73 commit 4eda17e
Show file tree
Hide file tree
Showing 15 changed files with 1,304 additions and 1,312 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
/*
* Copyright 2017 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.
*/
package org.terasology.scenario.components.regions;

import org.terasology.entitySystem.Component;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.math.geom.Vector3i;
import org.terasology.network.FieldReplicateType;
import org.terasology.network.Replicate;
import org.terasology.scenario.components.ScenarioComponent;

/**
* Creation component for a Scenario argument entity, indicates that this region is currently being created
*
* Scenario region entities are detailed in {@link ScenarioComponent}
*/
public class RegionBeingCreatedComponent implements Component {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public Vector3i firstHit;

@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public EntityRef creatingEntity;
}
/*
* Copyright 2017 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.
*/
package org.terasology.scenario.components.regions;

import org.joml.Vector3i;
import org.terasology.entitySystem.Component;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.network.FieldReplicateType;
import org.terasology.network.Replicate;
import org.terasology.scenario.components.ScenarioComponent;

/**
* Creation component for a Scenario argument entity, indicates that this region is currently being created
*
* Scenario region entities are detailed in {@link ScenarioComponent}
*/
public class RegionBeingCreatedComponent implements Component {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public Vector3i firstHit;

@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public EntityRef creatingEntity;
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
/*
* Copyright 2017 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.
*/
package org.terasology.scenario.components.regions;

import org.terasology.entitySystem.Component;
import org.terasology.math.Region3i;
import org.terasology.network.FieldReplicateType;
import org.terasology.network.Replicate;
import org.terasology.scenario.components.ScenarioComponent;
import org.terasology.scenario.internal.systems.RegionSystem;
import org.terasology.structureTemplates.components.ProtectedRegionsComponent;

/**
* Creation component for a Scenario argument entity, contains the actual Region3i of the region
*
* Scenario region entities are detailed in {@link ScenarioComponent}
*/
public class RegionLocationComponent implements Component {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public Region3i region;
}
/*
* Copyright 2017 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.
*/
package org.terasology.scenario.components.regions;

import org.terasology.entitySystem.Component;
import org.terasology.network.FieldReplicateType;
import org.terasology.network.Replicate;
import org.terasology.scenario.components.ScenarioComponent;
import org.terasology.world.block.BlockRegion;

/**
* Creation component for a Scenario argument entity, contains the actual Region3i of the region
*
* Scenario region entities are detailed in {@link ScenarioComponent}
*/
public class RegionLocationComponent implements Component {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public BlockRegion region;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.terasology.scenario.internal.systems;

import org.joml.Vector3f;
import org.slf4j.LoggerFactory;
import org.terasology.assets.management.AssetManager;
import org.terasology.entitySystem.entity.EntityManager;
Expand All @@ -27,19 +28,18 @@
import org.terasology.logic.characters.CharacterTeleportEvent;
import org.terasology.logic.chat.ChatMessageEvent;
import org.terasology.logic.common.DisplayNameComponent;
import org.terasology.logic.health.EngineDamageTypes;
import org.terasology.logic.health.event.DoDamageEvent;
import org.terasology.logic.health.event.DoRestoreEvent;
import org.terasology.logic.health.EngineDamageTypes;
import org.terasology.logic.inventory.InventoryComponent;
import org.terasology.logic.inventory.InventoryManager;
import org.terasology.logic.inventory.ItemComponent;
import org.terasology.logic.inventory.events.GiveItemEvent;
import org.terasology.math.JomlUtil;
import org.terasology.math.geom.Vector3f;
import org.terasology.network.ClientComponent;
import org.terasology.network.ColorComponent;
import org.terasology.registry.In;
import org.terasology.nui.Color;
import org.terasology.registry.In;
import org.terasology.scenario.components.ScenarioArgumentContainerComponent;
import org.terasology.scenario.components.actions.ScenarioSecondaryDamageAmountComponent;
import org.terasology.scenario.components.actions.ScenarioSecondaryGiveBlockComponent;
Expand Down Expand Up @@ -186,9 +186,9 @@ public void onEventTriggerEvent(EventTriggerEvent event, EntityRef entity, Scena

EvaluateRegionEvent regionEvaluateEvent = new EvaluateRegionEvent(event.informationEntity);
variables.get("region1").send(regionEvaluateEvent);
Vector3f location = regionEvaluateEvent.getResult().getComponent(RegionLocationComponent.class).region.center();
Vector3f location = regionEvaluateEvent.getResult().getComponent(RegionLocationComponent.class).region.center(new Vector3f());

CharacterTeleportEvent teleportEvent = new CharacterTeleportEvent(JomlUtil.from(location));
CharacterTeleportEvent teleportEvent = new CharacterTeleportEvent(location);

ScenarioValuePlayerComponent.PlayerType playerType = variables.get("player").getComponent(ScenarioValuePlayerComponent.class).type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.terasology.scenario.internal.systems.ComponentEvaluation;

import org.joml.Vector3f;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.terasology.entitySystem.entity.EntityRef;
Expand All @@ -28,7 +29,6 @@
import org.terasology.logic.inventory.InventoryComponent;
import org.terasology.logic.inventory.ItemComponent;
import org.terasology.logic.location.LocationComponent;
import org.terasology.math.geom.Vector3f;
import org.terasology.network.ClientComponent;
import org.terasology.nui.FontColor;
import org.terasology.registry.In;
Expand Down Expand Up @@ -226,9 +226,9 @@ public void onEvaluatePlayerRegionComparison(ConditionalCheckEvent event, Entity
EntityRef player = event.getPassedEntity().getComponent(InfoTriggeringEntityComponent.class).entity.getOwner().getComponent(ClientComponent.class).character;
RegionLocationComponent regionComp = region.getComponent(RegionLocationComponent.class);

Vector3f loc = player.getComponent(LocationComponent.class).getWorldPosition();
Vector3f loc = player.getComponent(LocationComponent.class).getWorldPosition(new Vector3f());

event.setResult(regionComp.region.encompasses((int)loc.x, (int)loc.y, (int)loc.z));
event.setResult(regionComp.region.contains((int) loc.x, (int) loc.y, (int) loc.z));
}

@ReceiveEvent
Expand Down
Loading

0 comments on commit 4eda17e

Please sign in to comment.