Skip to content

Commit

Permalink
fix(ecs-gestalt): Migrate Components to gestalt's Components. (#18)
Browse files Browse the repository at this point in the history
Ref: MovingBlocks/Terasology#4753

Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
  • Loading branch information
DarkWeird and skaldarnar authored Aug 25, 2021
1 parent ca0024f commit d0783ec
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
/*
* Copyright 2015 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.breathing.component;

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

/**
* Future class for representing the composition of blocks for breathing purposes, IE smoke is 50% oxygen.
*/
public class BreathableBlockComponent implements Component {
public class BreathableBlockComponent extends EmptyComponent<BreathableBlockComponent> {
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
/*
* Copyright 2015 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.breathing.component;

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

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

/**
* Use to signify an entity is subject to org.terasology.breathing
*/
public class BreatherComponent implements Component {
public class BreatherComponent implements Component<BreatherComponent> {

public long breathCapacity = 15000;
public float breathRechargeRate = 2.0f;
Expand All @@ -32,4 +20,12 @@ public class BreatherComponent implements Component {

public List<String> breathes = Arrays.asList("Oxygen");

@Override
public void copyFrom(BreatherComponent other) {
this.breathCapacity = other.breathCapacity;
this.breathRechargeRate = other.breathRechargeRate;
this.timeBetweenSuffocateDamage = other.timeBetweenSuffocateDamage;
this.suffocateDamage = other.suffocateDamage;
this.breathes = Lists.newArrayList(other.breathes);
}
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
/*
* Copyright 2015 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.breathing.component;

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

public class SuffocatingComponent implements Component {
public class SuffocatingComponent implements Component<SuffocatingComponent> {

@Replicate(FieldReplicateType.SERVER_TO_OWNER)
public boolean isBreathing;
Expand All @@ -46,4 +33,11 @@ public float getRemainingBreath(long gameTime) {
return Math.min(Math.max(percentage, 0f), 1f);
}

@Override
public void copyFrom(SuffocatingComponent other) {
this.isBreathing = other.isBreathing;
this.endTime = other.endTime;
this.startTime = other.startTime;
this.nextSuffocateDamageTime = other.nextSuffocateDamageTime;
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
/*
* 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.breathing.component;


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

public final class UnbreathableBlockComponent implements Component {
public final class UnbreathableBlockComponent extends EmptyComponent<UnbreathableBlockComponent> {
}

0 comments on commit d0783ec

Please sign in to comment.