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

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,21 +1,8 @@
/*
* 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.substanceMatters.components;

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

public class FluidSubstanceComponent implements Component {
public class FluidSubstanceComponent extends EmptyComponent<FluidSubstanceComponent> {
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
/*
* Copyright 2014 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.substanceMatters.components;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.terasology.engine.entitySystem.Component;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.prefab.Prefab;
import org.terasology.engine.entitySystem.prefab.PrefabManager;
import org.terasology.module.inventory.systems.InventoryUtils;
import org.terasology.module.inventory.components.ItemDifferentiating;
import org.terasology.engine.network.Replicate;
import org.terasology.engine.registry.CoreRegistry;
import org.terasology.engine.utilities.Assets;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.module.inventory.components.ItemDifferentiating;
import org.terasology.module.inventory.systems.InventoryUtils;

import java.util.Collections;
import java.util.Comparator;
Expand All @@ -35,7 +22,7 @@
/**
* A list of the contents of an item. Not intended to be added directly to a prefab with json.
*/
public class MaterialCompositionComponent implements Component, ItemDifferentiating {
public class MaterialCompositionComponent implements Component<MaterialCompositionComponent>, ItemDifferentiating {
/**
* A map of the substance prefab and how much is contained
*/
Expand Down Expand Up @@ -178,4 +165,9 @@ public String toDisplayString() {
display = display.trim();
return display;
}

@Override
public void copyFrom(MaterialCompositionComponent other) {
this.contents = Maps.newHashMap(other.contents);
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
/*
* Copyright 2014 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.substanceMatters.components;

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

/**
* Attach this to items that are made of a particular substance. The icon will be tinted to the substance's definition.
*/
public class MaterialItemComponent implements Component, ItemDifferentiating {
public class MaterialItemComponent implements Component<MaterialItemComponent>, ItemDifferentiating {
public String icon;

@Override
Expand All @@ -46,4 +33,9 @@ public boolean equals(Object o) {
public int hashCode() {
return icon != null ? icon.hashCode() : 0;
}

@Override
public void copyFrom(MaterialItemComponent other) {
this.icon = other.icon;
}
}
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
/*
* Copyright 2014 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.substanceMatters.components;

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

/**
* A definition for a substance. Color values are for generated icons.
*/
public class SubstanceComponent implements Component {
public class SubstanceComponent implements Component<SubstanceComponent> {
public String name;
public String description = "";
public int hue;
public float saturationScale = 1f;
public float brightnessScale = 1f;

@Override
public void copyFrom(SubstanceComponent other) {
this.name = other.name;
this.description = other.description;
this.hue = other.hue;
this.saturationScale = other.saturationScale;
this.brightnessScale = other.brightnessScale;
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
/*
* Copyright 2014 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.substanceMatters.processParts;

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

import java.util.Map;

public class InjectSubstancesComponent implements Component {
public class InjectSubstancesComponent implements Component<InjectSubstancesComponent> {
/**
* A map of substance prefab and how much is added
*/
Expand All @@ -31,4 +18,9 @@ public class InjectSubstancesComponent implements Component {
*/
public Map<String, String> replace = Maps.newHashMap();

@Override
public void copyFrom(InjectSubstancesComponent other) {
this.add = Maps.newHashMap(other.add);
this.replace = Maps.newHashMap(other.replace);
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
/*
* Copyright 2014 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.substanceMatters.processParts;

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

/**
* Creates an material item containing the materials that it is composed of based on the original input items. The item will appear like the largest amount of substance.
*/
public class TransferSubstancesComponent implements Component {
public class TransferSubstancesComponent implements Component<TransferSubstancesComponent> {
boolean extract = true;
boolean inject = true;

@Override
public void copyFrom(TransferSubstancesComponent other) {
this.extract = other.extract;
this.inject = other.inject;
}
}