diff --git a/src/main/java/org/terasology/fluid/component/FluidComponent.java b/src/main/java/org/terasology/fluid/component/FluidComponent.java index fa06637..fdd478e 100644 --- a/src/main/java/org/terasology/fluid/component/FluidComponent.java +++ b/src/main/java/org/terasology/fluid/component/FluidComponent.java @@ -1,27 +1,14 @@ -/* - * Copyright 2014 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.fluid.component; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.network.Replicate; +import org.terasology.gestalt.entitysystem.component.Component; /** * This component indicates that an entity is a fluid, and contains basic attributes of the fluid. */ -public class FluidComponent implements Component { +public class FluidComponent implements Component { /** The type of the fluid */ @Replicate public String fluidType; @@ -29,4 +16,10 @@ public class FluidComponent implements Component { /** The volume of the fluid */ @Replicate public float volume; + + @Override + public void copyFrom(FluidComponent other) { + this.fluidType = other.fluidType; + this.volume = other.volume; + } } diff --git a/src/main/java/org/terasology/fluid/component/FluidContainerItemComponent.java b/src/main/java/org/terasology/fluid/component/FluidContainerItemComponent.java index c3549db..26c455a 100644 --- a/src/main/java/org/terasology/fluid/component/FluidContainerItemComponent.java +++ b/src/main/java/org/terasology/fluid/component/FluidContainerItemComponent.java @@ -1,30 +1,17 @@ -/* - * Copyright 2015 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.fluid.component; import org.joml.Vector2f; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.network.Replicate; import org.terasology.engine.rendering.assets.texture.TextureRegionAsset; +import org.terasology.gestalt.entitysystem.component.Component; import org.terasology.module.inventory.components.ItemDifferentiating; /** * This component indicates that an entity is a container capable of holding fluids. */ -public class FluidContainerItemComponent implements Component, ItemDifferentiating { +public class FluidContainerItemComponent implements Component, ItemDifferentiating { /** The type of the fluid it can contain */ @Replicate @@ -86,4 +73,15 @@ public boolean equals(Object o) { return true; } + + @Override + public void copyFrom(FluidContainerItemComponent other) { + this.fluidType = other.fluidType; + this.volume = other.volume; + this.maxVolume = other.maxVolume; + this.fluidMinPerc = new Vector2f(other.fluidMinPerc); + this.fluidSizePerc = new Vector2f(other.fluidSizePerc); + this.textureWithHole = other.textureWithHole; + this.emptyTexture = other.emptyTexture; + } } diff --git a/src/main/java/org/terasology/fluid/component/FluidInventoryAccessComponent.java b/src/main/java/org/terasology/fluid/component/FluidInventoryAccessComponent.java index 9deb894..6078a90 100644 --- a/src/main/java/org/terasology/fluid/component/FluidInventoryAccessComponent.java +++ b/src/main/java/org/terasology/fluid/component/FluidInventoryAccessComponent.java @@ -1,29 +1,28 @@ -/* - * Copyright 2015 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.fluid.component; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.math.IntegerRange; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.Map; /** * A component for integration with a Computer module. */ -public class FluidInventoryAccessComponent implements Component { +public class FluidInventoryAccessComponent implements Component { public Map input; public Map output; + + @Override + public void copyFrom(FluidInventoryAccessComponent other) { + this.input.clear(); + for (Map.Entry entry : other.input.entrySet()) { + this.input.put(entry.getKey(), entry.getValue().copy()); + } + this.output.clear(); + for (Map.Entry entry : other.output.entrySet()) { + this.output.put(entry.getKey(), entry.getValue().copy()); + } + } } diff --git a/src/main/java/org/terasology/fluid/component/FluidInventoryComponent.java b/src/main/java/org/terasology/fluid/component/FluidInventoryComponent.java index f149cd4..5cc9138 100644 --- a/src/main/java/org/terasology/fluid/component/FluidInventoryComponent.java +++ b/src/main/java/org/terasology/fluid/component/FluidInventoryComponent.java @@ -1,32 +1,19 @@ -/* - * Copyright 2014 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.fluid.component; import com.google.common.collect.Lists; -import org.terasology.engine.entitySystem.Component; import org.terasology.engine.entitySystem.Owns; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.network.Replicate; +import org.terasology.gestalt.entitysystem.component.Component; import java.util.List; /** * Represents the fluid inventory of an entity which the entity uses to store fluids. */ -public class FluidInventoryComponent implements Component { +public class FluidInventoryComponent implements Component { /** A list of fluid slots which fluids can occupy */ @Replicate @@ -55,4 +42,10 @@ public FluidInventoryComponent(int numSlots, float maximumVolume) { maximumVolumes.add(maximumVolume); } } + + @Override + public void copyFrom(FluidInventoryComponent other) { + this.fluidSlots = Lists.newLinkedList(this.fluidSlots); + this.maximumVolumes = Lists.newLinkedList(maximumVolumes); + } }