Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Grasscutter
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
ziqian zhang
Grasscutter
Commits
922ae917
Commit
922ae917
authored
3 years ago
by
ImmuState
Committed by
Melledy
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix EnergyManager indentation.
parent
ab1341f0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/emu/grasscutter/game/managers/EnergyManager.java
+53
-53
53 additions, 53 deletions
...ain/java/emu/grasscutter/game/managers/EnergyManager.java
with
53 additions
and
53 deletions
src/main/java/emu/grasscutter/game/managers/EnergyManager.java
+
53
−
53
View file @
922ae917
...
@@ -24,20 +24,20 @@ import java.util.Optional;
...
@@ -24,20 +24,20 @@ import java.util.Optional;
import
com.google.protobuf.InvalidProtocolBufferException
;
import
com.google.protobuf.InvalidProtocolBufferException
;
public
class
EnergyManager
{
public
class
EnergyManager
{
private
final
Player
player
;
private
final
Player
player
;
public
EnergyManager
(
Player
player
)
{
public
EnergyManager
(
Player
player
)
{
this
.
player
=
player
;
this
.
player
=
player
;
}
}
public
Player
getPlayer
()
{
public
Player
getPlayer
()
{
return
this
.
player
;
return
this
.
player
;
}
}
/**********
/**********
Particle creation for elemental skills.
Particle creation for elemental skills.
**********/
**********/
private
int
getCastingAvatarIdForElemBall
(
int
invokeEntityId
)
{
private
int
getCastingAvatarIdForElemBall
(
int
invokeEntityId
)
{
// To determine the avatar that has cast the skill that caused the energy particle to be generated,
// To determine the avatar that has cast the skill that caused the energy particle to be generated,
// we have to look at the entity that has invoked the ability. This can either be that avatar directly,
// we have to look at the entity that has invoked the ability. This can either be that avatar directly,
// or it can be an `EntityClientGadget`, owned (some way up the owner hierarchy) by the avatar
// or it can be an `EntityClientGadget`, owned (some way up the owner hierarchy) by the avatar
...
@@ -61,11 +61,11 @@ public class EnergyManager {
...
@@ -61,11 +61,11 @@ public class EnergyManager {
entity
=
player
.
getScene
().
getEntityById
(
gadget
.
getOwnerEntityId
());
entity
=
player
.
getScene
().
getEntityById
(
gadget
.
getOwnerEntityId
());
}
}
}
}
return
res
;
return
res
;
}
}
public
void
handleGenerateElemBall
(
AbilityInvokeEntry
invoke
)
throws
InvalidProtocolBufferException
{
public
void
handleGenerateElemBall
(
AbilityInvokeEntry
invoke
)
throws
InvalidProtocolBufferException
{
// ToDo:
// ToDo:
// This is also called when a weapon like Favonius Warbow etc. creates energy through its passive.
// This is also called when a weapon like Favonius Warbow etc. creates energy through its passive.
// We are not handling this correctly at the moment.
// We are not handling this correctly at the moment.
...
@@ -75,13 +75,13 @@ public class EnergyManager {
...
@@ -75,13 +75,13 @@ public class EnergyManager {
if
(
action
==
null
)
{
if
(
action
==
null
)
{
return
;
return
;
}
}
// Determine the element of the energy particle that we have to generate.
// Determine the element of the energy particle that we have to generate.
// In case we can't, we default to an elementless particle.
// In case we can't, we default to an elementless particle.
// The element is the element of the avatar that has cast the ability.
// The element is the element of the avatar that has cast the ability.
// We can get that from the avatar's skill depot.
// We can get that from the avatar's skill depot.
int
itemId
=
2024
;
int
itemId
=
2024
;
// Try to fetch the avatar from the player's party and determine their element.
// Try to fetch the avatar from the player's party and determine their element.
// ToDo: Does this work in co-op?
// ToDo: Does this work in co-op?
int
avatarId
=
getCastingAvatarIdForElemBall
(
invoke
.
getEntityId
());
int
avatarId
=
getCastingAvatarIdForElemBall
(
invoke
.
getEntityId
());
...
@@ -122,7 +122,7 @@ public class EnergyManager {
...
@@ -122,7 +122,7 @@ public class EnergyManager {
if
(
itemData
==
null
)
{
if
(
itemData
==
null
)
{
return
;
// Should never happen
return
;
// Should never happen
}
}
// Generate entity.
// Generate entity.
EntityItem
energyBall
=
new
EntityItem
(
getPlayer
().
getScene
(),
getPlayer
(),
itemData
,
new
Position
(
action
.
getPos
()),
1
);
EntityItem
energyBall
=
new
EntityItem
(
getPlayer
().
getScene
(),
getPlayer
(),
itemData
,
new
Position
(
action
.
getPos
()),
1
);
energyBall
.
getRotation
().
set
(
action
.
getRot
());
energyBall
.
getRotation
().
set
(
action
.
getRot
());
...
@@ -130,11 +130,11 @@ public class EnergyManager {
...
@@ -130,11 +130,11 @@ public class EnergyManager {
this
.
getPlayer
().
getScene
().
addEntity
(
energyBall
);
this
.
getPlayer
().
getScene
().
addEntity
(
energyBall
);
}
}
/**********
/**********
Pickup of elemental particles and orbs.
Pickup of elemental particles and orbs.
**********/
**********/
public
void
handlePickupElemBall
(
GameItem
elemBall
)
{
public
void
handlePickupElemBall
(
GameItem
elemBall
)
{
// Check if the item is indeed an energy particle/orb.
// Check if the item is indeed an energy particle/orb.
if
(
elemBall
.
getItemId
()
<
2001
||
elemBall
.
getItemId
()
>
2024
)
{
if
(
elemBall
.
getItemId
()
<
2001
||
elemBall
.
getItemId
()
>
2024
)
{
return
;
return
;
}
}
...
@@ -150,10 +150,10 @@ public class EnergyManager {
...
@@ -150,10 +150,10 @@ public class EnergyManager {
// On-field vs off-field multiplier.
// On-field vs off-field multiplier.
// The on-field character gets no penalty.
// The on-field character gets no penalty.
// Off-field characters get a penalty depending on the team size, as follows:
// Off-field characters get a penalty depending on the team size, as follows:
//
- 2 character team: 0.8
//
- 2 character team: 0.8
//
- 3 character team: 0.7
//
- 3 character team: 0.7
//
- 4 character team: 0.6
//
- 4 character team: 0.6
//
- etc.
//
- etc.
// We set a lower bound of 0.1 here, to avoid gaining no or negative energy.
// We set a lower bound of 0.1 here, to avoid gaining no or negative energy.
float
offFieldPenalty
=
float
offFieldPenalty
=
(
this
.
player
.
getTeamManager
().
getCurrentCharacterIndex
()
==
i
)
(
this
.
player
.
getTeamManager
().
getCurrentCharacterIndex
()
==
i
)
...
@@ -181,41 +181,41 @@ public class EnergyManager {
...
@@ -181,41 +181,41 @@ public class EnergyManager {
};
};
float
elementBonus
=
(
ballElement
==
null
)
?
2.0f
:
(
avatarElement
==
ballElement
)
?
3.0f
:
1.0f
;
float
elementBonus
=
(
ballElement
==
null
)
?
2.0f
:
(
avatarElement
==
ballElement
)
?
3.0f
:
1.0f
;
// Add the energy.
// Add the energy.
entity
.
addEnergy
(
baseEnergy
*
elementBonus
*
offFieldPenalty
,
PropChangeReason
.
PROP_CHANGE_ENERGY_BALL
);
entity
.
addEnergy
(
baseEnergy
*
elementBonus
*
offFieldPenalty
,
PropChangeReason
.
PROP_CHANGE_ENERGY_BALL
);
}
}
}
}
/**********
/**********
Energy logic related to using skills.
Energy logic related to using skills.
**********/
**********/
private
void
handleBurstCast
(
Avatar
avatar
,
int
skillId
)
{
private
void
handleBurstCast
(
Avatar
avatar
,
int
skillId
)
{
// Don't do anything if energy usage is disabled.
// Don't do anything if energy usage is disabled.
if
(!
GAME_OPTIONS
.
energyUsage
)
{
if
(!
GAME_OPTIONS
.
energyUsage
)
{
return
;
return
;
}
}
// If the cast skill was a burst, consume energy.
// If the cast skill was a burst, consume energy.
if
(
avatar
.
getSkillDepot
()
!=
null
&&
skillId
==
avatar
.
getSkillDepot
().
getEnergySkill
())
{
if
(
avatar
.
getSkillDepot
()
!=
null
&&
skillId
==
avatar
.
getSkillDepot
().
getEnergySkill
())
{
avatar
.
getAsEntity
().
clearEnergy
(
PropChangeReason
.
PROP_CHANGE_ABILITY
);
avatar
.
getAsEntity
().
clearEnergy
(
PropChangeReason
.
PROP_CHANGE_ABILITY
);
}
}
}
}
public
void
handleEvtDoSkillSuccNotify
(
GameSession
session
,
int
skillId
,
int
casterId
)
{
public
void
handleEvtDoSkillSuccNotify
(
GameSession
session
,
int
skillId
,
int
casterId
)
{
// Determine the entity that has cast the skill. Cancel if we can't find that avatar.
// Determine the entity that has cast the skill. Cancel if we can't find that avatar.
Optional
<
EntityAvatar
>
caster
=
this
.
player
.
getTeamManager
().
getActiveTeam
().
stream
()
Optional
<
EntityAvatar
>
caster
=
this
.
player
.
getTeamManager
().
getActiveTeam
().
stream
()
.
filter
(
character
->
character
.
getId
()
==
casterId
)
.
filter
(
character
->
character
.
getId
()
==
casterId
)
.
findFirst
();
.
findFirst
();
if
(
caster
.
isEmpty
())
{
if
(
caster
.
isEmpty
())
{
return
;
return
;
}
}
Avatar
avatar
=
caster
.
get
().
getAvatar
();
Avatar
avatar
=
caster
.
get
().
getAvatar
();
// Handle elemental burst.
// Handle elemental burst.
this
.
handleBurstCast
(
avatar
,
skillId
);
this
.
handleBurstCast
(
avatar
,
skillId
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment