Skip to content

Commit 206e611

Browse files
committed
Fixed Resource Gathering reset after exhausting the source.
Updated Helper API to offer List able to use LINQ. Worker's gathering method is now chaining. Increased animation speed of Goblin to reduce global physics modifier. Fixed an issue with ActionQueue error if Finished during Progress. Resources are now properly removed from Player Model on Destroy. Added a GatherResource constructor overload to ignore Exceptions.
1 parent a110967 commit 206e611

File tree

25 files changed

+190
-52
lines changed

25 files changed

+190
-52
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
3+
namespace XposeCraft.Game.Actors.Resources
4+
{
5+
public class ResourceExhaustedException : Exception
6+
{
7+
public ResourceExhaustedException() : base("Resource is not available for gathering anymore")
8+
{
9+
}
10+
11+
public ResourceExhaustedException(IResource resource) : base(
12+
"Resource " + resource.GetType().Name + " is not available for gathering anymore")
13+
{
14+
}
15+
16+
public ResourceExhaustedException(string message) : base(message)
17+
{
18+
}
19+
}
20+
}

API/Sources/Actors/Units/Worker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using XposeCraft.Game.Actors.Buildings;
33
using XposeCraft.Game.Actors.Resources;
4+
using XposeCraft.Game.Control;
45
using XposeCraft.Game.Enums;
56

