-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ecs-gestalt): Migrate Components to gestalt's Components. (#19)
Ref: MovingBlocks/Terasology#4753 Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
- Loading branch information
1 parent
9041b13
commit 558cbd7
Showing
5 changed files
with
74 additions
and
85 deletions.
There are no files selected for viewing
27 changes: 10 additions & 17 deletions
27
src/main/java/org/terasology/segmentedpaths/components/BlockMappingComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
40 changes: 23 additions & 17 deletions
40
src/main/java/org/terasology/segmentedpaths/components/CurvedPathComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
37 changes: 20 additions & 17 deletions
37
src/main/java/org/terasology/segmentedpaths/components/LinearPathComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
27 changes: 10 additions & 17 deletions
27
src/main/java/org/terasology/segmentedpaths/components/PathDescriptorComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
28 changes: 11 additions & 17 deletions
28
src/main/java/org/terasology/segmentedpaths/components/PathFollowerComponent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |