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

Merged
merged 3 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,32 +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.scenario.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Sets;
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;

import java.util.HashSet;
import java.util.Set;

/**
* Component that gets attached to a scenario hub tool that contains the list of entities that are expanded in the treeview of the logic entities
*/
public class HubToolExpansionComponent implements Component{
public class HubToolExpansionComponent implements Component<HubToolExpansionComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public Set<EntityRef> expandedList = new HashSet<>();

@Override
public void copyFrom(HubToolExpansionComponent other) {
this.expandedList = Sets.newHashSet(other.expandedList);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
/*
* 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.scenario.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Maps;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.network.NetworkComponent;
import org.terasology.engine.network.Replicate;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.scenario.components.information.IndentificationComponents.ScenarioTypeIntegerComponent;
import org.terasology.scenario.components.information.ScenarioValueStringComponent;

Expand All @@ -36,7 +24,12 @@
* Scenario logic entities are detailed in {@link ScenarioComponent}
*/
@Replicate
public class ScenarioArgumentContainerComponent implements Component {
public class ScenarioArgumentContainerComponent implements Component<ScenarioArgumentContainerComponent> {
@Replicate
public Map<String, EntityRef> arguments;
public Map<String, EntityRef> arguments = Maps.newHashMap();

@Override
public void copyFrom(ScenarioArgumentContainerComponent other) {
this.arguments = Maps.newHashMap(other.arguments);
}
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
/*
* 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.scenario.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Lists;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.network.FieldReplicateType;
import org.terasology.engine.network.NetworkComponent;
import org.terasology.engine.network.Replicate;
import org.terasology.engine.world.block.BlockRegion;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.scenario.components.actions.ScenarioIndicatorActionComponent;
import org.terasology.scenario.components.actions.ScenarioSecondaryGiveBlockComponent;
import org.terasology.scenario.components.regions.RegionBeingCreatedComponent;
Expand Down Expand Up @@ -64,10 +52,16 @@
* * indicates optional (RegionBeingCreated meaning it is currently being created, ProtectedRegion meaning the region
* is being protected by the structureTemplates system and will prevent alterations being made to the land within the region
*/
public class ScenarioComponent implements Component {
public class ScenarioComponent implements Component<ScenarioComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public List<EntityRef> triggerEntities = new ArrayList<>();

@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public List<EntityRef> regionEntities = new ArrayList<>();

@Override
public void copyFrom(ScenarioComponent other) {
this.triggerEntities = Lists.newArrayList(other.triggerEntities);
this.regionEntities = Lists.newArrayList(other.regionEntities);
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +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.scenario.components;

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

/**
* Component that lets the client know that the scenario entity was updated and therefore it should redraw on the next update
*/
public class ScenarioHubToolUpdateComponent implements Component {
public class ScenarioHubToolUpdateComponent implements Component<ScenarioHubToolUpdateComponent> {
@NoReplicate
public String localScreenID;

@Replicate(FieldReplicateType.SERVER_TO_OWNER)
public EntityRef addedEntity;

@Override
public void copyFrom(ScenarioHubToolUpdateComponent other) {
this.localScreenID = other.localScreenID;
this.addedEntity = other.addedEntity;
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
/*
* 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.scenario.components;

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;

/**
* Label component for a Scenario logic entity, includes the text displayed on a dropdown menu for selecting an entity prefab in the logic editor
*
* Scenario logic entities detailed in {@link ScenarioComponent}
*/
public class ScenarioLogicLabelComponent implements Component {
public class ScenarioLogicLabelComponent implements Component<ScenarioLogicLabelComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public String name;

@Override
public void copyFrom(ScenarioLogicLabelComponent other) {
this.name = other.name;
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
/*
* 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.scenario.components;

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;
import org.terasology.scenario.internal.utilities.ArgumentParser;

/**
Expand All @@ -31,7 +18,12 @@
*
* Scenario logic entities detailed in {@link ScenarioComponent}
*/
public class ScenarioLogicTextComponent implements Component {
public class ScenarioLogicTextComponent implements Component<ScenarioLogicTextComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public String text;

@Override
public void copyFrom(ScenarioLogicTextComponent other) {
this.text = other.text;
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
/*
* 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.scenario.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Sets;
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;

import java.util.HashSet;
import java.util.Set;
Expand All @@ -28,7 +16,12 @@
* local player (visibility of the regions are ticked to true)
*/
@Replicate(FieldReplicateType.SERVER_TO_OWNER)
public class ScenarioRegionVisibilityComponent implements Component {
public class ScenarioRegionVisibilityComponent implements Component<ScenarioRegionVisibilityComponent> {
@Replicate(FieldReplicateType.OWNER_TO_SERVER)
public Set<EntityRef> visibleList = new HashSet<>();

@Override
public void copyFrom(ScenarioRegionVisibilityComponent other) {
visibleList = Sets.newHashSet(other.visibleList);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
/*
* 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.scenario.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Lists;
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;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -27,7 +15,12 @@
*
* Scenario logic entities detailed in {@link ScenarioComponent}
*/
public class TriggerActionListComponent implements Component {
public class TriggerActionListComponent implements Component<TriggerActionListComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public List<EntityRef> actions = new ArrayList<>();

@Override
public void copyFrom(TriggerActionListComponent other) {
this.actions = Lists.newArrayList(other.actions);
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
/*
* 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.scenario.components;

import org.terasology.engine.entitySystem.Component;
import com.google.common.collect.Lists;
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;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -28,7 +16,12 @@
*
* Scenario logic entities detailed in {@link ScenarioComponent}
*/
public class TriggerConditionListComponent implements Component {
public class TriggerConditionListComponent implements Component<TriggerConditionListComponent> {
@Replicate(FieldReplicateType.SERVER_TO_CLIENT)
public List<EntityRef> conditions = new ArrayList<>();

@Override
public void copyFrom(TriggerConditionListComponent other) {
this.conditions = Lists.newArrayList(other.conditions);
}
}
Loading