67
namespace XposeCraft.Game.Actors.Units
@@ -20,7 +21,7 @@ public class Worker : Unit
2021
/// <see cref="XposeCraft.Game.Helpers.ResourceHelper"/> provides various methods to find some.
2122
/// </summary>
2223
/// <param name="resource">Resource to be gathered.</param>
23-
public void SendGather(IResource resource)
24+
public UnitActionQueue SendGather(IResource resource)
2425
{
2526
throw new NotImplementedException();
2627
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,37 @@
11
using System;
2+
using XposeCraft.Game.Actors.Buildings;
23
using XposeCraft.Game.Actors.Resources;
4+
using XposeCraft.Game.Actors.Units;
35

46
namespace XposeCraft.Game.Control.GameActions
57
{
8+
/// <summary>
9+
/// Gathers a chosen Resource and returns back to the <see cref="BaseCenter"/> with collected Resources, which are
10+
/// subsequenty available for spending by Player anywhere. Only <see cref="Worker"/> units can do this Action.
11+
/// Throws <see cref="ResourceExhaustedException"/> if the target resource is no longer available.
12+
/// </summary>
613
public class GatherResource : GameAction
714
{
15+
/// <summary>
16+
/// Gathering target Resource.
17+
/// </summary>
818
public IResource Gathering { get; private set; }
919

20+
/// <inheritdoc cref="GatherResource"/>
21+
/// <param name="resource">Resource to be gathered.</param>
22+
/// <exception cref="ResourceExhaustedException">The Resource was already exhausted before the attempt to go gather it.</exception>
1023
public GatherResource(IResource resource)
1124
{
1225
throw new NotImplementedException();
1326
}
27+
28+
/// <inheritdoc cref="GatherResource"/>
29+
/// <param name="resource">Resource to be gathered.</param>
30+
/// <param name="exceptionIfExhausted">If false, won't throw the <see cref="ResourceExhaustedException"/></param>
31+
/// <exception cref="ResourceExhaustedException">The Resource was already exhausted before the attempt to go gather it.</exception>
32+
public GatherResource(IResource resource, bool exceptionIfExhausted)
33+
{
34+
throw new NotImplementedException();
35+
}
1436
}
1537
}

API/Sources/Helpers/BuildingHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public sealed class BuildingHelper : ActorHelper<IBuilding>
1414
/// <inheritdoc cref="GetMyBuildings{TBuilding}"/>
1515
/// <typeparam name="TBuilding">Type of the Building to be searched for.</typeparam>
1616
/// <returns>List of Buildings.</returns>
17-
public static IList<TBuilding> GetMyBuildingsAsList<TBuilding>() where TBuilding : IBuilding
17+
public static List<TBuilding> GetMyBuildingsAsList<TBuilding>() where TBuilding : IBuilding
1818
{
1919
throw new NotImplementedException();
2020
}
@@ -32,7 +32,7 @@ public static TBuilding[] GetMyBuildings<TBuilding>() where TBuilding : IBuildin
3232
/// <inheritdoc cref="GetVisibleEnemyBuildings{TUnit}"/>
3333
/// <typeparam name="TBuilding">Type of the Buildings to be searched for.</typeparam>
3434
/// <returns>List of Buildings</returns>
35-
public static IList<TBuilding> GetVisibleEnemyBuildingsAsList<TBuilding>() where TBuilding : IBuilding
35+
public static List<TBuilding> GetVisibleEnemyBuildingsAsList<TBuilding>() where TBuilding : IBuilding
3636
{
3737
throw new NotImplementedException();
3838
}

API/Sources/Helpers/ResourceHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public sealed class ResourceHelper : ActorHelper<IResource>
1717
/// <inheritdoc cref="GetResources{TResource}"/>
1818
/// <typeparam name="TResource">Type of the Resource to be searched for.</typeparam>
1919
/// <returns>List of resources.</returns>
20-
public static IList<TResource> GetResourcesAsList<TResource>() where TResource : IResource
20+
public static List<TResource> GetResourcesAsList<TResource>() where TResource : IResource
2121
{
2222
throw new NotImplementedException();
2323
}
@@ -60,7 +60,7 @@ public static TResource GetNearestResourceTo<TResource>(IActor actor) where TRes
6060
/// <param name="baseCenter">Base near which all nearest resources will be looked for.</param>
6161
/// <typeparam name="TResource">Type of the Resource to be searched for.</typeparam>
6262
/// <returns>List of resources.</returns>
63-
public static IList<TResource> GetResourcesNearBase<TResource>(BaseCenter baseCenter)
63+
public static List<TResource> GetResourcesNearBase<TResource>(BaseCenter baseCenter)
6464
where TResource : IResource
6565
{
6666
throw new NotImplementedException();

API/Sources/Helpers/UnitHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed class UnitHelper : ActorHelper<IUnit>
1313
/// <inheritdoc cref="GetMyUnits{TUnit}"/>
1414
/// <typeparam name="TUnit">Type of the Unit to be searched for.</typeparam>
1515
/// <returns>List of Units</returns>
16-
public static IList<TUnit> GetMyUnitsAsList<TUnit>() where TUnit : IUnit
16+
public static List<TUnit> GetMyUnitsAsList<TUnit>() where TUnit : IUnit
1717
{
1818
throw new NotImplementedException();
1919
}
@@ -31,7 +31,7 @@ public static TUnit[] GetMyUnits<TUnit>() where TUnit : IUnit
3131
/// <inheritdoc cref="GetVisibleEnemyUnits{TUnit}"/>
3232
/// <typeparam name="TUnit">Type of the Unit to be searched for.</typeparam>
3333
/// <returns>List of Units</returns>
34-
public static IList<TUnit> GetVisibleEnemyUnitsAsList<TUnit>() where TUnit : IUnit
34+
public static List<TUnit> GetVisibleEnemyUnitsAsList<TUnit>() where TUnit : IUnit
3535
{
3636
throw new NotImplementedException();
3737
}

Assets/Game/Meshes/Actors/Units/Goblin/Animators/GoblinAnimator.controller

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ AnimatorController:
1313
m_DefaultFloat: 0
1414
m_DefaultInt: 0
1515
m_DefaultBool: 0
16-
m_Controller: {fileID: 0}
16+
m_Controller: {fileID: 9100000}
1717
m_AnimatorLayers:
1818
- serializedVersion: 5
1919
m_Name: Base Layer
@@ -226,7 +226,7 @@ AnimatorState:
226226
m_PrefabParentObject: {fileID: 0}
227227
m_PrefabInternal: {fileID: 0}
228228
m_Name: Build
229-
m_Speed: 1
229+
m_Speed: 2
230230
m_CycleOffset: 0
231231
m_Transitions:
232232
- {fileID: 1101000011271170944}
@@ -250,7 +250,7 @@ AnimatorState:
250250
m_PrefabParentObject: {fileID: 0}
251251
m_PrefabInternal: {fileID: 0}
252252
m_Name: Move
253-
m_Speed: 1
253+
m_Speed: 2
254254
m_CycleOffset: 0
255255
m_Transitions:
256256
- {fileID: 1101000011872441762}
@@ -274,7 +274,7 @@ AnimatorState:
274274
m_PrefabParentObject: {fileID: 0}
275275
m_PrefabInternal: {fileID: 0}
276276
m_Name: Gather
277-
m_Speed: 1
277+
m_Speed: 2
278278
m_CycleOffset: 0
279279
m_Transitions:
280280
- {fileID: 1101000012103646210}
@@ -298,7 +298,7 @@ AnimatorState:
298298
m_PrefabParentObject: {fileID: 0}
299299
m_PrefabInternal: {fileID: 0}
300300
m_Name: Attack
301-
m_Speed: 1
301+
m_Speed: 2
302302
m_CycleOffset: 0
303303
m_Transitions:
304304
- {fileID: 1101000013839435532}
@@ -322,7 +322,7 @@ AnimatorState:
322322
m_PrefabParentObject: {fileID: 0}
323323
m_PrefabInternal: {fileID: 0}
324324
m_Name: Idle
325-
m_Speed: 1
325+
m_Speed: 2
326326
m_CycleOffset: 0
327327
m_Transitions:
328328
- {fileID: 1101000011031516282}

Assets/Game/Prefabs/Actors/Units/DonkeyGun.prefab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ MonoBehaviour:
264264
m_Script: {fileID: 11500000, guid: 907c1687b5023ca4a8ae5376bcb0dbbc, type: 3}
265265
m_Name:
266266
m_EditorClassIdentifier:
267-
speed: 6
268-
rotateSpeed: 5
267+
speed: 12
268+
rotateSpeed: 8
269269
target: {x: 0, y: 0, z: 0}
270270
gridI: 0
271271
myPath:

Assets/Game/Prefabs/Actors/Units/Goblin.prefab

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2850,8 +2850,8 @@ MonoBehaviour:
28502850
m_Script: {fileID: 11500000, guid: 907c1687b5023ca4a8ae5376bcb0dbbc, type: 3}
28512851
m_Name:
28522852
m_EditorClassIdentifier:
2853-
speed: 5
2854-
rotateSpeed: 8
2853+
speed: 10
2854+
rotateSpeed: 10
28552855
target: {x: 0, y: 0, z: 0}
28562856
gridI: 0
28572857
myPath:

Assets/Game/Prefabs/Managers/Player Manager.prefab

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ MonoBehaviour:
244244
m_Name:
245245
m_EditorClassIdentifier:
246246
key: q
247-
modifier: 4
247+
NormalSpeed: 1
248+
Modifier: 5
248249
--- !u!114 &114000012604824786
249250
MonoBehaviour:
250251
m_ObjectHideFlags: 1

0 commit comments

Comments
 (0)