Skip to content

Commit

Permalink
fix(ecs-gestalt): Migrate Components to gestalt's Components. (#55)
Browse files Browse the repository at this point in the history
Ref: MovingBlocks/Terasology#4753

Co-authored-by: Michael Pollind <mpollind@gmail.com>
Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
  • Loading branch information
3 people committed Aug 25, 2021
1 parent 1b046fc commit 2c8abd9
Show file tree
Hide file tree
Showing 29 changed files with 254 additions and 486 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
/*
* 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.entityNetwork.components;

import org.joml.Vector3i;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.world.block.BlockComponent;
import org.terasology.entityNetwork.BlockLocationNetworkNode;
import org.terasology.entityNetwork.NetworkNode;
import org.terasology.entityNetwork.NetworkNodeBuilder;
import org.terasology.gestalt.entitysystem.component.Component;

public class BlockLocationNetworkNodeComponent implements Component, NetworkNodeBuilder {
public class BlockLocationNetworkNodeComponent implements Component<BlockLocationNetworkNodeComponent>, NetworkNodeBuilder {
public String networkId;
public boolean isLeaf;
public int maximumGridDistance = 1;
Expand All @@ -37,4 +24,11 @@ public NetworkNode build(EntityRef entityRef) {
return null;
}
}

@Override
public void copyFrom(BlockLocationNetworkNodeComponent other) {
this.networkId = other.networkId;
this.isLeaf = other.isLeaf;
this.maximumGridDistance = other.maximumGridDistance;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
/*
* 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.entityNetwork.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class EntityNetworkComponent implements Component {
public class EntityNetworkComponent implements Component<EntityNetworkComponent> {
@Override
public void copyFrom(EntityNetworkComponent other) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.google.common.collect.Sets;
import org.joml.Vector3i;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.math.Direction;
import org.terasology.engine.math.Side;
Expand All @@ -13,11 +12,12 @@
import org.terasology.entityNetwork.NetworkNode;
import org.terasology.entityNetwork.NetworkNodeBuilder;
import org.terasology.entityNetwork.SidedBlockLocationNetworkNode;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.machines.BlockFamilyUtil;

import java.util.Set;

public class SidedBlockLocationNetworkNodeComponent implements Component, NetworkNodeBuilder {
public class SidedBlockLocationNetworkNodeComponent implements Component<SidedBlockLocationNetworkNodeComponent>, NetworkNodeBuilder {
public String networkId;
public boolean isLeaf;
public Set<String> directions = Sets.newHashSet();
Expand All @@ -42,4 +42,12 @@ private byte calculateConnectionSides(BlockComponent block) {
}
return SideBitFlag.getSides(sides);
}

@Override
public void copyFrom(SidedBlockLocationNetworkNodeComponent other) {
this.networkId = other.networkId;
this.isLeaf = other.isLeaf;
this.directions.clear();
this.directions.addAll(other.directions);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
/*
* 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.fluidTransport.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.Owns;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.gestalt.entitysystem.component.Component;

public class FluidDisplayComponent implements Component {
public class FluidDisplayComponent implements Component<FluidDisplayComponent> {
@Owns
public EntityRef renderedEntity;

@Override
public void copyFrom(FluidDisplayComponent other) {

}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
/*
* 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.fluidTransport.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.world.block.ForceBlockActive;
import org.terasology.gestalt.entitysystem.component.Component;

/**
* Marks a block that also has a FluidInventoryComponent as able to exchange fluid with adjacent liquid blocks.
*/
@ForceBlockActive
public class FluidInletOutletComponent implements Component {
public class FluidInletOutletComponent implements Component<FluidInletOutletComponent> {
/** The maximum amount of liquid that can flow into the container, in litres (thousandths of a block) per second. */
public float inletRate;
/** The maximum amount of liquid that can flow from the container, in litres (thousandths of a block) per second. */
public float outletRate;

public float inletVolume;
public float outletVolume;

@Override
public void copyFrom(FluidInletOutletComponent other) {
this.inletRate = other.inletRate;
this.outletRate = other.outletRate;
this.inletVolume = other.inletVolume;
this.outletVolume = other.outletVolume;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +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.fluidTransport.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class FluidPipeComponent implements Component {
public class FluidPipeComponent implements Component<FluidPipeComponent> {
public float maximumFlowRate;

@Override
public void copyFrom(FluidPipeComponent other) {
this.maximumFlowRate = other.maximumFlowRate;
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
/*
* 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.fluidTransport.components;

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 FluidPumpComponent implements Component {
public class FluidPumpComponent implements Component<FluidPumpComponent> {
@Replicate
public float pressure;
public float maximumFlowRate;

@Override
public void copyFrom(FluidPumpComponent other) {
this.pressure = other.pressure;
this.maximumFlowRate = other.maximumFlowRate;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
/*
* 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.fluidTransport.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class FluidTankDisplayComponent implements Component {
public class FluidTankDisplayComponent implements Component<FluidTankDisplayComponent> {
@Override
public void copyFrom(FluidTankDisplayComponent other) {

}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
/*
* 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.fluidTransport.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class FluidTankDropsFluidComponent implements Component {
public class FluidTankDropsFluidComponent implements Component<FluidTankDropsFluidComponent> {
@Override
public void copyFrom(FluidTankDropsFluidComponent other) {

}
}
Original file line number Diff line number Diff line change
@@ -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.fluidTransport.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.world.block.ForceBlockActive;
import org.terasology.entityNetwork.components.BlockLocationNetworkNodeComponent;
import org.terasology.fluidTransport.systems.FluidTransportAuthoritySystem;
import org.terasology.gestalt.entitysystem.component.Component;

@ForceBlockActive
public class FluidTransportBlockNetworkComponent extends BlockLocationNetworkNodeComponent implements Component {
public class FluidTransportBlockNetworkComponent extends BlockLocationNetworkNodeComponent implements Component<BlockLocationNetworkNodeComponent> {
public FluidTransportBlockNetworkComponent() {
this.networkId = FluidTransportAuthoritySystem.NETWORK_ID;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
/*
* 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.fluidTransport.processParts;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;

public class MechanicalPowerToPressureComponent implements Component {
public class MechanicalPowerToPressureComponent implements Component<MechanicalPowerToPressureComponent> {
@Override
public void copyFrom(MechanicalPowerToPressureComponent other) {

}
}
Loading

0 comments on commit 2c8abd9

Please sign in to comment.