Skip to content

Commit

Permalink
feat(gestaltv7-eventsystem): Migration Event and @ReceiveEvent to ges…
Browse files Browse the repository at this point in the history
…talt's (#56)
  • Loading branch information
DarkWeird authored Dec 7, 2021
1 parent 2c8abd9 commit 79031eb
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import org.terasology.gestalt.assets.management.AssetManager;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.BeforeDeactivateComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnActivatedComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnChangedComponent;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.prefab.Prefab;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
Expand All @@ -26,6 +24,8 @@
import org.terasology.entityNetwork.NetworkNode;
import org.terasology.entityNetwork.NetworkNodeBuilder;
import org.terasology.entityNetwork.components.EntityNetworkComponent;
import org.terasology.gestalt.assets.management.AssetManager;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;

import java.util.ArrayList;
import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
package org.terasology.fluidTransport.processParts;

import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.fluidTransport.components.FluidPumpComponent;
import org.terasology.fluidTransport.systems.FluidTransportAuthoritySystem;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.potentialEnergyDevices.components.PotentialEnergyDeviceComponent;
import org.terasology.workstation.process.ProcessPartDescription;
import org.terasology.workstation.processPart.ProcessEntityGetDurationEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,26 @@

import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.EventPriority;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.event.Priority;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.engine.logic.common.ActivateEvent;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.engine.logic.inventory.ItemComponent;
import org.terasology.engine.registry.In;
import org.terasology.fluid.component.FluidContainerItemComponent;
import org.terasology.fluid.system.FluidUtils;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.module.inventory.systems.InventoryManager;

