From efbaed2a1f3cb786d0eff75801e04dd4de796ba4 Mon Sep 17 00:00:00 2001 From: DarkWeird Date: Fri, 9 Jul 2021 16:53:15 +0300 Subject: [PATCH 1/2] fix(ecs-gestalt): Migrate Components to gestalt's Components. --- .../AltarOfResurrectionColliderComponent.java | 21 ++-------- .../AltarOfResurrectionRootComponent.java | 28 +++++-------- .../RevivePlayerComponent.java | 27 +++++------- .../damageplayer/DamagePlayerComponent.java | 27 +++++------- .../FireballLauncherComponent.java | 32 +++++++-------- .../AddFireballLauncherComponent.java | 41 +++++++++++-------- .../mcqButtonDoor/McqButtonDoorComponent.java | 30 ++++++-------- .../passwordDoor/PasswordDoorComponent.java | 28 +++++-------- .../swingingblade/SwingingBladeComponent.java | 32 +++++++-------- .../AddSwingingBladeComponent.java | 40 ++++++++++-------- .../traps/wipeout/WipeOutComponent.java | 32 +++++++-------- .../AddWipeOutComponent.java | 40 ++++++++++-------- 12 files changed, 174 insertions(+), 204 deletions(-) diff --git a/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionColliderComponent.java b/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionColliderComponent.java index 6acfef8..8f622b0 100644 --- a/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionColliderComponent.java +++ b/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionColliderComponent.java @@ -1,26 +1,13 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.altarofresurrection; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.EmptyComponent; /** * This is a marker component that is attached to a the altar of resurrection collider for dealing with the ActivateEvent and * AttackEvent. */ -public class AltarOfResurrectionColliderComponent implements Component { +public class AltarOfResurrectionColliderComponent extends EmptyComponent { } diff --git a/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java b/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java index 5d0205e..94c8c8e 100644 --- a/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java +++ b/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java @@ -1,32 +1,26 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.altarofresurrection; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.world.block.ForceBlockActive; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component is attached to every altar of resurrection root entity. */ @ForceBlockActive -public class AltarOfResurrectionRootComponent implements Component { +public class AltarOfResurrectionRootComponent implements Component { public EntityRef meshEntity; public EntityRef orbEntity; public EntityRef colliderEntity; + + @Override + public void copy(AltarOfResurrectionRootComponent other) { + this.meshEntity = other.meshEntity; + this.orbEntity = other.meshEntity; + this.colliderEntity = other.colliderEntity; + } } diff --git a/src/main/java/org/terasology/adventureassets/altarofresurrection/RevivePlayerComponent.java b/src/main/java/org/terasology/adventureassets/altarofresurrection/RevivePlayerComponent.java index 8269f27..173a1e8 100644 --- a/src/main/java/org/terasology/adventureassets/altarofresurrection/RevivePlayerComponent.java +++ b/src/main/java/org/terasology/adventureassets/altarofresurrection/RevivePlayerComponent.java @@ -1,24 +1,11 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.altarofresurrection; import org.joml.Vector3f; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.network.Replicate; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component makes a player respawn near the altar of resurrection. It is attached to the clientInfo entity which always @@ -26,9 +13,15 @@ * entity even when the player entity is inactive. */ -public class RevivePlayerComponent implements Component { +public class RevivePlayerComponent implements Component { @Replicate public Vector3f location; @Replicate public EntityRef altarOfResurrectionEntity; + + @Override + public void copy(RevivePlayerComponent other) { + this.location = new Vector3f(other.location); + this.altarOfResurrectionEntity = other.altarOfResurrectionEntity; + } } diff --git a/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java b/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java index 8dae509..02e1f5b 100644 --- a/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java +++ b/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java @@ -1,27 +1,20 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.damageplayer; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component marks a rigid body for dealing damage to the player. */ -public class DamagePlayerComponent implements Component { +public class DamagePlayerComponent implements Component { public float damage = 10; public float recoil = 5; + + @Override + public void copy(DamagePlayerComponent other) { + this.damage = other.damage; + this.recoil = other.recoil; + } } diff --git a/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java b/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java index a11acc4..a4949be 100644 --- a/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java @@ -1,31 +1,18 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.fireballlauncher; import org.joml.Vector3f; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.network.Replicate; import org.terasology.engine.world.block.ForceBlockActive; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component holds the data for a Fireball Launcher */ @ForceBlockActive -public class FireballLauncherComponent implements Component { +public class FireballLauncherComponent implements Component { /** * Sets the fireball launcher as active or inactive @@ -69,4 +56,15 @@ public class FireballLauncherComponent implements Component { */ @Replicate public int damageAmount = 20; + + @Override + public void copy(FireballLauncherComponent other) { + this.isFiring = other.isFiring; + this.timePeriod = other.timePeriod; + this.offset = other.offset; + this.lastShotTime = other.lastShotTime; + this.direction = new Vector3f(other.direction); + this.maxDistance = other.maxDistance; + this.damageAmount = other.damageAmount; + } } diff --git a/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/structuretemplateintegration/AddFireballLauncherComponent.java b/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/structuretemplateintegration/AddFireballLauncherComponent.java index e187a4b..c5d2715 100644 --- a/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/structuretemplateintegration/AddFireballLauncherComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/structuretemplateintegration/AddFireballLauncherComponent.java @@ -1,27 +1,15 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.fireballlauncher.structuretemplateintegration; import org.joml.Vector3f; import org.joml.Vector3i; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; import org.terasology.reflection.MappedContainer; import org.terasology.structureTemplates.events.SpawnStructureEvent; import java.util.List; +import java.util.stream.Collectors; /** * This component is intended to be used in structure templates. @@ -29,9 +17,16 @@ * It adds items (incl. block items) to one ore more chests when the entity receives a * {@link SpawnStructureEvent}. */ -public class AddFireballLauncherComponent implements Component { +public class AddFireballLauncherComponent implements Component { public List fireballLaunchersToSpawn; + @Override + public void copy(AddFireballLauncherComponent other) { + this.fireballLaunchersToSpawn = other.fireballLaunchersToSpawn.stream() + .map(FireballLauncherToSpawn::copy) + .collect(Collectors.toList()); + } + @MappedContainer public static class FireballLauncherToSpawn { public Vector3i position; @@ -41,5 +36,17 @@ public static class FireballLauncherToSpawn { public Vector3f direction; public int maxDistance; public int damageAmount; + + FireballLauncherToSpawn copy() { + FireballLauncherToSpawn newFL = new FireballLauncherToSpawn(); + newFL.position = new Vector3i(this.position); + newFL.isFiring = this.isFiring; + newFL.timePeriod = this.timePeriod; + newFL.offset = this.offset; + newFL.direction = new Vector3f(this.direction); + newFL.maxDistance = this.maxDistance; + newFL.damageAmount = this.damageAmount; + return newFL; + } } } diff --git a/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java b/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java index bdba2e2..fd48034 100644 --- a/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java @@ -1,30 +1,18 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.mcqButtonDoor; -import org.terasology.engine.entitySystem.Component; +import com.google.common.collect.Lists; import org.terasology.engine.network.Replicate; import org.terasology.engine.world.block.ForceBlockActive; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.Arrays; import java.util.List; @ForceBlockActive -public class McqButtonDoorComponent implements Component { +public class McqButtonDoorComponent implements Component { @Replicate public String title = "title"; @Replicate @@ -33,4 +21,12 @@ public class McqButtonDoorComponent implements Component { public String password = "password"; @Replicate public List options = Arrays.asList("password", "password1", "password2"); + + @Override + public void copy(McqButtonDoorComponent other) { + this.title = other.title; + this.message = other.message; + this.password = other.password; + this.options = Lists.newArrayList(other.options); + } } diff --git a/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java b/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java index 2348d18..6bc6901 100644 --- a/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java @@ -1,31 +1,25 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.passwordDoor; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.network.Replicate; import org.terasology.engine.world.block.ForceBlockActive; +import org.terasology.gestalt.entitysystem.component.Component; @ForceBlockActive -public class PasswordDoorComponent implements Component { +public class PasswordDoorComponent implements Component { @Replicate public String title = "title"; @Replicate public String message = "message"; @Replicate public String password = "password"; + + @Override + public void copy(PasswordDoorComponent other) { + this.title = other.title; + this.message = other.message; + this.password = other.password; + } } diff --git a/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java b/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java index 606fbb0..5bdd340 100644 --- a/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java @@ -1,26 +1,13 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.swingingblade; import com.google.common.collect.Lists; import org.joml.Quaternionf; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.network.Replicate; import org.terasology.engine.world.block.ForceBlockActive; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; @@ -29,7 +16,7 @@ */ @ForceBlockActive -public class SwingingBladeComponent implements Component { +public class SwingingBladeComponent implements Component { /** * Time taken by the swinging blade to complete one two and fro motion (in seconds) */ @@ -65,4 +52,15 @@ public class SwingingBladeComponent implements Component { @Replicate public List childrenEntities = Lists.newArrayList(); + + @Override + public void copy(SwingingBladeComponent other) { + this.timePeriod = other.timePeriod; + this.amplitude = other.amplitude; + this.offset = other.offset; + this.isSwinging = other.isSwinging; + this.rotation = new Quaternionf(other.rotation); + this.lastAngle = other.lastAngle; + this.childrenEntities = Lists.newArrayList(other.childrenEntities); + } } diff --git a/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java b/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java index 524676b..1dd6a87 100644 --- a/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java @@ -1,27 +1,15 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.swingingblade.structuretemplateintegration; import org.joml.Quaternionf; import org.joml.Vector3i; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; import org.terasology.reflection.MappedContainer; import org.terasology.structureTemplates.events.SpawnStructureEvent; import java.util.List; +import java.util.stream.Collectors; /** * This component is intended to be used in structure templates. @@ -29,9 +17,16 @@ * It adds items (incl. block items) to one ore more chests when the entity receives a * {@link SpawnStructureEvent}. */ -public class AddSwingingBladeComponent implements Component { +public class AddSwingingBladeComponent implements Component { public List swingingBladesToSpawn; + @Override + public void copy(AddSwingingBladeComponent other) { + this.swingingBladesToSpawn = other.swingingBladesToSpawn.stream() + .map(SwingingBladesToSpawn::copy) + .collect(Collectors.toList()); + } + @MappedContainer public static class SwingingBladesToSpawn { public Vector3i position; @@ -40,5 +35,16 @@ public static class SwingingBladesToSpawn { public float amplitude = 3.14f / 6; public float offset = 0f; public boolean isSwinging = true; + + SwingingBladesToSpawn copy() { + SwingingBladesToSpawn newToSpawn = new SwingingBladesToSpawn(); + newToSpawn.position = new Vector3i(this.position); + newToSpawn.rotation = new Quaternionf(this.rotation); + newToSpawn.timePeriod = this.timePeriod; + newToSpawn.amplitude = this.amplitude; + newToSpawn.offset = this.offset; + newToSpawn.isSwinging = this.isSwinging; + return newToSpawn; + } } } diff --git a/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java b/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java index 83a37e9..690bdf8 100644 --- a/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java @@ -1,26 +1,13 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.wipeout; import com.google.common.collect.Lists; import org.joml.Quaternionf; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.network.Replicate; import org.terasology.engine.world.block.ForceBlockActive; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; @@ -29,7 +16,7 @@ */ @ForceBlockActive -public class WipeOutComponent implements Component { +public class WipeOutComponent implements Component { /** * Time taken by the wipe out to complete one circle (in seconds) */ @@ -65,4 +52,15 @@ public class WipeOutComponent implements Component { @Replicate public List childrenEntities = Lists.newArrayList(); + + @Override + public void copy(WipeOutComponent other) { + this.timePeriod = other.timePeriod; + this.offset = other.offset; + this.isRotating = other.isRotating; + this.direction = other.direction; + this.rotation = new Quaternionf(other.rotation); + this.lastAngle = other.lastAngle; + this.childrenEntities = Lists.newArrayList(other.childrenEntities); + } } diff --git a/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java b/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java index d31735c..ea3514b 100644 --- a/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java @@ -1,28 +1,16 @@ -/* - * 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. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.adventureassets.traps.wipeout.structuretemplateintegration; import com.google.common.collect.Lists; import org.joml.Quaternionf; import org.joml.Vector3i; -import org.terasology.engine.entitySystem.Component; +import org.terasology.gestalt.entitysystem.component.Component; import org.terasology.reflection.MappedContainer; import org.terasology.structureTemplates.events.SpawnStructureEvent; import java.util.List; +import java.util.stream.Collectors; /** * This component is intended to be used in structure templates. @@ -30,9 +18,16 @@ * It adds items (incl. block items) to one ore more chests when the entity receives a * {@link SpawnStructureEvent}. */ -public class AddWipeOutComponent implements Component { +public class AddWipeOutComponent implements Component { public List wipeOutsToSpawn = Lists.newArrayList(); + @Override + public void copy(AddWipeOutComponent other) { + this.wipeOutsToSpawn = other.wipeOutsToSpawn.stream() + .map(WipeOutsToSpawn::copy) + .collect(Collectors.toList()); + } + @MappedContainer public static class WipeOutsToSpawn { public Vector3i position; @@ -41,5 +36,16 @@ public static class WipeOutsToSpawn { public int direction = 1; public float offset = 0f; public boolean isRotating = true; + + WipeOutsToSpawn copy() { + WipeOutsToSpawn newWipe = new WipeOutsToSpawn(); + newWipe.position = new Vector3i(this.position); + newWipe.rotation = new Quaternionf(this.rotation); + newWipe.timePeriod = this.timePeriod; + newWipe.direction = this.direction; + newWipe.offset = this.offset; + newWipe.isRotating = this.isRotating; + return newWipe; + } } } From 72d642a3d32698000baea1e64aa6a5f589bd0efc Mon Sep 17 00:00:00 2001 From: Tobias Nett Date: Sat, 14 Aug 2021 12:18:58 +0200 Subject: [PATCH 2/2] chore: rename copy >>> copyFrom (as per MovingBlocks/gestalt#123) --- .../altarofresurrection/AltarOfResurrectionRootComponent.java | 2 +- .../altarofresurrection/RevivePlayerComponent.java | 2 +- .../adventureassets/damageplayer/DamagePlayerComponent.java | 2 +- .../traps/fireballlauncher/FireballLauncherComponent.java | 2 +- .../AddFireballLauncherComponent.java | 2 +- .../traps/mcqButtonDoor/McqButtonDoorComponent.java | 2 +- .../traps/passwordDoor/PasswordDoorComponent.java | 2 +- .../traps/swingingblade/SwingingBladeComponent.java | 2 +- .../structuretemplateintegration/AddSwingingBladeComponent.java | 2 +- .../adventureassets/traps/wipeout/WipeOutComponent.java | 2 +- .../structuretemplateintegration/AddWipeOutComponent.java | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java b/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java index 94c8c8e..8205a12 100644 --- a/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java +++ b/src/main/java/org/terasology/adventureassets/altarofresurrection/AltarOfResurrectionRootComponent.java @@ -18,7 +18,7 @@ public class AltarOfResurrectionRootComponent implements Component { public EntityRef altarOfResurrectionEntity; @Override - public void copy(RevivePlayerComponent other) { + public void copyFrom(RevivePlayerComponent other) { this.location = new Vector3f(other.location); this.altarOfResurrectionEntity = other.altarOfResurrectionEntity; } diff --git a/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java b/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java index 02e1f5b..f09cc9b 100644 --- a/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java +++ b/src/main/java/org/terasology/adventureassets/damageplayer/DamagePlayerComponent.java @@ -13,7 +13,7 @@ public class DamagePlayerComponent implements Component { public float recoil = 5; @Override - public void copy(DamagePlayerComponent other) { + public void copyFrom(DamagePlayerComponent other) { this.damage = other.damage; this.recoil = other.recoil; } diff --git a/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java b/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java index a4949be..8a60a45 100644 --- a/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/fireballlauncher/FireballLauncherComponent.java @@ -58,7 +58,7 @@ public class FireballLauncherComponent implements Component fireballLaunchersToSpawn; @Override - public void copy(AddFireballLauncherComponent other) { + public void copyFrom(AddFireballLauncherComponent other) { this.fireballLaunchersToSpawn = other.fireballLaunchersToSpawn.stream() .map(FireballLauncherToSpawn::copy) .collect(Collectors.toList()); diff --git a/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java b/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java index fd48034..05af9e8 100644 --- a/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/mcqButtonDoor/McqButtonDoorComponent.java @@ -23,7 +23,7 @@ public class McqButtonDoorComponent implements Component public List options = Arrays.asList("password", "password1", "password2"); @Override - public void copy(McqButtonDoorComponent other) { + public void copyFrom(McqButtonDoorComponent other) { this.title = other.title; this.message = other.message; this.password = other.password; diff --git a/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java b/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java index 6bc6901..43859ab 100644 --- a/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/passwordDoor/PasswordDoorComponent.java @@ -17,7 +17,7 @@ public class PasswordDoorComponent implements Component { public String password = "password"; @Override - public void copy(PasswordDoorComponent other) { + public void copyFrom(PasswordDoorComponent other) { this.title = other.title; this.message = other.message; this.password = other.password; diff --git a/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java b/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java index 5bdd340..61b613b 100644 --- a/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/swingingblade/SwingingBladeComponent.java @@ -54,7 +54,7 @@ public class SwingingBladeComponent implements Component public List childrenEntities = Lists.newArrayList(); @Override - public void copy(SwingingBladeComponent other) { + public void copyFrom(SwingingBladeComponent other) { this.timePeriod = other.timePeriod; this.amplitude = other.amplitude; this.offset = other.offset; diff --git a/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java b/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java index 1dd6a87..306a8d4 100644 --- a/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/swingingblade/structuretemplateintegration/AddSwingingBladeComponent.java @@ -21,7 +21,7 @@ public class AddSwingingBladeComponent implements Component swingingBladesToSpawn; @Override - public void copy(AddSwingingBladeComponent other) { + public void copyFrom(AddSwingingBladeComponent other) { this.swingingBladesToSpawn = other.swingingBladesToSpawn.stream() .map(SwingingBladesToSpawn::copy) .collect(Collectors.toList()); diff --git a/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java b/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java index 690bdf8..e4be236 100644 --- a/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/wipeout/WipeOutComponent.java @@ -54,7 +54,7 @@ public class WipeOutComponent implements Component { public List childrenEntities = Lists.newArrayList(); @Override - public void copy(WipeOutComponent other) { + public void copyFrom(WipeOutComponent other) { this.timePeriod = other.timePeriod; this.offset = other.offset; this.isRotating = other.isRotating; diff --git a/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java b/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java index ea3514b..20f3e4d 100644 --- a/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java +++ b/src/main/java/org/terasology/adventureassets/traps/wipeout/structuretemplateintegration/AddWipeOutComponent.java @@ -22,7 +22,7 @@ public class AddWipeOutComponent implements Component { public List wipeOutsToSpawn = Lists.newArrayList(); @Override - public void copy(AddWipeOutComponent other) { + public void copyFrom(AddWipeOutComponent other) { this.wipeOutsToSpawn = other.wipeOutsToSpawn.stream() .map(WipeOutsToSpawn::copy) .collect(Collectors.toList());