generated from TeamGensouSpark/LunarCapitalFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ DanmakuStateModifier to modify state easier
- Loading branch information
Showing
5 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/io/github/teamgensouspark/kekkai/danmaku/DanmakuStateModifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package io.github.teamgensouspark.kekkai.danmaku; | ||
|
||
import net.katsstuff.teamnightclipse.danmakucore.danmaku.DanmakuEntityData; | ||
import net.katsstuff.teamnightclipse.danmakucore.danmaku.TrackerData; | ||
import net.katsstuff.teamnightclipse.danmakucore.danmaku.subentity.SubEntity; | ||
import net.katsstuff.teamnightclipse.danmakucore.data.MovementData; | ||
import net.katsstuff.teamnightclipse.danmakucore.data.RotationData; | ||
import net.katsstuff.teamnightclipse.danmakucore.data.ShotData; | ||
import net.katsstuff.teamnightclipse.mirror.data.Vector3; | ||
import net.katsstuff.teamnightclipse.danmakucore.danmaku.DanmakuState; | ||
import net.katsstuff.teamnightclipse.danmakucore.danmaku.ExtraDanmakuData; | ||
|
||
public class DanmakuStateModifier { | ||
DanmakuState danmaku; | ||
|
||
DanmakuEntityData entityData; | ||
ExtraDanmakuData extra; | ||
TrackerData tracker; | ||
|
||
public DanmakuStateModifier(DanmakuState danmaku) { | ||
this.danmaku = danmaku; | ||
this.entityData = danmaku.entity(); | ||
this.extra = danmaku.extra(); | ||
this.tracker = danmaku.tracking(); | ||
} | ||
|
||
public DanmakuEntityData getEntityData() { | ||
return entityData; | ||
} | ||
|
||
public ExtraDanmakuData getExtraData() { | ||
return extra; | ||
} | ||
|
||
public TrackerData getTrackerData() { | ||
return tracker; | ||
} | ||
|
||
public DanmakuStateModifier setDirection(Vector3 direction) { | ||
this.entityData.setDirection(direction); | ||
return this; | ||
} | ||
|
||
public DanmakuStateModifier setMovement(MovementData movement) { | ||
this.extra = this.extra.copy(extra.user(), extra.source(), extra.shot(), extra.subEntity(), movement, | ||
extra.rotation()); | ||
return this; | ||
} | ||
|
||
public DanmakuStateModifier setShot(ShotData shot) { | ||
this.extra = this.extra.copy(extra.user(), extra.source(), shot, extra.subEntity(), extra.movement(), | ||
extra.rotation()); | ||
return this; | ||
} | ||
|
||
public DanmakuStateModifier setRotation(RotationData rotation) { | ||
this.extra = this.extra.copy(extra.user(), extra.source(), extra.shot(), extra.subEntity(), extra.movement(), | ||
rotation); | ||
return this; | ||
} | ||
|
||
public DanmakuStateModifier setSubEntity(SubEntity entity) { | ||
this.extra = this.extra.copy(extra.user(), extra.source(), extra.shot(), entity, extra.movement(), | ||
extra.rotation()); | ||
return this; | ||
} | ||
|
||
public DanmakuState getDanmaku() { | ||
return danmaku.copy(entityData, extra, tracker); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ain/java/io/github/teamgensouspark/kekkai/danmaku/subentity/impl/ShotToSelfSubEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.github.teamgensouspark.kekkai.danmaku.subentity.impl; | ||
|
||
import net.katsstuff.teamnightclipse.danmakucore.danmaku.DanmakuState; | ||
import net.katsstuff.teamnightclipse.danmakucore.impl.subentity.SubEntityDefault; | ||
import net.katsstuff.teamnightclipse.mirror.data.Vector3; | ||
|
||
public class ShotToSelfSubEntity extends SubEntityDefault { | ||
|
||
@Override | ||
public DanmakuState onCreate(DanmakuState danmaku) { | ||
return super.onCreate(danmaku).copy( | ||
danmaku.entity() | ||
.setDirection( | ||
(Vector3) Vector3.directionToPos(danmaku.pos(), new Vector3(danmaku.user().get()))), | ||
danmaku.extra(), danmaku.tracking()); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/io/github/teamgensouspark/kekkai/utils/Vector3Utils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package io.github.teamgensouspark.kekkai.utils; | ||
|
||
import net.katsstuff.teamnightclipse.mirror.data.AbstractVector3; | ||
import net.katsstuff.teamnightclipse.mirror.data.Vector3; | ||
|
||
public class Vector3Utils { | ||
public static Vector3 pos2pos(AbstractVector3 from, AbstractVector3 to) { | ||
return (Vector3) Vector3.directionToPos(from, to); | ||
} | ||
} |