gg.easy.airship 0.1.2140 → 0.1.2143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,7 +57,7 @@ public static class LuauPluginUpdateCheck {
57
57
  if (lastHash != "") {
58
58
  // Check if user wants to restart
59
59
  var acceptsRestart = EditorUtility.DisplayDialog("Luau Plugin Updated",
60
- "The Luau plugin has updated. Restart Unity to apply changes.", "Quit", "Cancel");
60
+ "The Luau plugin has updated. Restart Unity to apply changes. We're sorry for this..", "Quit", "Cancel");
61
61
  if (acceptsRestart) {
62
62
  // Verify any unsaved changes are saved
63
63
  var confirmedSaveState = EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo();
@@ -75,8 +75,7 @@ namespace Airship.Editor {
75
75
  }
76
76
  }
77
77
 
78
-
79
- await Task.Delay(1); // tune as needed
78
+ await Task.Delay(100); // tune as needed
80
79
  }
81
80
  }
82
81
 
@@ -267,20 +267,24 @@ public class SystemRoot : Singleton<SystemRoot> {
267
267
  this.networkCollectionIdCounter = 1;
268
268
 
269
269
  // sort packages by load order
270
- List<List<IEnumerator>> loadLists = new(3);
270
+ List<List<IEnumerator>> loadLists = new(2);
271
271
  for (int i = 0; i < loadLists.Capacity; i++) {
272
272
  loadLists.Add(new());
273
273
  }
274
274
 
275
275
  List<IEnumerator> GetLoadList(AirshipPackage package) {
276
- return loadLists[0];
277
- // if (package.id == "@Easy/CoreMaterials") {
276
+ // // Load core first because packages may depend them
277
+ // if (package.id == "@Easy/CoreMaterials" || package.id == "@Easy/Core") {
278
278
  // return loadLists[0];
279
279
  // }
280
- // if (package.id == "@Easy/Core") {
281
- // return loadLists[1];
282
- // }
283
- // return loadLists[2];
280
+
281
+ // All packages first
282
+ if (package.packageType == AirshipPackageType.Package) {
283
+ return loadLists[0];
284
+ }
285
+
286
+ // Games go last
287
+ return loadLists[1];
284
288
  }
285
289
 
286
290
  // Find packages to load
@@ -334,7 +338,10 @@ public class SystemRoot : Singleton<SystemRoot> {
334
338
  }
335
339
  #endif
336
340
 
341
+ Debug.Log("Loading packages...");
337
342
  yield return this.WaitAll(loadLists[0].ToArray());
343
+ Debug.Log("Loading game...");
344
+ yield return this.WaitAll(loadLists[1].ToArray());
338
345
 
339
346
  foreach (var ao in this.extraBundleLoadRequests) {
340
347
  if (!ao.isDone) {
@@ -483,6 +483,13 @@ public partial class LuauCore : MonoBehaviour
483
483
  return true;
484
484
  }
485
485
 
486
+ if (t == byteType) {
487
+ byte byteVal = (byte)value;
488
+ System.Int32 integer = byteVal;
489
+ LuauPlugin.LuauPushValueToThread(thread, (int)PODTYPE.POD_INT32, new IntPtr(value: &integer), 0); // 0, because we know how big an intPtr is
490
+ return true;
491
+ }
492
+
486
493
  if (t == longType) {
487
494
  Int64 intVal = (Int64)value;
488
495
  System.Int32 integer = unchecked((int)intVal);
@@ -48,7 +48,7 @@ namespace Code.RemoteConsole {
48
48
  }
49
49
  }
50
50
 
51
- await Task.Delay(1); // tune as needed
51
+ await Task.Delay(100); // tune as needed
52
52
  }
53
53
  }
54
54
 
@@ -157,7 +157,11 @@ namespace Code.Network.Simulation
157
157
  G_ResimMonitor.FrameObserverBuffer = buffer;
158
158
 
159
159
  if (!isActive) return;
160
- if (Physics.simulationMode != SimulationMode.Script) return;
160
+ if (Physics.simulationMode != SimulationMode.Script) {
161
+ // reset the simulation mode if it changed for some reason. This seems to happen on the server when you change prefabs
162
+ // while in play mode with mppm.
163
+ Physics.simulationMode = SimulationMode.Script;
164
+ }
161
165
 
