Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ecs-gestalt): Migrate Components to gestalt's Components. #35

Merged
merged 2 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 10 additions & 17 deletions src/main/java/org/terasology/fluid/component/FluidComponent.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
/*
* 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<FluidComponent> {
/** The type of the fluid */
@Replicate
public String fluidType;

/** The volume of the fluid */
@Replicate
public float volume;

@Override
public void copy(FluidComponent other) {
this.fluidType = other.fluidType;
this.volume = other.volume;
}
}
Original file line number Diff line number Diff line change
@@ -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<FluidContainerItemComponent>, ItemDifferentiating {

/** The type of the fluid it can contain */
@Replicate
Expand Down Expand Up @@ -86,4 +73,15 @@ public boolean equals(Object o) {

return true;
}

@Override
public void copy(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;
}
}
Original file line number Diff line number Diff line change
@@ -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<FluidInventoryAccessComponent> {
public Map<String, IntegerRange> input;
public Map<String, IntegerRange> output;

@Override
public void copy(FluidInventoryAccessComponent other) {
this.input.clear();
for (Map.Entry<String, IntegerRange> entry : other.input.entrySet()) {
this.input.put(entry.getKey(), entry.getValue().copy());
}
this.output.clear();
for (Map.Entry<String, IntegerRange> entry : other.output.entrySet()) {
this.output.put(entry.getKey(), entry.getValue().copy());
}
}
}
Original file line number Diff line number Diff line change
@@ -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<FluidInventoryComponent> {

/** A list of fluid slots which fluids can occupy */
@Replicate
Expand Down Expand Up @@ -55,4 +42,10 @@ public FluidInventoryComponent(int numSlots, float maximumVolume) {
maximumVolumes.add(maximumVolume);
}
}

@Override
public void copy(FluidInventoryComponent other) {
this.fluidSlots = Lists.newLinkedList(this.fluidSlots);
this.maximumVolumes = Lists.newLinkedList(maximumVolumes);
}
}