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

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,26 +1,13 @@
/*
* 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.adventureassets.altarofresurrection;

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

/**
* This is a marker component that is attached to a the altar of resurrection collider for dealing with the ActivateEvent and
* AttackEvent.
*/

public class AltarOfResurrectionColliderComponent implements Component {
public class AltarOfResurrectionColliderComponent extends EmptyComponent<AltarOfResurrectionColliderComponent> {
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,26 @@
/*
* 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.adventureassets.altarofresurrection;

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

/**
* This component is attached to every altar of resurrection root entity.
*/

@ForceBlockActive
public class AltarOfResurrectionRootComponent implements Component {
public class AltarOfResurrectionRootComponent implements Component<AltarOfResurrectionRootComponent> {

public EntityRef meshEntity;
public EntityRef orbEntity;
public EntityRef colliderEntity;

@Override
public void copyFrom(AltarOfResurrectionRootComponent other) {
this.meshEntity = other.meshEntity;
this.orbEntity = other.meshEntity;
this.colliderEntity = other.colliderEntity;
}
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
/*
* 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.adventureassets.altarofresurrection;

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

/**
* This component makes a player respawn near the altar of resurrection. It is attached to the clientInfo entity which always
* remains active. This is done so that this component can be removed upon the destruction of the concerned altar of resurrection
* entity even when the player entity is inactive.
*/

public class RevivePlayerComponent implements Component {
public class RevivePlayerComponent implements Component<RevivePlayerComponent> {
@Replicate
public Vector3f location;
@Replicate
public EntityRef altarOfResurrectionEntity;

@Override
public void copyFrom(RevivePlayerComponent other) {
this.location = new Vector3f(other.location);
this.altarOfResurrectionEntity = other.altarOfResurrectionEntity;
}
}
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.adventureassets.damageplayer;

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

/**
* This component marks a rigid body for dealing damage to the player.
*/

public class DamagePlayerComponent implements Component {
public class DamagePlayerComponent implements Component<DamagePlayerComponent> {
public float damage = 10;
public float recoil = 5;

@Override
public void copyFrom(DamagePlayerComponent other) {
this.damage = other.damage;
this.recoil = other.recoil;
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
/*
* 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.adventureassets.traps.fireballlauncher;

import org.joml.Vector3f;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.network.Replicate;
import org.terasology.engine.world.block.ForceBlockActive;
import org.terasology.gestalt.entitysystem.component.Component;

/**
* This component holds the data for a Fireball Launcher
*/

@ForceBlockActive
public class FireballLauncherComponent implements Component {
public class FireballLauncherComponent implements Component<FireballLauncherComponent> {

/**
* Sets the fireball launcher as active or inactive
Expand Down Expand Up @@ -69,4 +56,15 @@ public class FireballLauncherComponent implements Component {
*/
@Replicate
public int damageAmount = 20;

@Override
public void copyFrom(FireballLauncherComponent other) {
this.isFiring = other.isFiring;
this.timePeriod = other.timePeriod;
this.offset = other.offset;
this.lastShotTime = other.lastShotTime;
this.direction = new Vector3f(other.direction);
this.maxDistance = other.maxDistance;
this.damageAmount = other.damageAmount;
}
}
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
/*
* 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.adventureassets.traps.fireballlauncher.structuretemplateintegration;

import org.joml.Vector3f;
import org.joml.Vector3i;
import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.reflection.MappedContainer;
import org.terasology.structureTemplates.events.SpawnStructureEvent;

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

/**
* This component is intended to be used in structure templates.
* <p>
* It adds items (incl. block items) to one ore more chests when the entity receives a
* {@link SpawnStructureEvent}.
*/
public class AddFireballLauncherComponent implements Component {
public class AddFireballLauncherComponent implements Component<AddFireballLauncherComponent> {
public List<FireballLauncherToSpawn> fireballLaunchersToSpawn;

@Override
public void copyFrom(AddFireballLauncherComponent other) {
this.fireballLaunchersToSpawn = other.fireballLaunchersToSpawn.stream()
.map(FireballLauncherToSpawn::copy)
.collect(Collectors.toList());
}

@MappedContainer
public static class FireballLauncherToSpawn {
public Vector3i position;
Expand All @@ -41,5 +36,17 @@ public static class FireballLauncherToSpawn {
public Vector3f direction;
public int maxDistance;
public int damageAmount;

FireballLauncherToSpawn copy() {
FireballLauncherToSpawn newFL = new FireballLauncherToSpawn();
newFL.position = new Vector3i(this.position);
newFL.isFiring = this.isFiring;
newFL.timePeriod = this.timePeriod;
newFL.offset = this.offset;
newFL.direction = new Vector3f(this.direction);
newFL.maxDistance = this.maxDistance;
newFL.damageAmount = this.damageAmount;
return newFL;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
/*
* 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.adventureassets.traps.mcqButtonDoor;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Lists;
import org.terasology.engine.network.Replicate;
import org.terasology.engine.world.block.ForceBlockActive;
import org.terasology.gestalt.entitysystem.component.Component;

import java.util.Arrays;
import java.util.List;

@ForceBlockActive
public class McqButtonDoorComponent implements Component {
public class McqButtonDoorComponent implements Component<McqButtonDoorComponent> {
@Replicate
public String title = "title";
@Replicate
Expand All @@ -33,4 +21,12 @@ public class McqButtonDoorComponent implements Component {
public String password = "password";
@Replicate
public List<String> options = Arrays.asList("password", "password1", "password2");

@Override
public void copyFrom(McqButtonDoorComponent other) {
this.title = other.title;
this.message = other.message;
this.password = other.password;
this.options = Lists.newArrayList(other.options);
}
}
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.adventureassets.traps.passwordDoor;

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

@ForceBlockActive
public class PasswordDoorComponent implements Component {
public class PasswordDoorComponent implements Component<PasswordDoorComponent> {
@Replicate
public String title = "title";
@Replicate
public String message = "message";
@Replicate
public String password = "password";

@Override
public void copyFrom(PasswordDoorComponent other) {
this.title = other.title;
this.message = other.message;
this.password = other.password;
}
}
Loading