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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
/*
* Copyright 2017 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.segmentedpaths.components;

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

/**
* Created by michaelpollind on 4/3/17.
*/
public class BlockMappingComponent implements Component {
public class BlockMappingComponent implements Component<BlockMappingComponent> {
public Side s1;
public Side s2;

@Override
public void copyFrom(BlockMappingComponent other) {
this.s1 = other.s1;
this.s2 = other.s2;
}
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
/*
* Copyright 2017 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.segmentedpaths.components;

import org.joml.Vector3f;
import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.reflection.MappedContainer;

import java.util.List;
import java.util.stream.Collectors;

/**
* Created by michaelpollind on 4/3/17.
*/
public class CurvedPathComponent implements Component {
public class CurvedPathComponent implements Component<CurvedPathComponent> {
public List<CurvedPathComponent.CubicBezier> path;
public Vector3f binormal;
public float rotation;

@Override
public void copyFrom(CurvedPathComponent other) {
this.path = other.path.stream()
.map(CubicBezier::copy)
.collect(Collectors.toList());
this.binormal = new Vector3f(other.binormal);
this.rotation = other.rotation;
}

@MappedContainer
public static class CubicBezier {
public Vector3f f1;
public Vector3f f2;
public Vector3f f3;
public Vector3f f4;

private CubicBezier copy() {
CubicBezier newCubicBezier = new CubicBezier();
newCubicBezier.f1 = f1;
newCubicBezier.f2 = f2;
newCubicBezier.f3 = f3;
newCubicBezier.f4 = f4;
return newCubicBezier;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
/*
* Copyright 2017 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.segmentedpaths.components;

import org.joml.Vector3f;
import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.reflection.MappedContainer;

import java.util.List;
import java.util.stream.Collectors;

public class LinearPathComponent implements Component {
public class LinearPathComponent implements Component<LinearPathComponent> {
public List<Linear> path;

@Override
public void copyFrom(LinearPathComponent other) {
this.path = other.path.stream()
.map(Linear::copy)
.collect(Collectors.toList());
}

@MappedContainer
public static class Linear {
public Vector3f point;
public Vector3f binormal;

private Linear copy() {
Linear linear = new Linear();
linear.point = new Vector3f(point);
linear.binormal = new Vector3f(binormal);
return linear;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
/*
* Copyright 2017 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.segmentedpaths.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Lists;
import org.terasology.engine.entitySystem.prefab.Prefab;
import org.terasology.gestalt.entitysystem.component.Component;

import java.util.List;


/**
* Created by michaelpollind on 8/15/16.
*/
public class PathDescriptorComponent implements Component {
public class PathDescriptorComponent implements Component<PathDescriptorComponent> {
public List<Prefab> descriptors;

@Override
public void copyFrom(PathDescriptorComponent other) {
this.descriptors = Lists.newArrayList(other.descriptors);
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
/*
* Copyright 2017 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.segmentedpaths.components;

import org.joml.Vector3f;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.network.Replicate;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.segmentedpaths.SegmentMeta;

/**
* Used to create entities that follow paths.
*/
public class PathFollowerComponent implements Component {
public class PathFollowerComponent implements Component<PathFollowerComponent> {
@Replicate
public SegmentMeta segmentMeta;
@Replicate
public Vector3f heading;

@Override
public void copyFrom(PathFollowerComponent other) {
this.segmentMeta = new SegmentMeta(other.segmentMeta);
this.segmentMeta.sign = other.segmentMeta.sign;
this.heading = new Vector3f(other.heading);
}
}