162
166
  // Before running any commands, we perform any resimulation requests that were made during
163
167
  // the last tick. This ensures that resimulations don't affect command processing and
@@ -518,7 +518,7 @@ namespace Code.Network.StateSystem
518
518
  else
519
519
  {
520
520
  // Ensure that we always tick the system even if there's no command to process.
521
- // Debug.LogWarning("No commands left. Last command processed: " + this.lastProcessedCommand);
521
+ Debug.LogWarning("No commands left. Last command processed: " + this.lastProcessedCommand);
522
522
  this.stateSystem.Tick(null, time, false);
523
523
  }
524
524
  } while (this.serverCommandBuffer.Count >
@@ -400,16 +400,24 @@ namespace Code.Player.Character.MovementSystems.Character {
400
400
 
401
401
  if (grounded && !currentMoveSnapshot.isGrounded) {
402
402
  currentMoveSnapshot.jumpCount = 0;
403
- currentMoveSnapshot.timeSinceBecameGrounded = 0f;
403
+ currentMoveSnapshot.canJump = 255;
404
404
  OnImpactWithGround?.Invoke(currentVelocity, groundHit);
405
405
  if (mode == NetworkedStateSystemMode.Authority && isServer) {
406
406
  SAuthImpactEvent(currentVelocity, groundHit);
407
407
  } else if (mode == NetworkedStateSystemMode.Authority && isClient) {
408
408
  CAuthImpactEvent(currentVelocity, groundHit);
409
409
  }
410
- } else {
411
- currentMoveSnapshot.timeSinceBecameGrounded =
412
- Math.Min(currentMoveSnapshot.timeSinceBecameGrounded + deltaTime, 100f);
410
+ }
411
+
412
+ // If we have transitioned to airborne
413
+ if (!grounded && currentMoveSnapshot.isGrounded) {
414
+ // Set canJump to the number of ticks of coyote time we have
415
+ currentMoveSnapshot.canJump = (byte) Math.Min(Math.Floor(movementSettings.jumpCoyoteTime / Time.fixedDeltaTime), 255);
416
+ }
417
+
418
+ if (!grounded && !currentMoveSnapshot.isGrounded) {
419
+ // If we've now ticked once in the air, remove a tick of canJump time.
420
+ currentMoveSnapshot.canJump = (byte) Math.Max(currentMoveSnapshot.canJump - 1, 0);
413
421
  }
414
422
 
415
423
  var groundSlopeDir = detectedGround
@@ -463,8 +471,10 @@ namespace Code.Player.Character.MovementSystems.Character {
463
471
  //In the air
464
472
  // coyote jump
465
473
  if (currentVelocity.y < 0f &&
466
- currentMoveSnapshot.timeSinceWasGrounded <= movementSettings.jumpCoyoteTime &&
467
- currentMoveSnapshot.timeSinceJump > movementSettings.jumpCoyoteTime) {
474
+ // currentMoveSnapshot.timeSinceWasGrounded <= movementSettings.jumpCoyoteTime &&
475
+ // currentMoveSnapshot.timeSinceJump > movementSettings.jumpCoyoteTime
476
+ currentMoveSnapshot.canJump > 0
477
+ ) {
468
478
  canJump = true;
469
479
  }
470
480
  //the first jump requires grounded, so if in the air bump the currentMoveState.jumpCount up
@@ -565,23 +575,6 @@ namespace Code.Player.Character.MovementSystems.Character {
565
575
  currentMoveSnapshot.isSprinting = false;
566
576
  }
567
577
 
568
- /*
569
- * Update Time Since:
570
- */
571
-
572
- if (didJump) {
573
- currentMoveSnapshot.timeSinceJump = 0f;
574
- } else {
575
- currentMoveSnapshot.timeSinceJump = Math.Min(currentMoveSnapshot.timeSinceJump + deltaTime, 100f);
576
- }
577
-
578
- if (grounded) {
579
- currentMoveSnapshot.timeSinceWasGrounded = 0f;
580
- } else {
581
- currentMoveSnapshot.timeSinceWasGrounded =
582
- Math.Min(currentMoveSnapshot.timeSinceWasGrounded + deltaTime, 100f);
583
- }
584
-
585
578
  #region CROUCH
586
579
 
587
580
  // Prevent falling off blocks while crouching
@@ -985,7 +978,7 @@ namespace Code.Player.Character.MovementSystems.Character {
985
978
  var didStepUp = false;
986
979
  if (movementSettings.detectStepUps && //Want to check step ups
987
980
  (!command.crouch || !movementSettings.preventStepUpWhileCrouching) && //Not blocked by crouch
988
- (movementSettings.assistedLedgeJump || currentMoveSnapshot.timeSinceBecameGrounded > .05) && //Grounded
981
+ (movementSettings.assistedLedgeJump || currentMoveSnapshot.canJump > 0) && //Grounded // Used to be currentMoveSnapshot.timeSinceBecameGrounded > .05
989
982
  Mathf.Abs(newVelocity.x) + Mathf.Abs(newVelocity.z) > .05f) {
990
983
  //Moveing
991
984
  var (hitStepUp, onRamp, pointOnRamp, stepUpVel) = physics.StepUp(rootPosition,
@@ -1039,7 +1032,7 @@ namespace Code.Player.Character.MovementSystems.Character {
1039
1032
  .1f);
1040
1033
  }
1041
1034
 
1042
- if (Physics.Raycast(projectedPosition + new Vector3(0, -.5f, 0), -normalizedVel,
1035
+ if (Physics.Raycast(projectedPosition + new Vector3(0, -.25f, 0), -normalizedVel,
1043
1036
  out var cliffHit, distanceCheck,
1044
1037
  movementSettings.groundCollisionLayerMask, QueryTriggerInteraction.Ignore)) {
1045
1038
 
@@ -1048,54 +1041,35 @@ namespace Code.Player.Character.MovementSystems.Character {
1048
1041
  }
1049
1042
 
1050
1043
  //Stop movement into this surface
1051
- var colliderDot = 1 - Mathf.Max(0,
1052
- -Vector3.Dot(-cliffHit.normal, normalizedVel));
1053
- colliderDot *= .8f;
1044
+ // var colliderDot = 1 - Mathf.Max(0,
1045
+ // -Vector3.Dot(-cliffHit.normal, newVelocity));
1046
+ var colliderDot = Vector3.Dot(newVelocity, -cliffHit.normal);
1047
+ //colliderDot *= .9f;
1054
1048
  //var colliderDot = 1 - -Vector3.Dot(forwardHit.normal, forwardVector);
1055
- if (Mathf.Abs(colliderDot) < .01f || normalizedVel.sqrMagnitude < 1f) {
1056
- colliderDot = 0;
1057
- }
1058
-
1059
- colliderDot = 0;
1049
+ // if (Mathf.Abs(colliderDot) < .01f || normalizedVel.sqrMagnitude < 1f) {
1050
+ // colliderDot = 0;
1051
+ // }
1060
1052
  var flatPoint = new Vector3(cliffHit.point.x, transform.position.y, cliffHit.point.z);
1061
- if (Vector3.Distance(flatPoint, transform.position) < bumpSize - forwardMargin) {
1053
+ //If we are too close to the edge or if there is an obstruction in the way
1054
+ if (Vector3.Distance(flatPoint, transform.position) < bumpSize - forwardMargin
1055
+ || Physics.Raycast(transform.position + new Vector3(0,.25f, 0), newVelocity, distanceCheck, movementSettings.groundCollisionLayerMask)) {
1062
1056
  //Snap back to the bump distance so you never inch your way to the edge
1063
1057
  //newVelocity = new Vector3(0, newVelocity.y, 0);
1064
1058
  //var newPos = cliffHit.point - normalizedVel * (bumpSize-forwardMargin);
1065
1059
  //transform.position = new Vector3(newPos.x, transform.position.y, newPos.z);
1066
-
1060
+
1067
1061
  newVelocity = -normalizedVel;
1068
1062
  } else {
1069
- //limit movement dir based on how straight you are walking into the wall
1063
+ //limit movement dir based on how straight you are walking into the edge
1070
1064
  characterMoveVelocity = Vector3.ProjectOnPlane(characterMoveVelocity, -cliffHit.normal);
1071
1065
  characterMoveVelocity.y = 0;
1072
1066
  characterMoveVelocity *= colliderDot;
1073
1067
  normalizedMoveDir = characterMoveVelocity.normalized;
1074
1068
 
1075
- newVelocity = Vector3.ProjectOnPlane(newVelocity, -cliffHit.normal);
1076
- newVelocity *= colliderDot;
1069
+ newVelocity -= colliderDot * -cliffHit.normal;
1070
+ //newVelocity *= colliderDot;
1077
1071
  }
1078
1072
  }
1079
- // Determine which direction we're mainly moving toward
1080
- // var xFirst = Math.Abs(command.moveDir.x) > Math.Abs(command.moveDir.z);
1081
- // Vector3[] vecArr = { new(command.moveDir.x, 0, 0), new(0, 0, command.moveDir.z) };
1082
- // for (var i = 0; i < 2; i++) {
1083
- // // We will try x dir first if x magnitude is greater
1084
- // var index = (xFirst ? i : i + 1) % 2;
1085
- // var safeDirection = vecArr[index];
1086
- // var stepPosition = rootPosition + safeDirection.normalized * 0.2f;
1087
- // (foundGroundedDir, _, _) =
1088
- // physics.CheckIfGrounded(stepPosition, newVelocity, normalizedMoveDir);
1089
- // if (foundGroundedDir) {
1090
- // characterMoveVelocity = safeDirection;
1091
- // break;
1092
- // }
1093
- // }
1094
-
1095
- // Only if we didn't find a safe direction set move to 0
1096
- // if (!foundGroundedDir) {
1097
- // characterMoveVelocity = Vector3.zero;
1098
- // }
1099
1073
  }
1100
1074
  }
1101
1075
 
@@ -1591,7 +1565,7 @@ namespace Code.Player.Character.MovementSystems.Character {
1591
1565
 
1592
1566
  // TS listens to this to update the local camera.
1593
1567
  // Position will update from reconcile, but we handle look direction manually.
1594
- if (mode == NetworkedStateSystemMode.Authority && isServer) {
1568
+ if (mode == NetworkedStateSystemMode.Authority && isServer && !this.manager.serverGeneratesCommands) {
1595
1569
  RpcSetLookVector(lookVector);
1596
1570
  }
1597
1571
 
@@ -1654,14 +1628,6 @@ namespace Code.Player.Character.MovementSystems.Character {
1654
1628
  return physics.ignoredColliders.ContainsKey(collider.GetInstanceID());
1655
1629
  }
1656
1630
 
1657
- public float GetTimeSinceWasGrounded() {
1658
- return currentMoveSnapshot.timeSinceWasGrounded;
1659
- }
1660
-
1661
- public float GetTimeSinceBecameGrounded() {
1662
- return currentMoveSnapshot.timeSinceBecameGrounded;
1663
- }
1664
-
1665
1631
  public void SetVelocity(Vector3 velocity) {
1666
1632
  if (mode == NetworkedStateSystemMode.Observer && isServer) {
1667
1633
  RpcVelocity(velocity);
@@ -27,9 +27,8 @@ namespace Code.Player.Character.MovementSystems.Character
27
27
  public float speedModifier = 1; // Not used yet
28
28
  public byte jumpCount;
29
29
  public CharacterState state = CharacterState.Idle;
30
- public float timeSinceBecameGrounded;
31
- public float timeSinceWasGrounded;
32
- public float timeSinceJump;
30
+ // > 0 means it is possible to jump. Value is the number of ticks they have left until they can no longer jump. byte.MaxValue when grounded.
31
+ public byte canJump;
33
32
 
34
33
  public BinaryBlob customData;
35
34
 
@@ -50,36 +49,69 @@ namespace Code.Player.Character.MovementSystems.Character
50
49
 
51
50
  string message = "";
52
51
 
53
- if (this.lastProcessedCommand != other.lastProcessedCommand)
52
+ var lastProcessedCommandEqual = this.lastProcessedCommand == other.lastProcessedCommand;
53
+ var positionEqual = this.position == other.position;
54
+ var velocityEqual = this.velocity == other.velocity;
55
+ var currentSpeedEqual = CharacterSnapshotDataSerializer.CompressToShort(this.currentSpeed) == CharacterSnapshotDataSerializer.CompressToShort(other.currentSpeed);
56
+ var speedModifierEqual = CharacterSnapshotDataSerializer.CompressToShort(this.speedModifier) == CharacterSnapshotDataSerializer.CompressToShort(other.speedModifier);
57
+ var inputDisabledEqual = inputDisabled == other.inputDisabled;
58
+ var isFlyingEqual = isFlying == other.isFlying;
59
+ var isSprintingEqual = isSprinting == other.isSprinting;
60
+ var jumpCountEqual = jumpCount == other.jumpCount;
61
+ var airborneFromImpulseEqual = airborneFromImpulse == other.airborneFromImpulse;
62
+ var alreadyJumpedEqual = alreadyJumped == other.alreadyJumped;
63
+ var isCrouchingEqual = isCrouching == other.isCrouching;
64
+ var prevStepUpEqual = prevStepUp == other.prevStepUp;
65
+ var isGroundedEqual = isGrounded == other.isGrounded;
66
+ var stateEqual = state == other.state;
67
+
68
+ if (!lastProcessedCommandEqual)
54
69
  message += $"lastProcessedCommand: {this.lastProcessedCommand} != {other.lastProcessedCommand}\n";
55
- if (this.position != other.position) message += $"position: {this.position} != {other.position}\n";
56
- if (this.velocity != other.velocity) message += $"velocity: {this.velocity} != {other.velocity}\n";
57
- if (this.currentSpeed != other.currentSpeed) message += $"currentSpeed: {this.currentSpeed} != {other.currentSpeed}\n";
58
- if (this.speedModifier != other.speedModifier)
59
- message += $"speedModifier: {this.speedModifier} != {other.speedModifier}";
60
- if (inputDisabled != other.inputDisabled)
70
+ if (!positionEqual)
71
+ message += $"position: {this.position} != {other.position}\n";
72
+ if (!velocityEqual)
73
+ message += $"velocity: {this.velocity} != {other.velocity}\n";
74
+ if (!currentSpeedEqual)
75
+ message += $"currentSpeed: {this.currentSpeed} != {other.currentSpeed}\n";
76
+ if (!speedModifierEqual)
77
+ message += $"speedModifier: {this.speedModifier} != {other.speedModifier}\n";
78
+ if (!inputDisabledEqual)
61
79
  message += $"inputDisabled: {inputDisabled} != {other.inputDisabled}\n";
62
- if (isFlying != other.isFlying) message += $"isFlying: {isFlying} != {other.isFlying}\n";
63
- if (isSprinting != other.isSprinting) message += $"isSprinting: {isSprinting} != {other.isSprinting}\n";
64
- if (jumpCount != other.jumpCount) message += $"jumpCount: {jumpCount} != {other.jumpCount}\n";
65
- if (airborneFromImpulse != other.airborneFromImpulse)
80
+ if (!isFlyingEqual)
81
+ message += $"isFlying: {isFlying} != {other.isFlying}\n";
82
+ if (!isSprintingEqual)
83
+ message += $"isSprinting: {isSprinting} != {other.isSprinting}\n";
84
+ if (!jumpCountEqual)
85
+ message += $"jumpCount: {jumpCount} != {other.jumpCount}\n";
86
+ if (!airborneFromImpulseEqual)
66
87
  message += $"airborneFromImpulse: {airborneFromImpulse} != {other.airborneFromImpulse}\n";
67
- if (alreadyJumped != other.alreadyJumped)
88
+ if (!alreadyJumpedEqual)
68
89
  message += $"alreadyJumped: {alreadyJumped} != {other.alreadyJumped}\n";
69
- if (isCrouching != other.isCrouching) message += $"prevCrouch: {isCrouching} != {other.isCrouching}\n";
70
- if (prevStepUp != other.prevStepUp) message += $"prevStepUp: {prevStepUp} != {other.prevStepUp}\n";
71
- if (isGrounded != other.isGrounded)
90
+ if (!isCrouchingEqual)
91
+ message += $"prevCrouch: {isCrouching} != {other.isCrouching}\n";
92
+ if (!prevStepUpEqual)
93
+ message += $"prevStepUp: {prevStepUp} != {other.prevStepUp}\n";
94
+ if (!isGroundedEqual)
72
95
  message += $"prevGrounded: {isGrounded} != {other.isGrounded}\n";
73
- if (state != other.state) message += $"state: {state} != {other.state}\n";
74
-
75
- var same = this.lastProcessedCommand == other.lastProcessedCommand && this.position == other.position &&
76
- this.velocity == other.velocity && this.currentSpeed == other.currentSpeed && this.speedModifier == other.speedModifier &&
77
- inputDisabled == other.inputDisabled
78
- && isFlying == other.isFlying && isSprinting == other.isSprinting && jumpCount == other.jumpCount &&
79
- airborneFromImpulse == other.airborneFromImpulse &&
80
- alreadyJumped == other.alreadyJumped
81
- && isCrouching == other.isCrouching && prevStepUp == other.prevStepUp &&
82
- isGrounded == other.isGrounded && state == other.state;
96
+ if (!stateEqual)
97
+ message += $"state: {state} != {other.state}\n";
98
+
99
+ var same =
100
+ lastProcessedCommandEqual &&
101
+ positionEqual &&
102
+ velocityEqual &&
103
+ currentSpeedEqual &&
104
+ speedModifierEqual &&
105
+ inputDisabledEqual &&
106
+ isFlyingEqual &&
107
+ isSprintingEqual &&
108
+ jumpCountEqual &&
109
+ airborneFromImpulseEqual &&
110
+ alreadyJumpedEqual &&
111
+ isCrouchingEqual &&
112
+ prevStepUpEqual &&
113
+ isGroundedEqual &&
114
+ stateEqual;
83
115
 
84
116
  if (same)
85
117
  {
@@ -103,9 +135,7 @@ namespace Code.Player.Character.MovementSystems.Character
103
135
  this.velocity = copySnapshot.velocity;
104
136
  this.currentSpeed = copySnapshot.currentSpeed;
105
137
  this.speedModifier = copySnapshot.speedModifier;
106
- this.timeSinceJump = copySnapshot.timeSinceJump;
107
- this.timeSinceWasGrounded = copySnapshot.timeSinceWasGrounded;
108
- this.timeSinceBecameGrounded = copySnapshot.timeSinceBecameGrounded;
138
+ this.canJump = copySnapshot.canJump;
109
139
  this.state = copySnapshot.state;
110
140
  this.isGrounded = copySnapshot.isGrounded;
111
141
  this.prevStepUp = copySnapshot.prevStepUp;
@@ -141,9 +171,7 @@ namespace Code.Player.Character.MovementSystems.Character
141
171
  velocity = velocity,
142
172
  currentSpeed = currentSpeed,
143
173
  speedModifier = speedModifier,
144
- timeSinceJump = timeSinceJump,
145
- timeSinceWasGrounded = timeSinceWasGrounded,
146
- timeSinceBecameGrounded = timeSinceBecameGrounded,
174
+ canJump = canJump,
147
175
  state = state,
148
176
  isGrounded = isGrounded,
149
177
  prevStepUp = prevStepUp,
@@ -165,6 +193,23 @@ namespace Code.Player.Character.MovementSystems.Character
165
193
  }
166
194
 
167
195
  public static class CharacterSnapshotDataSerializer {
196
+
197
+ public static ushort CompressToUshort(float value) {
198
+ return (ushort)Math.Clamp(value * 1000f, 0, ushort.MaxValue);
199
+ }
200
+
201
+ public static short CompressToShort(float value) {
202
+ return (short)Math.Clamp(value * 1000f, short.MinValue, short.MaxValue);
203
+ }
204
+
205
+ public static float DecompressUShort(ushort value) {
206
+ return value / 1000f;
207
+ }
208
+
209
+ public static float DecompressShort(short value) {
210
+ return value / 1000f;
211
+ }
212
+
168
213
  public static void WriteCharacterSnapshotData(this NetworkWriter writer, CharacterSnapshotData value) {
169
214
  byte bools = 0;
170
215
  SetBit(ref bools, 0, value.inputDisabled);
@@ -176,23 +221,26 @@ namespace Code.Player.Character.MovementSystems.Character
176
221
  SetBit(ref bools, 6, value.prevStepUp);
177
222
  SetBit(ref bools, 7, value.isGrounded);
178
223
  writer.Write(bools);
179
-
180
- writer.WriteInt(value.customData.dataSize);
181
- writer.WriteBytes(value.customData.data, 0, value.customData.data.Length);
224
+
225
+ if (value.customData != null) {
226
+ writer.WriteInt(value.customData.dataSize);
227
+ writer.WriteBytes(value.customData.data, 0, value.customData.data.Length);
228
+ }
229
+ else {
230
+ writer.WriteInt(0);
231
+ }
182
232
 
183
233
  writer.Write(value.time);
184
234
  writer.Write(value.lastProcessedCommand);
185
235
  writer.Write(value.position);
186
236
  writer.Write(value.velocity);
187
- writer.Write((short)(value.lookVector.x * 1000f));
188
- writer.Write((short)(value.lookVector.y * 1000f));
189
- writer.Write((short)(value.lookVector.z * 1000f));
237
+ writer.Write(CompressToShort(value.lookVector.x));
238
+ writer.Write(CompressToShort(value.lookVector.y));
239
+ writer.Write(CompressToShort(value.lookVector.z));
190
240
  writer.Write(value.currentSpeed);
191
241
  // This makes our max speed modifier 65.535 with a 0.001 precision.
192
- writer.Write((ushort) Math.Clamp(value.speedModifier * 1000f, 0, ushort.MaxValue));
193
- writer.Write((byte) Math.Min(Math.Floor(value.timeSinceJump / Time.fixedDeltaTime), 255));
194
- writer.Write((byte) Math.Min(Math.Floor(value.timeSinceWasGrounded / Time.fixedDeltaTime), 255));
195
- writer.Write((byte) Math.Min(Math.Floor(value.timeSinceBecameGrounded / Time.fixedDeltaTime), 255));
242
+ writer.Write(CompressToUshort(value.speedModifier));
243
+ writer.Write(value.canJump);
196
244
  writer.Write((byte) value.state);
197
245
  writer.Write(value.jumpCount);
198
246
  }
@@ -200,8 +248,11 @@ namespace Code.Player.Character.MovementSystems.Character
200
248
  public static CharacterSnapshotData ReadCharacterSnapshotData(this NetworkReader reader) {
201
249
  var bools = reader.Read<byte>();
202
250
  var customDataSize = reader.ReadInt();
203
- var customDataArray = reader.ReadBytes(customDataSize);
204
- var customData = new BinaryBlob(customDataArray);
251
+ BinaryBlob customData = default;
252
+ if (customDataSize != 0) {
253
+ var customDataArray = reader.ReadBytes(customDataSize);
254
+ customData = new BinaryBlob(customDataArray);
255
+ }
205
256
  return new CharacterSnapshotData() {
206
257
  inputDisabled = GetBit(bools, 0),
207
258
  isFlying = GetBit(bools, 1),
@@ -211,17 +262,17 @@ namespace Code.Player.Character.MovementSystems.Character
211
262
  isCrouching = GetBit(bools, 5),
212
263
  prevStepUp = GetBit(bools, 6),
213
264
  isGrounded = GetBit(bools, 7),
214
-
215
265
  time = reader.Read<double>(),
216
266
  lastProcessedCommand = reader.Read<int>(),
217
267
  position = reader.Read<Vector3>(),
218
268
  velocity = reader.Read<Vector3>(),
219
- lookVector = new Vector3(reader.Read<short>() / 1000f, reader.Read<short>() / 1000f, reader.Read<short>() / 1000f),
269
+ lookVector = new Vector3(
270
+ DecompressShort(reader.Read<short>()),
271
+ DecompressShort(reader.Read<short>()),
272
+ DecompressShort(reader.Read<short>())),
220
273
  currentSpeed = reader.Read<float>(),
221
- speedModifier = reader.Read<ushort>() / 1000f,
222
- timeSinceJump = reader.Read<byte>() * Time.fixedDeltaTime,
223
- timeSinceWasGrounded = reader.Read<byte>() * Time.fixedDeltaTime,
224
- timeSinceBecameGrounded = reader.Read<byte>() * Time.fixedDeltaTime,
274
+ speedModifier = DecompressUShort(reader.Read<ushort>()),
275
+ canJump = reader.Read<byte>(),
225
276
  state = (CharacterState) reader.Read<byte>(),
226
277
  jumpCount = reader.Read<byte>(),
227
278
  customData = customData,
@@ -675,8 +675,6 @@ namespace Airship.DevConsole
675
675
  _inputField.textComponent.alignment = TextAnchor.MiddleLeft;
676
676
 
677
677
  if (EventSystem.current != null) {
678
- // if (_inputField.isFocused)
679
- print("setting to null");
680
678
  EventSystem.current.SetSelectedGameObject(null);
681
679
  }
682
680
 
@@ -1385,7 +1383,6 @@ namespace Airship.DevConsole
1385
1383
 
1386
1384
  // Force the input field to be focused by the event system
1387
1385
  if (_focusInputField && !Application.isMobilePlatform) {
1388
- Debug.Log("Selecting input field.");
1389
1386
  EventSystem.current.SetSelectedGameObject(_inputField.gameObject);
1390
1387
  _focusInputField = false;
1391
1388
  }
Binary file
@@ -155,7 +155,9 @@ namespace UnityEditor.Build.Pipeline.Tasks
155
155
  {
156
156
  foreach (AssetOutput o in output.AssetResults)
157
157
  {
158
- m_DependencyData.AssetInfo.Add(o.asset, o.assetInfo);
158
+ if (!m_DependencyData.AssetInfo.TryAdd(o.asset, o.assetInfo)) {
159
+ Debug.LogWarning("m_DependencyData already contained asset: " + AssetDatabase.GUIDToAssetPath(o.asset));
160
+ }
159
161
  foreach (var objectDependencyInfo in o.objectDependencyInfo)
160
162
  m_ObjectDependencyData.ObjectDependencyMap[objectDependencyInfo.Object] = objectDependencyInfo.Dependencies;
161
163
  }
@@ -167,7 +169,7 @@ namespace UnityEditor.Build.Pipeline.Tasks
167
169
  ExpandReferences(assetOutput, m_ObjectDependencyData.ObjectDependencyMap);
168
170
  #endif
169
171
 
170
- m_DependencyData.AssetUsage.Add(assetOutput.asset, assetOutput.usageTags);
172
+ m_DependencyData.AssetUsage.TryAdd(assetOutput.asset, assetOutput.usageTags);
171
173
 
172
174
  Dictionary<ObjectIdentifier, System.Type[]> objectTypes = new Dictionary<ObjectIdentifier, Type[]>();
173
175
  foreach (var objectType in assetOutput.objectTypes)
@@ -183,21 +185,21 @@ namespace UnityEditor.Build.Pipeline.Tasks
183
185
  ReferencedObjects = assetOutput.assetInfo.referencedObjects,
184
186
  ObjectTypes = objectTypes
185
187
  };
186
- m_Results.AssetResults.Add(assetOutput.asset, resultData);
188
+ m_Results.AssetResults.TryAdd(assetOutput.asset, resultData);
187
189
  }
188
190
 
189
191
  if (assetOutput.spriteData != null)
190
192
  {
191
193
  if (m_SpriteData == null)
192
194
  m_SpriteData = new BuildSpriteData();
193
- m_SpriteData.ImporterData.Add(assetOutput.asset, assetOutput.spriteData);
195
+ m_SpriteData.ImporterData.TryAdd(assetOutput.asset, assetOutput.spriteData);
194
196
  }
195
197
 
196
198
  if (!m_Parameters.DisableVisibleSubAssetRepresentations && assetOutput.extendedData != null)
197
199
  {
198
200
  if (m_ExtendedAssetData == null)
199
201
  m_ExtendedAssetData = new BuildExtendedAssetData();
200
- m_ExtendedAssetData.ExtendedData.Add(assetOutput.asset, assetOutput.extendedData);
202
+ m_ExtendedAssetData.ExtendedData.TryAdd(assetOutput.asset, assetOutput.extendedData);
201
203
  }
202
204
 
203
205
  if (assetOutput.objectTypes != null)
@@ -1045,7 +1045,9 @@ namespace Mirror
1045
1045
  // the players object for example.
1046
1046
  public static bool Ready()
1047
1047
  {
1048
+ #if AIRSHIP_PLAYER
1048
1049
  Debug.Log($"NetworkClient.Ready() called with active scene: " + SceneManager.GetActiveScene().name);
1050
+ #endif
1049
1051
  if (ready)
1050
1052
  {
1051
1053
  Debug.LogError("NetworkClient is already ready. It shouldn't be called twice.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gg.easy.airship",
3
- "version": "0.1.2140",
3
+ "version": "0.1.2143",
4
4
  "displayName": "Airship",
5
5
  "unity": "2021.3",
6
6
  "unityRelease": "12f1",