@@ -23,7 +23,9 @@ public class ClientInputSender : NetworkBehaviour
23
23
//upstream network conservation. This matters when holding down your mouse button to move.
24
24
const float k_MoveSendRateSeconds = 0.04f ; //25 fps.
25
25
26
- const float k_TargetMoveTimeout = 0.45f ; //prevent moves for this long after targeting someone (helps prevent walking to the guy you clicked).
26
+ const float
27
+ k_TargetMoveTimeout =
28
+ 0.45f ; //prevent moves for this long after targeting someone (helps prevent walking to the guy you clicked).
27
29
28
30
float m_LastSentMove ;
29
31
@@ -39,8 +41,7 @@ public class ClientInputSender : NetworkBehaviour
39
41
40
42
RaycastHitComparer m_RaycastHitComparer ;
41
43
42
- [ SerializeField ]
43
- ServerCharacter m_ServerCharacter ;
44
+ [ SerializeField ] ServerCharacter m_ServerCharacter ;
44
45
45
46
/// <summary>
46
47
/// This event fires at the time when an action request is sent to the server.
@@ -53,12 +54,12 @@ public class ClientInputSender : NetworkBehaviour
53
54
/// </summary>
54
55
public enum SkillTriggerStyle
55
56
{
56
- None , //no skill was triggered.
57
- MouseClick , //skill was triggered via mouse-click implying you should do a raycast from the mouse position to find a target.
58
- Keyboard , //skill was triggered via a Keyboard press, implying target should be taken from the active target.
57
+ None , //no skill was triggered.
58
+ MouseClick , //skill was triggered via mouse-click implying you should do a raycast from the mouse position to find a target.
59
+ Keyboard , //skill was triggered via a Keyboard press, implying target should be taken from the active target.
59
60
KeyboardRelease , //represents a released key.
60
- UI , //skill was triggered from the UI, and similar to Keyboard, target should be inferred from the active target.
61
- UIRelease , //represents letting go of the mouse-button on a UI button
61
+ UI , //skill was triggered from the UI, and similar to Keyboard, target should be inferred from the active target.
62
+ UIRelease , //represents letting go of the mouse-button on a UI button
62
63
}
63
64
64
65
bool IsReleaseStyle ( SkillTriggerStyle style )
@@ -105,8 +106,7 @@ struct ActionRequest
105
106
/// </summary>
106
107
CharacterClass CharacterClass => m_ServerCharacter . CharacterClass ;
107
108
108
- [ SerializeField ]
109
- PhysicsWrapper m_PhysicsWrapper ;
109
+ [ SerializeField ] PhysicsWrapper m_PhysicsWrapper ;
110
110
111
111
public ActionState actionState1 { get ; private set ; }
112
112
@@ -140,11 +140,13 @@ public override void OnNetworkSpawn()
140
140
{
141
141
actionState1 = new ActionState ( ) { actionID = action1 . ActionID , selectable = true } ;
142
142
}
143
+
143
144
if ( CharacterClass . Skill2 &&
144
145
GameDataSource . Instance . TryGetActionPrototypeByID ( CharacterClass . Skill2 . ActionID , out var action2 ) )
145
146
{
146
147
actionState2 = new ActionState ( ) { actionID = action2 . ActionID , selectable = true } ;
147
148
}
149
+
148
150
if ( CharacterClass . Skill3 &&
149
151
GameDataSource . Instance . TryGetActionPrototypeByID ( CharacterClass . Skill3 . ActionID , out var action3 ) )
150
152
{
@@ -225,16 +227,19 @@ void FixedUpdate()
225
227
}
226
228
else if ( ! IsReleaseStyle ( m_ActionRequests [ i ] . TriggerStyle ) )
227
229
{
228
- var actionPrototype = GameDataSource . Instance . GetActionPrototypeByID ( m_ActionRequests [ i ] . RequestedActionID ) ;
230
+ var actionPrototype =
231
+ GameDataSource . Instance . GetActionPrototypeByID ( m_ActionRequests [ i ] . RequestedActionID ) ;
229
232
if ( actionPrototype . Config . ActionInput != null )
230
233
{
231
234
var skillPlayer = Instantiate ( actionPrototype . Config . ActionInput ) ;
232
- skillPlayer . Initiate ( m_ServerCharacter , m_PhysicsWrapper . Transform . position , actionPrototype . ActionID , SendInput , FinishSkill ) ;
235
+ skillPlayer . Initiate ( m_ServerCharacter , m_PhysicsWrapper . Transform . position ,
236
+ actionPrototype . ActionID , SendInput , FinishSkill ) ;
233
237
m_CurrentSkillInput = skillPlayer ;
234
238
}
235
239
else
236
240
{
237
- PerformSkill ( actionPrototype . ActionID , m_ActionRequests [ i ] . TriggerStyle , m_ActionRequests [ i ] . TargetId ) ;
241
+ PerformSkill ( actionPrototype . ActionID , m_ActionRequests [ i ] . TriggerStyle ,
242
+ m_ActionRequests [ i ] . TargetId ) ;
238
243
}
239
244
}
240
245
}
@@ -354,7 +359,8 @@ void PerformSkill(ActionID actionID, SkillTriggerStyle triggerStyle, ulong targe
354
359
/// <param name="triggerStyle">How did this skill play get triggered? Mouse, Keyboard, UI etc.</param>
355
360
/// <param name="resultData">Out parameter that will be filled with the resulting action, if any.</param>
356
361
/// <returns>true if we should play an action, false otherwise. </returns>
357
- bool GetActionRequestForTarget ( Transform hit , ActionID actionID , SkillTriggerStyle triggerStyle , out ActionRequestData resultData )
362
+ bool GetActionRequestForTarget ( Transform hit , ActionID actionID , SkillTriggerStyle triggerStyle ,
363
+ out ActionRequestData resultData )
358
364
{
359
365
resultData = new ActionRequestData ( ) ;
360
366
@@ -427,7 +433,8 @@ void PopulateSkillRequest(Vector3 hitPoint, ActionID actionID, ref ActionRequest
427
433
//for projectile logic, infer the direction from the click position.
428
434
case ActionLogic . LaunchProjectile :
429
435
resultData . Direction = direction ;
430
- resultData . ShouldClose = false ; //why? Because you could be lining up a shot, hoping to hit other people between you and your target. Moving you would be quite invasive.
436
+ resultData . ShouldClose =
437
+ false ; //why? Because you could be lining up a shot, hoping to hit other people between you and your target. Moving you would be quite invasive.
431
438
return ;
432
439
case ActionLogic . Melee :
433
440
resultData . Direction = direction ;
@@ -475,13 +482,13 @@ void Update()
475
482
{
476
483
if ( Input . GetKeyDown ( KeyCode . Alpha1 ) && CharacterClass . Skill1 )
477
484
{
478
-
479
485
RequestAction ( actionState1 . actionID , SkillTriggerStyle . Keyboard ) ;
480
486
}
481
487
else if ( Input . GetKeyUp ( KeyCode . Alpha1 ) && CharacterClass . Skill1 )
482
488
{
483
489
RequestAction ( actionState1 . actionID , SkillTriggerStyle . KeyboardRelease ) ;
484
490
}
491
+
485
492
if ( Input . GetKeyDown ( KeyCode . Alpha2 ) && CharacterClass . Skill2 )
486
493
{
487
494
RequestAction ( actionState2 . actionID , SkillTriggerStyle . Keyboard ) ;
@@ -490,6 +497,7 @@ void Update()
490
497
{
491
498
RequestAction ( actionState2 . actionID , SkillTriggerStyle . KeyboardRelease ) ;
492
499
}
500
+
493
501
if ( Input . GetKeyDown ( KeyCode . Alpha3 ) && CharacterClass . Skill3 )
494
502
{
495
503
RequestAction ( actionState3 . actionID , SkillTriggerStyle . Keyboard ) ;
@@ -503,14 +511,17 @@ void Update()
503
511
{
504
512
RequestAction ( GameDataSource . Instance . Emote1ActionPrototype . ActionID , SkillTriggerStyle . Keyboard ) ;
505
513
}
514
+
506
515
if ( Input . GetKeyDown ( KeyCode . Alpha6 ) )
507
516
{
508
517
RequestAction ( GameDataSource . Instance . Emote2ActionPrototype . ActionID , SkillTriggerStyle . Keyboard ) ;
509
518
}
519
+
510
520
if ( Input . GetKeyDown ( KeyCode . Alpha7 ) )
511
521
{
512
522
RequestAction ( GameDataSource . Instance . Emote3ActionPrototype . ActionID , SkillTriggerStyle . Keyboard ) ;
513
523
}
524
+
514
525
if ( Input . GetKeyDown ( KeyCode . Alpha8 ) )
515
526
{
516
527
RequestAction ( GameDataSource . Instance . Emote4ActionPrototype . ActionID , SkillTriggerStyle . Keyboard ) ;
@@ -528,7 +539,8 @@ void Update()
528
539
529
540
if ( Input . GetMouseButtonDown ( 0 ) )
530
541
{
531
- RequestAction ( GameDataSource . Instance . GeneralTargetActionPrototype . ActionID , SkillTriggerStyle . MouseClick ) ;
542
+ RequestAction ( GameDataSource . Instance . GeneralTargetActionPrototype . ActionID ,
543
+ SkillTriggerStyle . MouseClick ) ;
532
544
}
533
545
else if ( Input . GetMouseButton ( 0 ) )
534
546
{
@@ -540,7 +552,8 @@ void Update()
540
552
void UpdateAction1 ( )
541
553
{
542
554
var isHoldingNetworkObject =
543
- NetworkManager . Singleton . SpawnManager . SpawnedObjects . TryGetValue ( m_ServerCharacter . HeldNetworkObject . Value ,
555
+ NetworkManager . Singleton . SpawnManager . SpawnedObjects . TryGetValue (
556
+ m_ServerCharacter . HeldNetworkObject . Value ,
544
557
out var heldNetworkObject ) ;
545
558
546
559
NetworkManager . Singleton . SpawnManager . SpawnedObjects . TryGetValue ( m_ServerCharacter . TargetId . Value ,
@@ -554,19 +567,19 @@ void UpdateAction1()
554
567
actionState1 . actionID = GameDataSource . Instance . DropActionPrototype . ActionID ;
555
568
}
556
569
else if ( ( m_ServerCharacter . TargetId . Value != 0
557
- && selection != null
558
- && selection . TryGetComponent ( out PickUpState pickUpState ) )
559
- )
570
+ && selection != null
571
+ && selection . TryGetComponent ( out PickUpState pickUpState ) )
572
+ )
560
573
{
561
574
// special case: targeting a pickup-able item or holding a pickup object
562
575
563
576
actionState1 . actionID = GameDataSource . Instance . PickUpActionPrototype . ActionID ;
564
577
}
565
578
else if ( m_ServerCharacter . TargetId . Value != 0
566
- && selection != null
567
- && selection . NetworkObjectId != m_ServerCharacter . NetworkObjectId
568
- && selection . TryGetComponent ( out ServerCharacter charState )
569
- && ! charState . IsNpc )
579
+ && selection != null
580
+ && selection . NetworkObjectId != m_ServerCharacter . NetworkObjectId
581
+ && selection . TryGetComponent ( out ServerCharacter charState )
582
+ && ! charState . IsNpc )
570
583
{
571
584
// special case: when we have a player selected, we change the meaning of the basic action
572
585
// we have another player selected! In that case we want to reflect that our basic Action is a Revive, not an attack!
0 commit comments