mirror of
https://github.com/Anime-Game-Servers/Grasscutter-Quests.git
synced 2024-11-23 12:39:49 +00:00
Fix gather object multiplying when reloading gadther points
This commit is contained in:
parent
7f24e43bc0
commit
94adfb3bb1
@ -24,6 +24,7 @@ import emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo;
|
||||
import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||
import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
|
||||
import emu.grasscutter.net.proto.VectorOuterClass.Vector;
|
||||
import emu.grasscutter.net.proto.VisionTypeOuterClass;
|
||||
import emu.grasscutter.scripts.EntityControllerScriptManager;
|
||||
import emu.grasscutter.scripts.constants.EventType;
|
||||
import emu.grasscutter.scripts.data.SceneGadget;
|
||||
@ -40,6 +41,8 @@ import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ToString(callSuper = true)
|
||||
public class EntityGadget extends EntityBaseGadget {
|
||||
@ -50,6 +53,7 @@ public class EntityGadget extends EntityBaseGadget {
|
||||
@Getter private final Position bornRot;
|
||||
private int gadgetId;
|
||||
@Getter @Setter private GameEntity owner = null;
|
||||
@Getter @Setter private List<GameEntity> children = new ArrayList<>();
|
||||
|
||||
private int state;
|
||||
private int pointType;
|
||||
@ -201,6 +205,15 @@ public class EntityGadget extends EntityBaseGadget {
|
||||
getScene().getScriptManager().callEvent(new ScriptArgs(EventType.EVENT_GADGET_CREATE, this.getConfigId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoved() {
|
||||
super.onRemoved();
|
||||
if(!children.isEmpty()) {
|
||||
getScene().removeEntities(children, VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE);
|
||||
children.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(int killerId) {
|
||||
super.onDeath(killerId); // Invoke super class's onDeath() method.
|
||||
|
@ -34,6 +34,7 @@ public class GadgetGatherPoint extends GadgetContent {
|
||||
gatherObjectChild.setMetaGadget(gadget.getMetaGadget());
|
||||
gatherObjectChild.buildContent();
|
||||
|
||||
gadget.getChildren().add(gatherObjectChild);
|
||||
scene.addEntity(gatherObjectChild);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user