/// <summary> /// Give the user the rider component if they're buckling to the vehicle, /// otherwise remove it. /// </summary> private void OnBuckleChange(EntityUid uid, VehicleComponent component, BuckleChangeEvent args) { // Send an event that our vehicle buckle changed if (TryComp <MindComponent>(args.BuckledEntity, out var mind) && mind.Mind != null && mind.Mind.TryGetSession(out var session)) { RaiseNetworkEvent(new BuckledToVehicleEvent(uid, args.BuckledEntity, args.Buckling), Filter.SinglePlayer(session)); } if (args.Buckling) { // Add a virtual item to rider's hand, unbuckle if we can't. if (!_virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.BuckledEntity)) { _riderSystem.UnbuckleFromVehicle(args.BuckledEntity); return; } // Set up the rider and vehicle with each other EnsureComp <SharedPlayerInputMoverComponent>(uid); var rider = EnsureComp <RiderComponent>(args.BuckledEntity); component.Rider = args.BuckledEntity; rider.Vehicle = component; component.HasRider = true; // Handle pulling RemComp <SharedPullableComponent>(args.BuckledEntity); RemComp <SharedPullableComponent>(uid); // Let this open doors if it has the key in it if (component.HasKey) { _tagSystem.AddTag(uid, "DoorBumpOpener"); } // Update appearance stuff, add actions UpdateBuckleOffset(Transform(uid), component); UpdateDrawDepth(uid, GetDrawDepth(Transform(uid), component.NorthOnly)); if (TryComp <ActionsComponent>(args.BuckledEntity, out var actions) && TryComp <UnpoweredFlashlightComponent>(uid, out var flashlight)) { _actionsSystem.AddAction(args.BuckledEntity, flashlight.ToggleAction, uid, actions); } if (component.HornSound != null) { _actionsSystem.AddAction(args.BuckledEntity, component.HornAction, uid, actions); } _itemSlotsSystem.SetLock(uid, component.Name, true); return; } // Clean up actions and virtual items _actionsSystem.RemoveProvidedActions(args.BuckledEntity, uid); _virtualItemSystem.DeleteInHandsMatching(args.BuckledEntity, uid); // Go back to old pullable behavior _tagSystem.RemoveTag(uid, "DoorBumpOpener"); EnsureComp <SharedPullableComponent>(args.BuckledEntity); EnsureComp <SharedPullableComponent>(uid); // Entity is no longer riding RemComp <RiderComponent>(args.BuckledEntity); // Reset component component.HasRider = false; component.Rider = null; _itemSlotsSystem.SetLock(uid, component.Name, false); }
/// <summary> /// Turn off the engine when key is removed. /// </summary> private void OnEntRemoved(EntityUid uid, VehicleComponent component, EntRemovedFromContainerMessage args) { if (args.Container.ID != KeySlot || !RemComp <InVehicleComponent>(args.Entity)) { return; } // Disable vehicle component.HasKey = false; _ambientSound.SetAmbience(uid, false); _tagSystem.RemoveTag(uid, "DoorBumpOpener"); _modifier.RefreshMovementSpeedModifiers(uid); }
private void OnMindRemoved(EntityUid uid, DroneComponent drone, MindRemovedMessage args) { UpdateDroneAppearance(uid, DroneStatus.Off); _tagSystem.RemoveTag(uid, "DoorBumpOpener"); EnsureComp <GhostTakeoverAvailableComponent>(uid); }