@RegisterSystem(RegisterMode.AUTHORITY)
public class FluidTankAuthoritySystem extends BaseComponentSystem {
@In
InventoryManager inventoryManager;

// Prioritize interacting with tanks over other things
@ReceiveEvent(components = {ItemComponent.class}, priority = EventPriority.PRIORITY_HIGH)
@Priority(EventPriority.PRIORITY_HIGH)
@ReceiveEvent(components = {ItemComponent.class})

Check warning on line 39 in src/main/java/org/terasology/fluidTransport/systems/FluidTankAuthoritySystem.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

AnnotationUseStyleCheck

NORMAL: Annotation style must be 'COMPACT_NO_ARRAY'.
Raw output
<p>Since Checkstyle 5.0</p><p> This check controls the style with the usage of annotations. </p>
public void fillFluidContainerItem(ActivateEvent event, EntityRef item,
FluidContainerItemComponent fluidContainer) {
EntityRef targetBlockEntity = event.getTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
import org.joml.Vector3f;
import org.joml.Vector3fc;
import org.joml.Vector3i;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.engine.entitySystem.entity.EntityBuilder;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.BeforeDeactivateComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnActivatedComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnChangedComponent;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
Expand All @@ -25,15 +23,17 @@
import org.terasology.engine.rendering.assets.mesh.MeshBuilder;
import org.terasology.engine.rendering.assets.texture.Texture;
import org.terasology.engine.rendering.logic.MeshComponent;
import org.terasology.module.inventory.ui.GetItemTooltip;
import org.terasology.engine.utilities.Assets;
import org.terasology.engine.world.block.regions.BlockRegionComponent;
import org.terasology.fluid.component.FluidInventoryComponent;
import org.terasology.fluid.system.FluidContainerAssetResolver;
import org.terasology.fluid.system.FluidRegistry;
import org.terasology.fluidTransport.components.FluidDisplayComponent;
import org.terasology.fluidTransport.components.FluidTankDisplayComponent;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.itemRendering.components.RenderItemComponent;
import org.terasology.module.inventory.ui.GetItemTooltip;
import org.terasology.nui.widgets.TooltipLine;

import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnChangedComponent;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
Expand All @@ -46,6 +45,7 @@
import org.terasology.fluidTransport.components.FluidPipeComponent;
import org.terasology.fluidTransport.components.FluidPumpComponent;
import org.terasology.fluidTransport.components.FluidTankDropsFluidComponent;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.workstation.component.WorkstationComponent;
import org.terasology.workstation.event.WorkstationStateChanged;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.terasology.itemTransport.events;

import org.joml.Vector3i;
import org.terasology.engine.entitySystem.event.Event;
import org.terasology.gestalt.entitysystem.event.Event;

public class ConveyorItemStuckEvent implements Event {
Vector3i targetPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnActivatedComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnAddedComponent;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.event.Activity;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.engine.entitySystem.systems.UpdateSubscriberSystem;
import org.terasology.engine.logic.delay.DelayManager;
import org.terasology.engine.logic.delay.DelayedActionTriggeredEvent;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.module.inventory.systems.InventoryUtils;
import org.terasology.module.inventory.events.InventorySlotChangedEvent;
import org.terasology.module.inventory.events.InventorySlotStackSizeChangedEvent;
import org.terasology.engine.math.Direction;
import org.terasology.engine.math.Side;
import org.terasology.engine.monitoring.PerformanceMonitor;
import org.terasology.engine.registry.In;
import org.terasology.engine.world.BlockEntityRegistry;
import org.terasology.engine.world.block.Block;
import org.terasology.engine.world.block.BlockComponent;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.itemRendering.components.AnimatedMovingItemComponent;
import org.terasology.itemTransport.components.PullInventoryInDirectionComponent;
import org.terasology.itemTransport.components.PushInventoryInDirectionComponent;
import org.terasology.machines.ExtendedInventoryManager;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.module.inventory.events.InventorySlotChangedEvent;
import org.terasology.module.inventory.events.InventorySlotStackSizeChangedEvent;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.module.inventory.systems.InventoryUtils;
import org.terasology.workstation.process.WorkstationInventoryUtils;
import org.terasology.workstation.process.inventory.InventoryOutputProcessPartCommonSystem;

Expand Down Expand Up @@ -148,8 +149,9 @@ private void finishPushing(EntityRef entity, PushInventoryInDirectionComponent p
}
}
}

@ReceiveEvent(activity = ACTIVITY)

@Activity(ACTIVITY)
@ReceiveEvent
public void pushInventoryGotItem(InventorySlotChangedEvent event, EntityRef entity, PushInventoryInDirectionComponent pushInventory,
BlockComponent block, InventoryComponent inventory) {
Side side = getRelativeSide(entity, pushInventory.direction);
Expand Down Expand Up @@ -199,27 +201,31 @@ public void pushInventoryGotItem(InventorySlotChangedEvent event, EntityRef enti
// 2. Inventory of an adjacent block has changed (maybe there is space there now?)
// 3. New inventory was placed or loaded in an adjacent block

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pushCondition1(DelayedActionTriggeredEvent event, EntityRef entity, PushInventoryInDirectionComponent pushInventory,
BlockComponent blockComponent, InventoryComponent inventory) {
if (event.getActionId().equals("FINISHED_PUSHING")) {
pendingPushChecks.add(entity);
}
}

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pushCondition2(InventorySlotChangedEvent event, EntityRef entity, InventoryComponent inventory,
BlockComponent block) {
checkAdjacentBlocksForPushFinish(block);
}

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pushCondition2(InventorySlotStackSizeChangedEvent event, EntityRef entity, InventoryComponent inventory,
BlockComponent block) {
checkAdjacentBlocksForPushFinish(block);
}

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pushCondition3(OnActivatedComponent event, EntityRef entity, InventoryComponent inventory,
BlockComponent block) {
checkAdjacentBlocksForPushFinish(block);
Expand Down Expand Up @@ -249,25 +255,29 @@ private boolean entityCanAcceptItem(EntityRef targetEntity) {
// 3. Inventory of an adjacent block has changed (maybe there is something new to pull?)
// 4. New inventory was placed or loaded in an adjacent block

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pullCondition1(InventorySlotChangedEvent event, EntityRef entity, PullInventoryInDirectionComponent pullInventory,
BlockComponent blockComponent, InventoryComponent inventory) {
tryPullingAnItem(entity);
}

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pullCondition2(OnAddedComponent event, EntityRef entity, PullInventoryInDirectionComponent pullInventory,
BlockComponent blockComponent, InventoryComponent inventory) {
tryPullingAnItem(entity);
}

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pullCondition3(InventorySlotChangedEvent event, EntityRef entity, InventoryComponent inventory,
BlockComponent block) {
checkAdjacentBlocksForPulling(block);
}

@ReceiveEvent(activity = ACTIVITY)
@Activity(ACTIVITY)
@ReceiveEvent
public void pullCondition4(OnActivatedComponent event, EntityRef entity, InventoryComponent inventory,
BlockComponent block) {
checkAdjacentBlocksForPulling(block);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package org.terasology.machines;

import org.terasology.engine.entitySystem.event.Event;
import org.terasology.engine.network.NoReplicate;
import org.terasology.gestalt.entitysystem.event.Event;

public abstract class AbstractResultEvent<T> implements Event {
@NoReplicate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package org.terasology.machines.events;

import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.Event;
import org.terasology.gestalt.entitysystem.event.Event;

public class RequirementUsedEvent implements Event {
EntityRef processEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
package org.terasology.machines.processParts;

import com.google.common.collect.Lists;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.engine.core.Time;
import org.terasology.engine.entitySystem.entity.EntityBuilder;
import org.terasology.engine.entitySystem.entity.EntityManager;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.prefab.Prefab;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.engine.logic.inventory.ItemComponent;
import org.terasology.module.inventory.events.BeforeItemPutInInventory;
import org.terasology.engine.registry.CoreRegistry;
import org.terasology.engine.registry.In;
import org.terasology.engine.utilities.Assets;
import org.terasology.gestalt.assets.ResourceUrn;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.machines.ExtendedInventoryManager;
import org.terasology.machines.components.MachineDefinitionComponent;
import org.terasology.machines.components.ProcessRequirementsProviderComponent;
import org.terasology.machines.components.ProcessRequirementsProviderFromWorkstationComponent;
import org.terasology.machines.events.RequirementUsedEvent;
import org.terasology.machines.ui.OverlapLayout;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.module.inventory.events.BeforeItemPutInInventory;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.nui.UIWidget;
import org.terasology.nui.databinding.ReadOnlyBinding;
import org.terasology.workstation.process.ProcessPartDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@

import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnAddedComponent;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.engine.logic.common.RetainComponentsComponent;
import org.terasology.module.inventory.components.InventoryAccessComponent;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.engine.math.IntegerRange;
import org.terasology.engine.world.block.BlockComponent;
import org.terasology.fluid.component.FluidInventoryComponent;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.machines.components.MachineDefinitionComponent;
import org.terasology.machines.components.NestedMachineComponent;
import org.terasology.machines.processParts.RequirementInputProcessPartCommonSystem;
import org.terasology.module.inventory.components.InventoryAccessComponent;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.workstation.process.fluid.FluidInputProcessPartCommonSystem;
import org.terasology.workstation.process.fluid.FluidOutputProcessPartCommonSystem;
import org.terasology.workstation.process.inventory.InventoryInputProcessPartCommonSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
import org.terasology.engine.entitySystem.entity.lifecycleEvents.BeforeDeactivateComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnActivatedComponent;
import org.terasology.engine.entitySystem.entity.lifecycleEvents.OnChangedComponent;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.module.inventory.components.InventoryAccessComponent;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.itemRendering.components.RenderInventorySlotsComponent;
import org.terasology.machines.components.RenderInventoryInCategoryComponent;
import org.terasology.module.inventory.components.InventoryAccessComponent;
import org.terasology.workstation.process.WorkstationInventoryUtils;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.terasology.machines.systems;

import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
Expand All @@ -26,6 +25,7 @@
import org.terasology.engine.world.block.Block;
import org.terasology.engine.world.block.family.UpdatesWithNeighboursFamily;
import org.terasology.entityNetwork.components.EntityNetworkComponent;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;

@RegisterSystem(RegisterMode.AUTHORITY)
public class SameNetworkByBlockBlockFamilyAuthoritySystem extends BaseComponentSystem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

import org.joml.Vector3fc;
import org.terasology.engine.entitySystem.entity.EntityRef;
import org.terasology.engine.entitySystem.event.ReceiveEvent;
import org.terasology.engine.entitySystem.systems.BaseComponentSystem;
import org.terasology.engine.entitySystem.systems.RegisterMode;
import org.terasology.engine.entitySystem.systems.RegisterSystem;
import org.terasology.engine.input.binds.inventory.UseItemButton;
import org.terasology.engine.logic.characters.CharacterComponent;
import org.terasology.engine.logic.common.ActivateEvent;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.engine.logic.inventory.ItemComponent;
import org.terasology.engine.math.Direction;
import org.terasology.engine.math.Side;
Expand All @@ -24,7 +21,10 @@
import org.terasology.engine.world.block.BlockComponent;
import org.terasology.engine.world.block.family.BlockFamily;
import org.terasology.engine.world.block.family.SideDefinedBlockFamily;
import org.terasology.gestalt.entitysystem.event.ReceiveEvent;
import org.terasology.machines.components.SideActivatedInventoryInteractionComponent;
import org.terasology.module.inventory.components.InventoryComponent;
import org.terasology.module.inventory.systems.InventoryManager;
import org.terasology.workstation.process.WorkstationInventoryUtils;

import java.util.List;
Expand Down
Loading

0 comments on commit 79031eb

Please sign in to comment.