Skip to content

Commit

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

Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
  • Loading branch information
DarkWeird and skaldarnar committed Aug 25, 2021
1 parent 1377300 commit 5bbbc6e
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
/*
* Copyright 2013 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.changingBlocks;

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

import java.util.Map;

@ForceBlockActive
public final class ChangingBlocksComponent implements Component {
public final class ChangingBlocksComponent implements Component<ChangingBlocksComponent> {

// determines if animation loops back to first block after last block is reached
public boolean loops;
Expand All @@ -38,4 +25,13 @@ public final class ChangingBlocksComponent implements Component {
// internal: used to track the last time we checked to see if we needed to change a block
public long lastGameTimeCheck = -1;

@Override
public void copyFrom(ChangingBlocksComponent other) {
this.loops = other.loops;
this.stopped = other.stopped;
this.blockFamilyStages.clear();
other.blockFamilyStages.forEach((k,v) -> this.blockFamilyStages.put(k,v));
this.timeInGameMsToNextStage = other.timeInGameMsToNextStage;
this.lastGameTimeCheck = other.lastGameTimeCheck;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
/*
* Copyright 2019 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.changingBlocks.conditional.components;

import com.google.common.collect.Lists;
import org.terasology.changingBlocks.conditional.BlockCondition;

import java.util.List;

public class ChangeBlockBlockDirectedComponent implements ConditionalBlockChangeComponent {
public class ChangeBlockBlockDirectedComponent implements ConditionalBlockChangeComponent<ChangeBlockBlockDirectedComponent> {
public List<BlockCondition.BlockDirected> changes;

@Override
public void copyFrom(ChangeBlockBlockDirectedComponent other) {
this.changes = Lists.newArrayList(other.changes);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
/*
* Copyright 2019 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.changingBlocks.conditional.components;

import com.google.common.collect.Lists;
import org.terasology.changingBlocks.conditional.BlockCondition;

import java.util.List;

public class ChangeBlockBlockNearbyComponent implements ConditionalBlockChangeComponent {
public class ChangeBlockBlockNearbyComponent implements ConditionalBlockChangeComponent<ChangeBlockBlockNearbyComponent> {
public List<BlockCondition.BlockNearby> changes;

@Override
public void copyFrom(ChangeBlockBlockNearbyComponent other) {
this.changes = Lists.newArrayList(other.changes);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
/*
* Copyright 2019 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.changingBlocks.conditional.components;

import com.google.common.collect.Lists;
import org.terasology.changingBlocks.conditional.BlockCondition;

import java.util.List;

public class ChangeBlockEntityDirectedComponent implements ConditionalBlockChangeComponent {
public class ChangeBlockEntityDirectedComponent implements ConditionalBlockChangeComponent<ChangeBlockEntityDirectedComponent> {
public List<BlockCondition.EntityDirected> changes;

@Override
public void copyFrom(ChangeBlockEntityDirectedComponent other) {
this.changes = Lists.newArrayList(other.changes);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
/*
* Copyright 2019 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.changingBlocks.conditional.components;

import com.google.common.collect.Lists;
import org.terasology.changingBlocks.conditional.BlockCondition;

import java.util.List;

public class ChangeBlockEntityNearbyComponent implements ConditionalBlockChangeComponent {
public class ChangeBlockEntityNearbyComponent implements ConditionalBlockChangeComponent<ChangeBlockEntityNearbyComponent> {
public List<BlockCondition.EntityNearby> changes;

@Override
public void copyFrom(ChangeBlockEntityNearbyComponent other) {
this.changes = Lists.newArrayList(other.changes);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
/*
* Copyright 2019 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.changingBlocks.conditional.components;

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

public interface ConditionalBlockChangeComponent extends Component {
public interface ConditionalBlockChangeComponent<T extends Component<T>> extends Component<T> {
}

0 comments on commit 5bbbc6e

Please sign in to comment.