3 using Microsoft.Xna.Framework;
5 using System.Collections.Generic;
52 protected readonly Dictionary<AnimationType, AnimSwap>
tempAnimations =
new Dictionary<AnimationType, AnimSwap>();
87 return humanAnimController.HumanCrouchParams;
150 anims.Add(humanAnimController.HumanCrouchParams);
161 public enum Animation {
None, Climbing, UsingItem, Struggle, CPR, UsingItemWhileClimbing };
182 if (p ==
null) {
return null; }
183 if (v ==
null) {
return null; }
184 if (!MathUtils.IsValid(v.Value)) {
return null; }
189 if (p ==
null) {
return null; }
207 UpdateTemporaryAnimations();
223 DebugConsole.ThrowError($
"{character.SpeciesName} cannot walk!");
231 DebugConsole.ThrowError($
"{character.SpeciesName} cannot run!");
241 throw new NotImplementedException(type.ToString());
292 return humanAnimController.HumanCrouchParams;
296 DebugConsole.ThrowError($
"Animation params of type {type} not implemented for non-humanoids!");
322 foreach (var limb
in Limbs)
324 if (limb.IsSevered) {
continue; }
325 if (Math.Abs(limb.Params.ConstantTorque) > 0)
329 limb.body.SmoothRotate(
MainLimb.
Rotation + MathHelper.ToRadians(limb.Params.ConstantAngle) *
Dir, limb.Mass * limb.Params.ConstantTorque * movementFactor, wrapAngle:
true);
336 foreach (var limb
in Limbs)
338 if (limb.IsSevered) {
continue; }
339 if (limb.Params.BlinkFrequency <= 0) {
continue; }
340 if (!limb.InWater && limb.Params.OnlyBlinkInWater) {
continue; }
357 if (sqrDist > MathUtils.Pow(ConvertUnits.ToDisplayUnits(
upperArmLength + forearmLength), 2))
365 if (distX > ConvertUnits.ToDisplayUnits(
upperArmLength + forearmLength))
370 Vector2 GetTargetMovement(Vector2
dir)
378 Vector2 handSimPos = ConvertUnits.ToSimUnits(handWorldPos);
385 Vector2 diff = handSimPos - refPos;
386 float dist = diff.Length();
390 handSimPos = refPos + diff / dist * maxDist;
394 if (leftHand !=
null)
396 leftHand.Disabled =
true;
397 leftHand.PullJointEnabled =
true;
398 leftHand.PullJointWorldAnchorB = handSimPos;
402 if (rightHand !=
null)
404 rightHand.Disabled =
true;
405 rightHand.PullJointEnabled =
true;
406 rightHand.PullJointWorldAnchorB = handSimPos;
414 humanoidAnimController.Crouch();
416 humanoidAnimController.ForceSelectAnimationType =
AnimationType.Crouch;
420 public void Grab(Vector2 rightHandPos, Vector2 leftHandPos)
422 for (
int i = 0; i < 2; i++)
435 private readonly Vector2[] transformedHandlePos =
new Vector2[2];
437 public void HoldItem(
float deltaTime,
Item item, Vector2[] handlePos, Vector2 itemPos,
bool aim,
float holdAngle,
float itemAngleRelativeToHoldAngle = 0.0f,
bool aimMelee =
false, Vector2? targetPos =
null)
446 Matrix itemTransform = Matrix.CreateRotationZ(item.
body.
Rotation);
447 transformedHandlePos[0] = Vector2.Transform(handlePos[0], itemTransform);
448 transformedHandlePos[1] = Vector2.Transform(handlePos[1], itemTransform);
455 bool usingController = controller is { AllowAiming:
false };
456 if (!usingController)
459 usingController = controller is { AllowAiming:
false };
464 float torsoRotation = torso.
Rotation;
467 bool equippedInRightHand = rightHandItem == item && rightHand is { IsSevered:
false };
469 bool equippedInLeftHand = leftHandItem == item && leftHand is { IsSevered:
false };
474 Vector2 diff = holdable.
Aimable ?
476 MathUtils.RotatePoint(Vector2.UnitX, torsoRotation);
478 holdAngle = MathUtils.VectorToAngle(
new Vector2(diff.X, diff.Y *
Dir)) - torsoRotation *
Dir;
479 holdAngle += GetAimWobble(rightHand, leftHand, item);
480 itemAngle = torsoRotation + holdAngle *
Dir;
485 bool anotherItemControlsPose = equippedInLeftHand && rightHandItem != item && (rightHandItem?.GetComponent<
Holdable>()?.ControlPose ??
false);
498 if (equippedInRightHand)
502 else if (equippedInLeftHand)
508 itemAngle = torsoRotation + holdAngle *
Dir;
513 itemAngle = torsoRotation + holdAngle *
Dir;
519 if (itemPos == Vector2.Zero || isClimbing || usingController)
521 if (equippedInRightHand)
524 itemAngle = rightHand.
Rotation + (holdAngle - rightHand.
Params.GetSpriteOrientation() + MathHelper.PiOver2) *
Dir;
526 else if (equippedInLeftHand)
529 itemAngle = leftHand.
Rotation + (holdAngle - leftHand.
Params.GetSpriteOrientation() + MathHelper.PiOver2) *
Dir;
534 if (equippedInRightHand)
539 if (equippedInLeftHand)
541 if (leftShoulder ==
null) {
return; }
546 transformedHoldPos += Vector2.Transform(itemPos, Matrix.CreateRotationZ(itemAngle));
551 Vector2 currItemPos = equippedInRightHand ?
555 if (!MathUtils.IsValid(currItemPos))
557 string errorMsg =
"Attempted to move the item \"" + item +
"\" to an invalid position in HumanidAnimController.HoldItem: " +
559 ", handlePos[0]: " + handlePos[0] +
", handlePos[1]: " + handlePos[1] +
560 ", transformedHandlePos[0]: " + transformedHandlePos[0] +
", transformedHandlePos[1]:" + transformedHandlePos[1] +
561 ", item pos: " + item.
SimPosition +
", itemAngle: " + itemAngle +
563 DebugConsole.Log(errorMsg);
564 GameAnalyticsManager.AddErrorEventOnce(
566 GameAnalyticsManager.ErrorSeverity.Error,
572 float targetAngle = MathUtils.WrapAngleTwoPi(itemAngle + itemAngleRelativeToHoldAngle *
Dir);
573 float currentRotation = MathUtils.WrapAngleTwoPi(item.
body.
Rotation);
574 float itemRotation = MathHelper.SmoothStep(currentRotation, targetAngle, deltaTime * 25);
575 if (previousDirection !=
dir || Math.Abs(targetAngle - currentRotation) > MathHelper.Pi)
577 itemRotation = targetAngle;
579 item.
SetTransform(currItemPos, itemRotation, setPrevTransform:
false);
580 previousDirection =
dir;
582 if (holdable.
Pusher !=
null)
607 for (
int i = 0; i < 2; i++)
611 if (handlePos[i].LengthSquared() >
ArmLength)
613 DebugConsole.AddWarning($
"Aim position for the item {item.Name} may be incorrect (further than the length of the character's arm)",
618 i == 0 ? rightHand : leftHand, transformedHoldPos + transformedHandlePos[i],
621 maxAngularVelocity: 15.0f);
626 private float GetAimWobble(
Limb rightHand,
Limb leftHand,
Item heldItem)
628 float wobbleStrength = 0.0f;
637 if (wobbleStrength <= 0.1f) {
return 0.0f; }
638 wobbleStrength = (float)Math.Min(wobbleStrength, 1.0f);
640 float lowFreqNoise = PerlinNoise.GetPerlin((
float)Timing.TotalTime / 320.0f, (float)Timing.TotalTime / 240.0f) - 0.5f;
641 float highFreqNoise = PerlinNoise.GetPerlin((
float)Timing.TotalTime / 40.0f, (float)Timing.TotalTime / 50.0f) - 0.5f;
643 return (lowFreqNoise * 1.0f + highFreqNoise * 0.1f) * wobbleStrength;
646 public void HandIK(
Limb hand, Vector2 pos,
float armTorque = 1.0f,
float handTorque = 1.0f,
float maxAngularVelocity =
float.PositiveInfinity)
653 if (leftShoulder ==
null) {
return; }
667 if (arm ==
null) {
return; }
670 float c = Vector2.Distance(pos, shoulderPos);
673 float armAngle = MathUtils.VectorToAngle(pos - shoulderPos) + arm.
Params.GetSpriteOrientation() - MathHelper.PiOver2;
674 float upperArmAngle = MathUtils.SolveTriangleSSS(forearmLength,
upperArmLength, c) *
Dir;
675 float lowerArmAngle = MathUtils.SolveTriangleSSS(
upperArmLength, forearmLength, c) *
Dir;
678 while (arm.
Rotation - armAngle > MathHelper.Pi)
680 armAngle += MathHelper.TwoPi;
682 while (arm.
Rotation - armAngle < -MathHelper.Pi)
684 armAngle -= MathHelper.TwoPi;
689 arm.
body.
SmoothRotate(armAngle - upperArmAngle, 100.0f * armTorque * arm.
Mass, wrapAngle:
false);
691 float forearmAngle = armAngle + lowerArmAngle;
698 float handAngle = forearm !=
null ? forearmAngle : armAngle;
703 private float prevFootPos;
712 else if (ladder ==
null)
727 tempTargetMovement.Y = Math.Clamp(tempTargetMovement.Y, slide ? -animParams.SlideSpeed : -maxClimbingSpeed, maxClimbingSpeed);
739 Vector2 ladderSimPos = ConvertUnits.ToSimUnits(
740 ladder.Item.Rect.X + ladder.Item.Rect.Width / 2.0f,
743 Vector2 ladderSimSize = ConvertUnits.ToSimUnits(ladder.Item.Rect.Size.ToVector2());
745 var lowestNearbyLadder = GetLowestNearbyLadder(ladder);
746 if (lowestNearbyLadder !=
null && lowestNearbyLadder != ladder)
748 ladderSimSize.Y = ConvertUnits.ToSimUnits(ladder.Item.WorldRect.Y - (lowestNearbyLadder.Item.WorldRect.Y - lowestNearbyLadder.Item.Rect.Size.Y));
751 float stepHeight = ConvertUnits.ToSimUnits(animParams.ClimbStepHeight);
755 ladderSimPos += ladder.Item.Submarine.SimPosition;
768 float bodyMoveForce = animParams.ClimbBodyMoveForce;
771 MoveLimb(torso,
new Vector2(ladderSimPos.X - 0.35f *
Dir, bottomPos + torsoPos), bodyMoveForce);
776 MoveLimb(head,
new Vector2(ladderSimPos.X - 0.2f *
Dir, bottomPos + headPos), bodyMoveForce);
781 Vector2 handPos =
new Vector2(
783 bottomPos + torsoPos +
movement.Y * 0.1f - ladderSimPos.Y);
784 if (climbFast) { handPos.Y -= stepHeight; }
786 float handMoveForce = animParams.ClimbHandMoveForce;
789 handPos.Y = Math.Min(-0.5f, handPos.Y);
792 if (rightHand !=
null)
795 new Vector2(slide ? handPos.X + ladderSimSize.X * 0.75f : handPos.X,
796 (slide ? handPos.Y + stepHeight : MathUtils.Round(handPos.Y, stepHeight * 2.0f)) + ladderSimPos.Y),
803 if (leftHand !=
null)
806 new Vector2(handPos.X - ladderSimSize.X * (slide ? 1.0f : 0.5f),
807 (slide ? handPos.Y + stepHeight : MathUtils.Round(handPos.Y - stepHeight, stepHeight * 2.0f) + stepHeight) + ladderSimPos.Y),
813 float stepHeightAdjustment = stepHeight * 2.7f;
814 Vector2 footPos =
new Vector2(
815 handPos.X -
Dir * 0.05f,
817 if (climbFast) { footPos.Y += stepHeight; }
825 if (footPos.Y > -ladderSimSize.Y - 0.2f && leftFoot !=
null && rightFoot !=
null && leftLeg !=
null && rightLeg !=
null)
830 float footMoveForce = animParams.ClimbFootMoveForce;
833 if (!leftLegBackwards) {
MoveLimb(leftFoot,
new Vector2(footPos.X - ladderSimSize.X * 0.5f, footPos.Y + ladderSimPos.Y), footMoveForce, pullFromCenter:
true); }
834 if (!rightLegBackwards) {
MoveLimb(rightFoot,
new Vector2(footPos.X, footPos.Y + ladderSimPos.Y), footMoveForce, pullFromCenter:
true); }
838 float leftFootPos = MathUtils.Round(footPos.Y + stepHeight, stepHeight * 2.0f) - stepHeight;
839 float prevLeftFootPos = MathUtils.Round(prevFootPos + stepHeight, stepHeight * 2.0f) - stepHeight;
840 if (!leftLegBackwards) {
MoveLimb(leftFoot,
new Vector2(footPos.X, leftFootPos + ladderSimPos.Y), footMoveForce, pullFromCenter:
true); }
842 float rightFootPos = MathUtils.Round(footPos.Y, stepHeight * 2.0f);
843 float prevRightFootPos = MathUtils.Round(prevFootPos, stepHeight * 2.0f);
844 if (!rightLegBackwards) {
MoveLimb(rightFoot,
new Vector2(footPos.X, rightFootPos + ladderSimPos.Y), footMoveForce, pullFromCenter:
true); }
846 if (Math.Abs(leftFootPos - prevLeftFootPos) > stepHeight && leftFoot.LastImpactSoundTime < Timing.TotalTime -
Limb.
SoundInterval)
849 leftFoot.LastImpactSoundTime = (float)Timing.TotalTime;
851 if (Math.Abs(rightFootPos - prevRightFootPos) > stepHeight && rightFoot.LastImpactSoundTime < Timing.TotalTime -
Limb.
SoundInterval)
854 rightFoot.LastImpactSoundTime = (float)Timing.TotalTime;
857 prevFootPos = footPos.Y;
864 float movementFactor = (handPos.Y / stepHeight) * (
float)Math.PI;
865 movementFactor = 0.8f + (float)Math.Abs(Math.Sin(movementFactor));
868 ? Vector2.Zero : ladder.Item.
Submarine.Velocity;
871 Vector2 climbForce =
new Vector2(0.0f,
movement.Y) * movementFactor;
873 if (!
InWater) { climbForce.Y += 0.3f * movementFactor; }
879 !
floorFixture.CollisionCategories.HasFlag(Physics.CollisionStairs) &&
880 !
floorFixture.CollisionCategories.HasFlag(Physics.CollisionPlatform) &&
883 climbForce.Y = MathHelper.Clamp((standOnFloorY + minHeightFromFloor -
character.
SimPosition.Y) * 5.0f, climbForce.Y, 1.0f);
899 float targetRotation = MathHelper.WrapAngle(MathUtils.VectorToAngle(diff) - MathHelper.PiOver4 *
Dir);
905 head.
body.
SmoothRotate(MathHelper.PiOver4 * movementMultiplier *
Dir, force: animParams.HeadTorque);
909 if (ladder.Item.Prefab.Triggers.None())
915 Rectangle trigger = ladder.Item.Prefab.Triggers.FirstOrDefault();
916 trigger = ladder.Item.TransformTrigger(trigger);
918 bool isRemote =
false;
919 bool isClimbing =
true;
945 Ladder GetLowestNearbyLadder(
Ladder currentLadder,
float threshold = 16.0f)
964 return GetLimb(limbType, useSecondaryType:
true) ??
GetLimb(limbType, excludeLimbsWithSecondaryType:
true);
977 float rot = MathUtils.VectorToAngle(
dir);
979 if (neckJoint !=
null)
982 float lowerLimit = neckJoint.LowerLimit + offset;
983 float upperLimit = neckJoint.UpperLimit + offset;
984 float min = Math.Min(lowerLimit, upperLimit);
985 float max = Math.Max(lowerLimit, upperLimit);
986 rot = Math.Clamp(rot, min, max);
991 public void ApplyPose(Vector2 leftHandPos, Vector2 rightHandPos, Vector2 leftFootPos, Vector2 rightFootPos,
float footMoveForce = 10)
996 if (waist ==
null) {
return; }
997 Vector2 midPos = waist.SimPosition;
998 if (leftHand !=
null)
1000 leftHand.Disabled =
true;
1001 leftHandPos.X *=
Dir;
1002 leftHandPos += midPos;
1003 HandIK(leftHand, leftHandPos);
1005 if (rightHand !=
null)
1007 rightHand.Disabled =
true;
1008 rightHandPos.X *=
Dir;
1009 rightHandPos += midPos;
1010 HandIK(rightHand, rightHandPos);
1013 if (leftFoot !=
null)
1015 leftFoot.Disabled =
true;
1016 leftFootPos =
new Vector2(waist.SimPosition.X + leftFootPos.X *
Dir,
GetColliderBottom().Y + leftFootPos.Y);
1017 MoveLimb(leftFoot, leftFootPos, Math.Abs(leftFoot.SimPosition.X - leftFootPos.X) * footMoveForce * leftFoot.Mass,
true);
1020 if (rightFoot !=
null)
1022 rightFoot.Disabled =
true;
1023 rightFootPos =
new Vector2(waist.SimPosition.X + rightFootPos.X *
Dir,
GetColliderBottom().Y + rightFootPos.Y);
1024 MoveLimb(rightFoot, rightFootPos, Math.Abs(rightFoot.SimPosition.X - rightFootPos.X) * footMoveForce * rightFoot.Mass,
true);
1034 new Vector2(-0.75f, -0.2f),
1035 new Vector2(0.75f, -0.2f),
1046 if (rightHand ==
null) {
return; }
1051 Vector2 localAnchorShoulder = Vector2.Zero;
1052 Vector2 localAnchorElbow = Vector2.Zero;
1057 LimbJoint rightElbow = rightForearm ==
null ?
1060 if (rightElbow !=
null)
1064 upperArmLength = Vector2.Distance(localAnchorShoulder, localAnchorElbow);
1065 if (rightElbow !=
null)
1067 if (rightForearm ==
null)
1069 forearmLength = Vector2.Distance(
1076 if (rightWrist !=
null)
1078 forearmLength = Vector2.Distance(
1082 forearmLength += Vector2.Distance(
1093 (lj.LimbA.type == limbTypeA && lj.LimbB.type == limbTypeB) ||
1094 (lj.LimbB.type == limbTypeA && lj.LimbA.type == limbTypeB));
1100 lj.LimbA.type == matchingType && ignoredTypes.None(t => lj.LimbB.type == t) ||
1101 lj.LimbB.type == matchingType && ignoredTypes.None(t => lj.LimbB.type == t));
1106 base.Recreate(ragdollParams);
1120 private void StartAnimation(
Animation animation)
1126 else if (animation ==
Animation.Climbing)
1136 private void StopAnimation(
Animation animation)
1142 else if (animation ==
Animation.Climbing)
1160 private readonly Dictionary<AnimationType, AnimationParams> defaultAnimations =
new Dictionary<AnimationType, AnimationParams>();
1171 if (animLoadInfo.File.TryGet(out
string fileName) && animSwap.TemporaryAnimation.FileNameWithoutExtension.Equals(fileName, StringComparison.OrdinalIgnoreCase))
1174 animSwap.IsActive =
true;
1177 else if (animLoadInfo.File.TryGet(out
ContentPath contentPath) && animSwap.TemporaryAnimation.Path == contentPath)
1180 animSwap.IsActive =
true;
1185 if (animSwap.Priority >= animLoadInfo.Priority)
1199 if (defaultAnimation ==
null) {
return false; }
1202 defaultAnimations.TryAdd(animType, defaultAnimation);
1207 private void UpdateTemporaryAnimations()
1212 if (!animSwap.IsActive)
1214 if (defaultAnimations.TryGetValue(animSwap.AnimationType, out AnimationParams defaultAnimation))
1221 DebugConsole.ThrowError($
"[AnimController] Failed to find the default animation parameters of type {animSwap.AnimationType}. Cannot swap back the default animations!");
1234 animSwap.IsActive =
false;
1246 switch (animationType)
1250 animParams = humanAnimController.WalkParams;
1254 animParams = humanAnimController.RunParams;
1258 animParams = humanAnimController.HumanCrouchParams;
1262 animParams = humanAnimController.SwimSlowParams;
1266 animParams = humanAnimController.SwimFastParams;
1269 DebugConsole.ThrowError($
"[AnimController] Animation of type {animationType} not implemented!");
1275 switch (animationType)
1300 DebugConsole.ThrowError($
"[AnimController] Animation of type {animationType} not implemented!");
1305 bool success = animParams !=
null;
1306 if (!file.TryGet(out
string fileName))
1310 fileName = contentPath.Value;
1313 success = contentPath == animParams.
Path;
1321 success = animParams.FileNameWithoutExtension.
Equals(fileName, StringComparison.OrdinalIgnoreCase);
1326 DebugConsole.NewMessage($
"Animation {fileName} successfully loaded for {character.DisplayName}", Color.LightGreen, debugOnly:
true);
1328 else if (throwErrors)
1330 DebugConsole.ThrowError($
"Animation {fileName} for {character.DisplayName} could not be loaded!");
1343 switch (animationType)
1348 humanAnimController.WalkParams = newWalkParams;
1354 humanAnimController.HumanRunParams = newRunParams;
1360 humanAnimController.HumanCrouchParams = newCrouchParams;
1366 humanAnimController.HumanSwimSlowParams = newSwimSlowParams;
1372 humanAnimController.HumanSwimFastParams = newSwimFastParams;
1376 DebugConsole.ThrowError($
"[AnimController] Animation of type {animationType} not implemented!");
1382 switch (animationType)
1409 DebugConsole.ThrowError($
"[AnimController] Animation of type {animationType} not implemented!");
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
static readonly Identifier DamageType
readonly AnimationType AnimationType
AnimSwap(AnimationParams temporaryAnimation, float priority)
readonly AnimationParams TemporaryAnimation
List< AnimationParams > AllAnimParams
Note: creates a new list every time, because the params might have changed. If there is a need to acc...
void CalculateArmLengths()
void HandIK(Limb hand, Vector2 pos, float armTorque=1.0f, float handTorque=1.0f, float maxAngularVelocity=float.PositiveInfinity)
AnimationType ForceSelectAnimationType
abstract void UpdateAnim(float deltaTime)
Vector2? GetValidOrNull(AnimationParams p, Vector2 v)
override? float HeadPosition
float? GetValidOrNull(AnimationParams p, float? v)
virtual ? Vector2 StepSize
float GetCurrentSpeed(bool useMaxSpeed)
override void Recreate(RagdollParams ragdollParams=null)
Call this to create the ragdoll from the RagdollParams.
AnimationParams? CurrentAnimationParams
override? float TorsoAngle
GroundedMovementParams? CurrentGroundedParams
abstract void DragCharacter(Character target, float deltaTime)
readonly Dictionary< AnimationType, AnimSwap > tempAnimations
SwimParams? CurrentSwimParams
abstract SwimParams SwimFastParams
bool TrySwapAnimParams(AnimationParams newParams)
Simply swaps existing animation parameters as current parameters.
void UpdateBlink(float deltaTime)
void UpdateAnimations(float deltaTime)
void UpdateConstantTorque(float deltaTime)
readonly HashSet< AnimationType > expiredAnimations
abstract GroundedMovementParams RunParams
bool TryLoadAnimation(AnimationType animationType, Either< string, ContentPath > file, out AnimationParams animParams, bool throwErrors)
Loads animations. Non-permanent (= resets on load).
float GetHeightFromFloor()
AnimationParams GetAnimationParamsFromType(AnimationType type)
bool? IsMovingFast
Note: Presupposes that the slow speed is lower than the high speed. Otherwise will give invalid resul...
Vector2 AimSourceWorldPos
void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 itemPos, bool aim, float holdAngle, float itemAngleRelativeToHoldAngle=0.0f, bool aimMelee=false, Vector2? targetPos=null)
bool TryLoadTemporaryAnimation(StatusEffect.AnimLoadInfo animLoadInfo, bool throwErrors)
Loads an animation (variation) that automatically resets in 0.1s, unless triggered again....
LimbJoint GetJoint(LimbType matchingType, IEnumerable< LimbType > ignoredTypes)
AnimController(Character character, string seed, RagdollParams ragdollParams=null)
virtual Vector2 AimSourceSimPos
void RecreateAndRespawn(RagdollParams ragdollParams=null)
void RotateHead(Limb head)
LimbJoint GetJointBetweenLimbs(LimbType limbTypeA, LimbType limbTypeB)
override? float TorsoPosition
void UpdateUseItem(bool allowMovement, Vector2 handWorldPos)
void LockFlipping(float time=0.2f)
abstract GroundedMovementParams WalkParams
override? float HeadAngle
abstract SwimParams SwimSlowParams
void ApplyPose(Vector2 leftHandPos, Vector2 rightHandPos, Vector2 leftFootPos, Vector2 rightFootPos, float footMoveForce=10)
virtual float GetSpeed(AnimationType type)
void Grab(Vector2 rightHandPos, Vector2 leftHandPos)
virtual AnimationType AnimationType
float GetLimbDamage(Limb limb, Identifier afflictionType)
readonly CharacterParams Params
CharacterHealth CharacterHealth
bool IsRemotelyControlled
Is the character controlled remotely (either by another player, or a server-side AIController)
override Vector2? SimPosition
Item????????? SelectedItem
The primary selected item. It can be any device that character interacts with. This excludes items li...
Vector2 SmoothedCursorPosition
float SpeedMultiplier
Can be used to modify the character's speed via StatusEffects
CharacterInventory Inventory
Item SelectedSecondaryItem
The secondary selected item. It's an item other than a device (see SelectedItem), e....
bool IsKeyDown(InputType inputType)
void ReleaseSecondaryItem()
readonly AnimController AnimController
void TeleportTo(Vector2 worldPos)
Item GetItemInLimbSlot(InvSlotType limbSlot)
bool IsInLimbSlot(Item item, InvSlotType limbSlot)
bool Equals(ContentPath other)
virtual Vector2 WorldPosition
static FishRunParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static FishSwimFastParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static FishSwimSlowParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static FishWalkParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static NetworkMember NetworkMember
float BackwardsMovementMultiplier
static HumanCrouchParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanRunParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanSwimFastParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanSwimSlowParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
static HumanWalkParams GetAnimParams(Character character, Either< string, ContentPath > file, bool throwErrors=true)
override Vector2? SimPosition
void SetTransform(Vector2 simPosition, float rotation, bool findNewHull=true, bool setPrevTransform=true)
bool IsInteractable(Character character)
Returns interactibility based on whether the character is on a player team
override string Name
Note that this is not a LocalizedString instance, just the current name of the item as a string....
bool UseHandRotationForHoldAngle
static List< Ladder > List
readonly LimbParams Params
Vector2 PullJointWorldAnchorB
Vector2 PullJointWorldAnchorA
const float SoundInterval
Vector2 PullJointLocalAnchorA
void ApplyTorque(float torque)
void MoveToTargetPosition(bool lerp=true)
void ApplyForce(Vector2 force, float maxVelocity=NetConfig.MaxPhysicsBodyVelocity)
bool SetTransform(Vector2 simPosition, float rotation, bool setPrevTransform=true)
void MoveToPos(Vector2 simPosition, float force, Vector2? pullPos=null)
void SmoothRotate(float targetRotation, float force=10.0f, bool wrapAngle=true)
Rotate the body towards the target rotation in the "shortest direction", taking into account the curr...
ContentPackage? ContentPackage
Vector2 GetColliderBottom()
Limb GetLimb(LimbType limbType, bool excludeSevered=true, bool excludeLimbsWithSecondaryType=false, bool useSecondaryType=false)
Note that if there are multiple limbs of the same type, only the first (valid) limb is returned.
readonly Character character
float ColliderHeightFromFloor
In sim units. Joint scale applied.
bool HasMultipleLimbsOfSameType
void MoveLimb(Limb limb, Vector2 pos, float amount, bool pullFromCenter=false)
if false, force is applied to the position of pullJoint
StatusEffects can be used to execute various kinds of effects: modifying the state of some entity in ...
readonly record struct AnimLoadInfo(AnimationType Type, Either< string, ContentPath > File, float Priority, ImmutableArray< Identifier > ExpectedSpeciesNames)
Submarine(SubmarineInfo info, bool showErrorMessages=true, Func< Submarine, List< MapEntity >> loadEntities=null, IdRemap linkedRemap=null)
override Vector2 SimPosition
override Vector2? Position