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. #12

Merged
merged 2 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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> {
}