-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from AndyTechGuy/characterFactions
Implementation of a Character Faction System
- Loading branch information
Showing
13 changed files
with
394 additions
and
33 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
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
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
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
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
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
47 changes: 47 additions & 0 deletions
47
src/main/java/org/terasology/metalrenegades/ai/actions/SetTargetToEnemyAction.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,47 @@ | ||
/* | ||
* Copyright 2018 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.ai.actions; | ||
|
||
import org.terasology.behaviors.components.FollowComponent; | ||
import org.terasology.logic.behavior.BehaviorAction; | ||
import org.terasology.logic.behavior.core.Actor; | ||
import org.terasology.logic.behavior.core.BaseAction; | ||
import org.terasology.logic.behavior.core.BehaviorState; | ||
import org.terasology.metalrenegades.ai.component.NearbyCitizenEnemiesComponent; | ||
|
||
/** | ||
* Action which sets this agent's move target to the nearest citizen from an enemy faction, as | ||
* defined in {@link NearbyCitizenEnemiesComponent}. | ||
*/ | ||
@BehaviorAction(name = "set_target_to_enemy") | ||
public class SetTargetToEnemyAction extends BaseAction { | ||
|
||
@Override | ||
public BehaviorState modify(Actor actor, BehaviorState result) { | ||
if (!actor.hasComponent(NearbyCitizenEnemiesComponent.class)) { | ||
return BehaviorState.SUCCESS; | ||
} | ||
|
||
NearbyCitizenEnemiesComponent enemiesComponent = actor.getComponent(NearbyCitizenEnemiesComponent.class); | ||
FollowComponent followComponent = new FollowComponent(); | ||
|
||
followComponent.entityToFollow = enemiesComponent.closestEnemy; | ||
actor.getEntity().addComponent(followComponent); | ||
|
||
return BehaviorState.SUCCESS; | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/org/terasology/metalrenegades/ai/component/FactionAlignmentComponent.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,36 @@ | ||
/* | ||
* Copyright 2018 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.ai.component; | ||
|
||
import org.terasology.entitySystem.Component; | ||
import org.terasology.metalrenegades.ai.system.FactionAlignmentSystem.Alignment; | ||
|
||
/** | ||
* Defines the faction alignment of a particular character, building, or settlement. | ||
*/ | ||
public class FactionAlignmentComponent implements Component { | ||
|
||
public Alignment alignment; | ||
|
||
public FactionAlignmentComponent() { | ||
this.alignment = Alignment.NEUTRAL; | ||
} | ||
|
||
public FactionAlignmentComponent(Alignment alignment) { | ||
this.alignment = alignment; | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/terasology/metalrenegades/ai/component/NearbyCitizenEnemiesComponent.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,34 @@ | ||
/* | ||
* Copyright 2018 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.ai.component; | ||
|
||
import org.terasology.entitySystem.Component; | ||
import org.terasology.entitySystem.entity.EntityRef; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Stores the faction enemies in range of this citizen. | ||
*/ | ||
public class NearbyCitizenEnemiesComponent implements Component { | ||
|
||
public float searchRadius = 20f; | ||
|
||
public List<EntityRef> enemiesWithinRange; | ||
|
||
public EntityRef closestEnemy; | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/org/terasology/metalrenegades/ai/event/CitizenSpawnedEvent.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,25 @@ | ||
/* | ||
* Copyright 2018 MovingBlocks | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.terasology.metalrenegades.ai.event; | ||
|
||
import org.terasology.entitySystem.event.Event; | ||
|
||
/** | ||
* Fired when a new citizen character is spawned by {@link org.terasology.metalrenegades.ai.system.CitizenSpawnSystem}. | ||
*/ | ||
public class CitizenSpawnedEvent implements Event { | ||
|
||
} |
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
Oops, something went wrong.