Skip to content

Commit

Permalink
fix(ecs-gestalt): Migrate Components to gestalt's Components. (#68)
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 7dd1972 commit abfccce
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 171 deletions.
26 changes: 9 additions & 17 deletions src/main/java/org/terasology/gooeysQuests/GooeyComponent.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
/*
* Copyright 2016 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.gooeysQuests;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.network.FieldReplicateType;
import org.terasology.engine.network.Replicate;
import org.terasology.gestalt.entitysystem.component.Component;

/**
* Used to find the character "Gooey".
*/
public class GooeyComponent implements Component {
public class GooeyComponent implements Component<GooeyComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public EntityRef offeredQuest = EntityRef.NULL;

@Override
public void copyFrom(GooeyComponent other) {
this.offeredQuest = other.offeredQuest;
}
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
/*
* Copyright 2016 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.gooeysQuests;

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

/**
* Destroys this entity when a player collides with the current entity and spawns the specified prefab.
*/
public class SpawnPrefabOnPlayerCollisionComponent implements Component {
public class SpawnPrefabOnPlayerCollisionComponent implements Component<SpawnPrefabOnPlayerCollisionComponent> {

public Prefab prefab;

@Override
public void copyFrom(SpawnPrefabOnPlayerCollisionComponent other) {
this.prefab = other.prefab;
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
/*
* Copyright 2016 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.gooeysQuests.api;

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

/**
* Marks an entity to be a quest offered by gooey.
Expand All @@ -29,10 +16,17 @@
* preperation, it sends a {@link QuestReadyEvent} to the quest entitiy.
*
*/
public class GooeysQuestComponent implements Component {
public class GooeysQuestComponent implements Component<GooeysQuestComponent> {
public String greetingText = "Hi";
public String startButtonText = "Start Quest";
public String description="Up for a quest?\n\n"
+ "Sadly I have no further description for you.\n\n"
+ "However be warned: Starting a quest can result in possibly unwanted world modifications!";

@Override
public void copyFrom(GooeysQuestComponent other) {
this.greetingText = other.greetingText;
this.startButtonText = other.startButtonText;
this.description = other.description;
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
/*
* Copyright 2016 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.gooeysQuests.api;

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

import java.util.List;

Expand All @@ -29,13 +16,18 @@
* to the component. The {@link CreateStartQuestsEvent} event can be consumed to prevent the creation of the default
* quests.
*/
public class PersonalQuestsComponent implements Component {
public class PersonalQuestsComponent implements Component<PersonalQuestsComponent> {

/**
* Quests that are currently being prepared. Once the preperation is done, gooey will offer the quest to the player.
*/
public List<EntityRef> questsInPreperation = Lists.newArrayList();

@Override
public void copyFrom(PersonalQuestsComponent other) {
this.questsInPreperation = Lists.newArrayList(other.questsInPreperation);
}

// public EntityRef activeQuest = EntityRef.NULL;

// TODO allow the player to reject certain categories of quests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
/*
* Copyright 2016 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.gooeysQuests.api;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.world.block.BlockRegion;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.structureTemplates.events.SpawnStructureEvent;
import org.terasology.structureTemplates.events.StructureBlocksSpawnedEvent;

/**
* If a entity with this component gets a {@link SpawnStructureEvent} (that triggers a
* {@link StructureBlocksSpawnedEvent}) then particles will be spawned in the given region.
*/
public class SpawnMagicBuildParticlesComponent implements Component {
public BlockRegion region;
public class SpawnMagicBuildParticlesComponent implements Component<SpawnMagicBuildParticlesComponent> {
public BlockRegion region = new BlockRegion(BlockRegion.INVALID);

@Override
public void copyFrom(SpawnMagicBuildParticlesComponent other) {
this.region.set(other.region);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
/*
* Copyright 2016 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.gooeysQuests.api;

import com.google.common.collect.Lists;
import org.joml.Vector3i;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.math.Side;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.reflection.MappedContainer;

import java.util.ArrayList;
Expand All @@ -26,9 +14,14 @@
/**
* Describes how the current structure entity can be connected to other structure entities.
*/
public class StructureConnectionPointsComponent implements Component {
public class StructureConnectionPointsComponent implements Component<StructureConnectionPointsComponent> {
public List<ConnectionPoint> points = new ArrayList<>();

@Override
public void copyFrom(StructureConnectionPointsComponent other) {
this.points = Lists.newArrayList(other.points);
}

@MappedContainer
public static class ConnectionPoint {
public Vector3i position;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
/*
* Copyright 2016 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.gooeysQuests.quests.dungeon;

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

/**
* Owned by the entity that represents a dungeon quest.
*/
public class DungeonQuestComponent implements Component {
public class DungeonQuestComponent implements Component<DungeonQuestComponent> {

@Override
public void copyFrom(DungeonQuestComponent other) {

}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
/*
* Copyright 2016 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.gooeysQuests.quests.dwarfhalls;

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

/**
* Owned by the entity that represents a dwarf halls quest.
*/
public class DwarfHallsQuestComponent implements Component {
public class DwarfHallsQuestComponent implements Component<DwarfHallsQuestComponent> {

@Override
public void copyFrom(DwarfHallsQuestComponent other) {

}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
/*
* Copyright 2016 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.gooeysQuests.quests.fortressvillage;

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

/**
* Owned by the entity that represents a fortressvillage quest.
*/
public class FortressVillageQuestComponent implements Component {
public class FortressVillageQuestComponent implements Component<FortressVillageQuestComponent> {

@Override
public void copyFrom(FortressVillageQuestComponent other) {

}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
/*
* Copyright 2018 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.gooeysQuests.quests.mines;

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

/**
* Owned by the entity that represents a mines quest.
*/
public class MinesQuestComponent implements Component {
public class MinesQuestComponent implements Component<MinesQuestComponent> {
@Override
public void copyFrom(MinesQuestComponent other) {

}
}

0 comments on commit abfccce

Please sign in to comment.