public void EnterState(IEntity entity) { if (entity.TryGetComponent(out AppearanceComponent appearance)) { appearance.SetData(DamageStateVisuals.State, DamageState.Dead); } if (entity.TryGetComponent(out ServerStatusEffectsComponent status)) { status.ChangeStatusEffectIcon(StatusEffect.Health, "/Textures/Interface/StatusEffects/Human/humandead.png"); } if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlayComponent)) { overlayComponent.AddOverlay(SharedOverlayID.CircleMaskOverlay); } if (entity.TryGetComponent(out StunnableComponent stun)) { stun.CancelAll(); } StandingStateHelper.Down(entity); if (entity.TryGetComponent(out CollidableComponent collidable)) { collidable.CanCollide = false; } }
public void EnterState(IEntity entity) { if (entity.TryGetComponent(out AppearanceComponent appearance)) { appearance.SetData(DamageStateVisuals.State, DamageState.Critical); } if (entity.TryGetComponent(out ServerStatusEffectsComponent status)) { status.ChangeStatusEffectIcon(StatusEffect.Health, "/Textures/Interface/StatusEffects/Human/humancrit-0.png"); //Todo: combine humancrit-0 and humancrit-1 into a gif and display it } if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlay)) { overlay.AddOverlay(SharedOverlayID.GradientCircleMaskOverlay); } if (entity.TryGetComponent(out StunnableComponent stun)) { stun.CancelAll(); } StandingStateHelper.Down(entity); }
public void EnterState(IEntity entity) { if (entity.TryGetComponent(out StunnableComponent stun)) { stun.CancelAll(); } StandingStateHelper.Down(entity); }
public void EnterState(IEntity entity) { if (entity.TryGetComponent(out StunnableComponent stun)) { stun.CancelAll(); } entity.TryGetComponent(out AppearanceComponent appearanceComponent); appearanceComponent?.SetData(DamageStateVisuals.State, DamageStateVisualData.Crit); StandingStateHelper.Down(entity); }
public void EnterState(IEntity entity) { if (entity.TryGetComponent(out StunnableComponent stun)) { stun.CancelAll(); } StandingStateHelper.Down(entity); if (entity.TryGetComponent(out ICollidableComponent collidable)) { collidable.CanCollide = false; } }
/// <summary> /// Knocks down the mob, making it fall to the ground. /// </summary> /// <param name="seconds">How many seconds the mob will stay on the ground</param> public void Knockdown(float seconds) { seconds = MathF.Min(_knockdownTimer + (seconds * KnockdownTimeModifier), _knockdownCap); if (seconds <= 0f) { return; } StandingStateHelper.Down(Owner); _knockdownTimer = seconds; _lastStun = _gameTiming.CurTime; }
public void EnterState(IEntity entity) { if (entity.TryGetComponent(out StunnableComponent stun)) { stun.CancelAll(); } StandingStateHelper.Down(entity); entity.TryGetComponent(out AppearanceComponent appearanceComponent); appearanceComponent?.SetData(DamageStateVisuals.State, DamageStateVisualData.Dead); if (entity.TryGetComponent(out ICollidableComponent collidable)) { collidable.CanCollide = false; } }
public bool TryUnbuckle(IEntity user, bool force = false) { if (BuckledTo == null) { return(false); } if (!force) { if (!ActionBlockerSystem.CanInteract(user)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't do that!")); return(false); } var strapPosition = Owner.Transform.MapPosition; var range = SharedInteractionSystem.InteractionRange / 2; if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't reach there!")); return(false); } } if (BuckledTo.Owner.TryGetComponent(out StrapComponent strap)) { strap.Remove(this); _entitySystem.GetEntitySystem <AudioSystem>() .PlayFromEntity(strap.UnbuckleSound, Owner); } Owner.Transform.DetachParent(); Owner.Transform.WorldRotation = BuckledTo.Owner.Transform.WorldRotation; BuckledTo = null; if (Owner.TryGetComponent(out AppearanceComponent appearance)) { appearance.SetData(BuckleVisuals.Buckled, false); } if (Owner.TryGetComponent(out StunnableComponent stunnable) && stunnable.KnockedDown) { StandingStateHelper.Down(Owner); }
private void CalculateSpeed() { if (!Owner.TryGetComponent(out MovementSpeedModifierComponent? playerMover)) { return; } float speedSum = 0; foreach (var part in _activeLegs.Keys) { if (!part.HasProperty <LegProperty>()) { _activeLegs.Remove(part); } } foreach (var(key, value) in _activeLegs) { if (key.TryGetProperty(out LegProperty legProperty)) { // Speed of a leg = base speed * (1+log1024(leg length)) speedSum += legProperty.Speed * (1 + (float)Math.Log(value, 1024.0)); } } if (speedSum <= 0.001f || _activeLegs.Count <= 0) { // Case: no way of moving. Fall down. StandingStateHelper.Down(Owner); playerMover.BaseWalkSpeed = 0.8f; playerMover.BaseSprintSpeed = 2.0f; } else { // Case: have at least one leg. Set move speed. StandingStateHelper.Standing(Owner); // Extra legs stack diminishingly. // Final speed = speed sum/(leg count-log4(leg count)) playerMover.BaseWalkSpeed = speedSum / (_activeLegs.Count - (float)Math.Log(_activeLegs.Count, 4.0)); playerMover.BaseSprintSpeed = playerMover.BaseWalkSpeed * 1.75f; } }
#pragma warning restore 649 protected override void OnKnockdown() { StandingStateHelper.Down(Owner); }
private bool TryBuckle(IEntity user, IEntity to) { if (user == null || user == to) { return(false); } if (!ActionBlockerSystem.CanInteract(user)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't do that!")); return(false); } var strapPosition = Owner.Transform.MapPosition; var range = SharedInteractionSystem.InteractionRange / 2; if (!InteractionChecks.InRangeUnobstructed(user, strapPosition, range)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You can't reach there!")); return(false); } if (!user.TryGetComponent(out HandsComponent hands)) { _notifyManager.PopupMessage(user, user, Loc.GetString("You don't have hands!")); return(false); } if (hands.GetActiveHand != null) { _notifyManager.PopupMessage(user, user, Loc.GetString("Your hand isn't free!")); return(false); } if (BuckledTo != null) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You are already buckled in!" : "{0:They} are already buckled in!", Owner)); return(false); } if (!to.TryGetComponent(out StrapComponent strap)) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't buckle yourself there!" : "You can't buckle {0:them} there!", Owner)); return(false); } var parent = to.Transform.Parent; while (parent != null) { if (parent == user.Transform) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't buckle yourself there!" : "You can't buckle {0:them} there!", Owner)); return(false); } parent = parent.Parent; } if (!strap.HasSpace(this)) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't fit there!" : "{0:They} can't fit there!", Owner)); return(false); } _entitySystem.GetEntitySystem <AudioSystem>() .PlayFromEntity(strap.BuckleSound, Owner); if (!strap.TryAdd(this)) { _notifyManager.PopupMessage(Owner, user, Loc.GetString(Owner == user ? "You can't buckle yourself there!" : "You can't buckle {0:them} there!", Owner)); return(false); } BuckledTo = strap; if (Owner.TryGetComponent(out AppearanceComponent appearance)) { appearance.SetData(BuckleVisuals.Buckled, true); } var ownTransform = Owner.Transform; var strapTransform = strap.Owner.Transform; ownTransform.GridPosition = strapTransform.GridPosition; ownTransform.AttachParent(strapTransform); switch (strap.Position) { case StrapPosition.None: ownTransform.WorldRotation = strapTransform.WorldRotation; break; case StrapPosition.Stand: StandingStateHelper.Standing(Owner); ownTransform.WorldRotation = strapTransform.WorldRotation; break; case StrapPosition.Down: StandingStateHelper.Down(Owner); ownTransform.WorldRotation = Angle.South; break; } BuckleStatus(); return(true); }