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

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,24 +1,11 @@
/*
* Copyright 2019 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.apiculture.components;

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

/**
* Indicates that a block entity is an apiary.
*/
public class ApiaryComponent implements Component {
public class ApiaryComponent extends EmptyComponent<ApiaryComponent> {
}
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
/*
* Copyright 2019 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.apiculture.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.module.inventory.components.ItemDifferentiating;

import java.util.Objects;

/**
* Indicates that an item is a bee.
*/
public final class BeeComponent implements Component, ItemDifferentiating {
public final class BeeComponent implements Component<BeeComponent>, ItemDifferentiating {
/**
* Bee type, that is, whether a bee is a drone, princess, or queen.
*/
public BeeType type;

@Override
public void copyFrom(BeeComponent other) {
this.type = other.type;
}

public enum BeeType {
DRONE,
PRINCESS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
/*
* Copyright 2019 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.apiculture.components;

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

/**
* Indicates that a block entity is an extractor.
*/
public class ExtractorComponent implements Component {
public class ExtractorComponent extends EmptyComponent<ExtractorComponent> {
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
/*
* Copyright 2019 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.apiculture.components;

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

/**
* Indicates that a block entity is an injector.
*/
public class InjectorComponent implements Component {
public class InjectorComponent extends EmptyComponent<InjectorComponent> {
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
/*
* Copyright 2019 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.apiculture.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.module.inventory.components.ItemDifferentiating;

import java.util.Objects;

/**
* Indicates an item is a genetic sample, and stores the locus and genotype of the gene it is a sample of.
*/
public class LocusSampleComponent implements Component, ItemDifferentiating {
public class LocusSampleComponent implements Component<LocusSampleComponent>, ItemDifferentiating {
/**
* The locus of the gene this sample is of.
*/
Expand Down Expand Up @@ -53,4 +40,10 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(locus, genotype);
}

@Override
public void copyFrom(LocusSampleComponent other) {
this.locus = other.locus;
this.genotype = other.genotype;
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
/*
* Copyright 2019 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.apiculture.components;

import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.module.inventory.components.ItemDifferentiating;
import org.terasology.genetics.components.GeneticsComponent;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.module.inventory.components.ItemDifferentiating;

import java.util.Objects;

/**
* Stores the genetic and lifespan information for a queen bee.
*/
public final class MatedComponent implements Component, ItemDifferentiating {
public final class MatedComponent implements Component<MatedComponent>, ItemDifferentiating {
/**
* An entity containing the genetics component of the drone that mated with the queen.
*/
Expand Down Expand Up @@ -62,4 +49,11 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(ticksRemaining, lifespan, container.getComponent(GeneticsComponent.class));
}

@Override
public void copyFrom(MatedComponent other) {
this.container = other.container;
this.ticksRemaining = other.ticksRemaining;
this.lifespan = other.lifespan;
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
/*
* Copyright 2019 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.apiculture.components;

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

/**
* Indicates to screens that processes are occurring in an apiary, extractor, or injector, and at what game time they will
* complete.
*/
public final class ProcessingComponent implements Component {
public final class ProcessingComponent implements Component<ProcessingComponent> {
public long finishTime;

public ProcessingComponent() { }

public ProcessingComponent(long finishTime) {
this.finishTime = finishTime;
}

@Override
public void copyFrom(ProcessingComponent other) {
this.finishTime = other.finishTime;
}
}