package com.hypixel.hytale.server.npc.systems; import com.hypixel.hytale.component.ArchetypeChunk; import com.hypixel.hytale.component.CommandBuffer; import com.hypixel.hytale.component.ComponentType; import com.hypixel.hytale.component.Store; import com.hypixel.hytale.component.dependency.Dependency; import com.hypixel.hytale.component.query.Query; import com.hypixel.hytale.component.system.tick.EntityTickingSystem; import com.hypixel.hytale.server.core.universe.world.storage.EntityStore; import com.hypixel.hytale.server.npc.components.messaging.BeaconSupport; import com.hypixel.hytale.server.npc.components.messaging.MessageSupport; import com.hypixel.hytale.server.npc.components.messaging.NPCBlockEventSupport; import com.hypixel.hytale.server.npc.components.messaging.NPCEntityEventSupport; import com.hypixel.hytale.server.npc.components.messaging.NPCMessage; import com.hypixel.hytale.server.npc.components.messaging.PlayerBlockEventSupport; import com.hypixel.hytale.server.npc.components.messaging.PlayerEntityEventSupport; import java.util.Set; import javax.annotation.Nonnull; public abstract class MessageSupportSystem extends SteppableTickingSystem { @Nonnull private final ComponentType messageSupportComponentType; @Nonnull private final Set> dependencies; public MessageSupportSystem(@Nonnull ComponentType messageSupportComponentType, @Nonnull Set> dependencies) { this.messageSupportComponentType = messageSupportComponentType; this.dependencies = dependencies; } @Nonnull @Override public Set> getDependencies() { return this.dependencies; } @Override public boolean isParallel(int archetypeChunkSize, int taskCount) { return EntityTickingSystem.maybeUseParallel(archetypeChunkSize, taskCount); } @Override public void steppedTick( float dt, int index, @Nonnull ArchetypeChunk archetypeChunk, @Nonnull Store store, @Nonnull CommandBuffer commandBuffer ) { T messageSupportComponent = archetypeChunk.getComponent(index, this.messageSupportComponentType); assert messageSupportComponent != null; NPCMessage[] messageSlots = messageSupportComponent.getMessageSlots(); if (messageSlots != null) { for (NPCMessage slot : messageSlots) { if (slot.isActivated() && !slot.isInfinite() && slot.tickAge(dt)) { slot.deactivate(); } } } } @Nonnull @Override public Query getQuery() { return this.messageSupportComponentType; } public static class BeaconSystem extends MessageSupportSystem { public BeaconSystem(@Nonnull ComponentType componentType, @Nonnull Set> dependencies) { super(componentType, dependencies); } } public static class NPCBlockEventSystem extends MessageSupportSystem { public NPCBlockEventSystem(@Nonnull ComponentType componentType, @Nonnull Set> dependencies) { super(componentType, dependencies); } } public static class NPCEntityEventSystem extends MessageSupportSystem { public NPCEntityEventSystem(@Nonnull ComponentType componentType, @Nonnull Set> dependencies) { super(componentType, dependencies); } } public static class PlayerBlockEventSystem extends MessageSupportSystem { public PlayerBlockEventSystem( @Nonnull ComponentType componentType, @Nonnull Set> dependencies ) { super(componentType, dependencies); } } public static class PlayerEntityEventSystem extends MessageSupportSystem { public PlayerEntityEventSystem( @Nonnull ComponentType componentType, @Nonnull Set> dependencies ) { super(componentType, dependencies); } } }